Author Topic: SSGET variable?  (Read 5782 times)

0 Members and 1 Guest are viewing this topic.

Daniel J. Ellis

  • Swamp Rat
  • Posts: 811
SSGET variable?
« on: February 16, 2009, 09:06:14 AM »
I'm working on a routine that selects all the objects on a layer, quite simply just:

<code>(SETQ ss (SSGET "x" '((8 . "0-fdp-h-nos-plot"))))</CODE>

However, I want to the routine to be able to select one of a number of layers, then do the SSGET on the specified layer:

(CODE>(SETQ ss (SSGET ("x" '((8 . layer)))))</CODE>

but test runs don't seem to like this.  Can anybody suggest anything?

Not got time to test now, but I've just wondered if I can go

<CODE>(setq SS (ssget "X" laylist))</code>

Having previously defined laylist as being equivilent to (8 . layer).  Does that sound plausible?

dJE
===
dJE

litss

  • Guest
Re: SSGET variable?
« Reply #1 on: February 16, 2009, 09:18:17 AM »
you gotta use "and" or "or", something like:

Code: [Select]
(ssget '((-4 . "<OR") (-4 . "<AND")
                             (0 . "TEXT")
                             (8 . "12")
                             (-4 . "AND>")
                             (-4 . "<AND")
                             (0 . "*LINE")
                             (8 . "0")
                             (-4 . "AND>")
                             (-4 . "OR>")
                            )
                     )

hope it helps :)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: SSGET variable?
« Reply #2 on: February 16, 2009, 09:41:05 AM »
This routine is a good example of how to create a list of layers for ssget
http://www.theswamp.org/index.php?topic=1915.0

You can also combine layer names as a text string separating them with a comma like this:
Code: [Select]
(setq ss (ssget "_X" '((8 . "layer1,Layer2,Layer3"))))You may also use wildcard characters in the string names.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

GDF

  • Water Moccasin
  • Posts: 2081
Re: SSGET variable?
« Reply #3 on: February 16, 2009, 10:19:59 AM »
Alan

I get the following error with the csel routine:

elect object for color filter.; error: bad argument type: stringp T

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: SSGET variable?
« Reply #4 on: February 16, 2009, 10:24:23 AM »
And just to clarify your intial question, this:
Code: [Select]
(SETQ ss (SSGET ("x" '((8 . layer))))) needs to look like this:
Code: [Select]
(SETQ ss (SSGET ("x" (list (cons 8  layer)))))When you have a variable in a list, that list must be generated with (cons). Quoted lists may only be used when no variables are involved.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: SSGET variable?
« Reply #5 on: February 16, 2009, 10:57:29 AM »
Alan

I get the following error with the csel routine:

elect object for color filter.; error: bad argument type: stringp T

Gary

I can't recreate the error. Would you mind running the lisp with VLIDE & tell me which line the error occurs?

If here (while (setq ent (entsel col:prompt))
what is in the variable col:prompt ?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

GDF

  • Water Moccasin
  • Posts: 2081
Re: SSGET variable?
« Reply #6 on: February 16, 2009, 11:09:43 AM »
Alan

I get the following error with the csel routine:

elect object for color filter.; error: bad argument type: stringp T

Gary

I can't recreate the error. Would you mind running the lisp with VLIDE & tell me which line the error occurs?

If here (while (setq ent (entsel col:prompt))
what is in the variable col:prompt ?

Alan

The vlide editor stops here:

(get_color_name col)

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Daniel J. Ellis

  • Swamp Rat
  • Posts: 811
Re: SSGET variable?
« Reply #7 on: February 16, 2009, 04:15:41 PM »
That's exactly the answer I was looking for, thanks Jeff :)

dJE

needs to look like this:
Code: [Select]
(SETQ ss (SSGET ("x" (list (cons 8  layer)))))When you have a variable in a list, that list must be generated with (cons). Quoted lists may only be used when no variables are involved.
===
dJE

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: SSGET variable?
« Reply #8 on: February 16, 2009, 04:45:58 PM »
Gary,
Looks like the code here
Code: [Select]
      (setq col (cdr (assoc 62
                            (tblsearch "layer"
                                     (cdr (assoc 8 (entget (car ent))))))))
is not returning a color number. It might be a True Color issue, not sure.
No error in ACAD2k, but I'll try to check it out in 2k6.Don't have anything newer.  :-(
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

GDF

  • Water Moccasin
  • Posts: 2081
Re: SSGET variable?
« Reply #9 on: February 16, 2009, 06:12:01 PM »
Gary,
Looks like the code here
Code: [Select]
      (setq col (cdr (assoc 62
                            (tblsearch "layer"
                                     (cdr (assoc 8 (entget (car ent))))))))
is not returning a color number. It might be a True Color issue, not sure.
No error in ACAD2k, but I'll try to check it out in 2k6.Don't have anything newer.  :-(


Ok, thanks Alan
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: SSGET variable?
« Reply #10 on: February 16, 2009, 07:21:52 PM »
Alan, not sure why it works in 2000...... :-)

Your function (get_color_name) returns T or nil, not the color as intended. This makes the (strcat) function fail since there is always a T returned...(strcat "Textstring " T) fails.

Changing that function to this allows it to work correctly.
Code: [Select]
(defun get_color_name (c# / col)
    (setq col (assoc c# '((1  "Red")
                          (2  "Yellow")
                          (3  "Green")
                          (4  "Cyan")
                          (5  "Blue")
                          (6  "Magenta")
                          (7  "Black/White")
                          (8  "Dark Grey")
                          (9  "Grey"))
               ))
    (or (cadr col) (setq col (itoa c#)));;changed this line
    col ;;added this line
  )
HTH

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: SSGET variable?
« Reply #11 on: February 16, 2009, 11:45:13 PM »
Jeff, I thought you were crazy until I went and looked at the code in the link.
Sure enough I had updated the code in my computer but never updated the posted code.
Thanks for keeping an eye out.

This was my sub and the reason it always worked for me  :oops:
 I did change the code out today. (not sure how that one was never caught.)
Code: [Select]
  ;; return the color name from the color number supplied
  ;; else return the number as a string
  (defun get_color_name (c# / col)
    (setq col (assoc c# '((1  "Red")
                          (2  "Yellow")
                          (3  "Green")
                          (4  "Cyan")
                          (5  "Blue")
                          (6  "Magenta")
                          (7  "Black/White")
                          (8  "Dark Grey")
                          (9  "Grey"))
               ))
    (if col
      (cadr col)
      (itoa c#))
  )
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: SSGET variable?
« Reply #12 on: February 17, 2009, 01:15:32 AM »
Jeff, I thought you were crazy
Probably right about that.
Quote
Thanks for keeping an eye out.

I did change the code out today. (not sure how that one was never caught.)
No problem. And I see that my "fixed" code fragment only fixed part of it. If the color was one that returns a named value, mine would fail since I neglected to note that you have col as a list.

My turn for an :oops:

GDF

  • Water Moccasin
  • Posts: 2081
Re: SSGET variable?
« Reply #13 on: February 17, 2009, 10:35:38 AM »
Thanks Alan, it works perfectly now.
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: SSGET variable?
« Reply #14 on: February 17, 2009, 11:44:13 AM »
You're welcome & thanks for reporting the error. 8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.