Using a variable value in sintax (autoLISP)

Using a variable value in sintax (autoLISP)

Anonymous
Not applicable
821 Views
1 Reply
Message 1 of 2

Using a variable value in sintax (autoLISP)

Anonymous
Not applicable

 I want to use a variable I get from selection to write the code, to be more precise, I want the user to select a entity, and then the code will get the type of this entity and I will use ssget to make a list of everything that has that type. So far, I'm trying this:

 

(defun c:qualtipo()
(setq tipsel (entsel))
(setq tip (entget (car tipsel)))
(setq tipolayer (dxf 8 tip))
(setq ss (ssget "X" ' ((0. "LINE")((8. tipolayer)))))
(setq count (sslength ss))
)

 

But everytime I get bad ssget list.

0 Likes
Accepted solutions (1)
822 Views
1 Reply
Reply (1)
Message 2 of 2

Kent1Cooper
Consultant
Consultant
Accepted solution

This really belongs over in the Customization Forum....

 

You need a space between the DXF code number [0 or 8 in your case] and the period/decimal.

 

And unless you have a (dxf) function that you didn't include to pull a value out of an entity data list, your 'tipolayer' needs to use the (assoc) function, and will contain the entire entry, including  the 8 and the period, so don't pair it with another 8.

 

And when anything in a list like this filter list includes something that needs to be evaluated, such as a variable, you can't use the "quoted" list approach with the apostrophe at the beginning, but you must use the explicit (list) function.

 

Try this adjustment:

....

  (setq tipolayer (assoc 8 tip))

  (setq ss (ssget "X" (list '(0 . "LINE") tipolayer)))

....

 

Or, if you have a (dxf) function, and (dxf 8 tip) extracts just the Layer name, without the 8 and period, then you do need to (cons)ociate that with an 8 again:

....

  (setq ss (ssget "X" (list '(0 . "LINE") (cons 8 tipolayer))))

....

Kent Cooper, AIA
0 Likes