Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using a variable value in sintax (autoLISP)

1 REPLY 1
SOLVED
Reply
Message 1 of 2
Anonymous
728 Views, 1 Reply

Using a variable value in sintax (autoLISP)

 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.

Tags (1)
Labels (3)
1 REPLY 1
Message 2 of 2
Kent1Cooper
in reply to: Anonymous

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report