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

using variables to make up a point

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
rodb
283 Views, 4 Replies

using variables to make up a point

Can anyone help with this, I always have trouble with syntax!

 

(setq pt1 '(0.0 0.0 0.0)
    pt2 '(-520.0 0.0 0.0)
    pt3 '(-520.0 10.0 0.0)
    pt4 '(0.0 10.0 0.0)
    pt5 '(0.0 480.0 0.0)
)
    
(setq ss1 (ssget "C" pt1 pt2 '(( 8 . "grid"))))
;this works

; but how to pass variables to a point list
(setq ldist 500)
(setq xfit (cadr (assoc 10 (entget e1))))
(setq yfit (caddr (assoc 10 (entget e1))))
            
(setq pt6 '((- xfit ldist) (+ yfit 3.0) 0.0))

4 REPLIES 4
Message 2 of 5
trevor.bird.au
in reply to: rodb

Hi rodb,

Try this:
(setq pt6 (list (- xfit ldist) (+ yfit 3.0) 0.0))

The list function will evaluate the variables xfit, ldist & yfit in the point list variable you are creating.

The AutoLISP Reference in the help will explain ' & list.

Hope this helps.

Regards,
Trevor
Message 3 of 5
rodb
in reply to: trevor.bird.au

Yes!!!! I that does work, its all about putting ( ) in the right place, thought there must be a way. I saw this worked

(setq pt6 (list xfit yfit 0.0)) so there was hope. Thanks so much perhaps I can sort out my main program now.

Message 4 of 5
trevor.bird.au
in reply to: rodb

You're welcome rodb,

The parentheses are important but the function you use to construct the point list is more critical i.e. the quote (') function or the list function.

From the AutoLISP help:
As an alternative to using the list function, you can explicitly quote a list with the quote function if there are no variables or undefined items in the list. The single quote character (') is defined as the quote function.

Thank you also for the kudos rodb.


Regards,
Trevor
Message 5 of 5
rodb
in reply to: trevor.bird.au

Thank you Trevor, now you see that explains the difference between list and ( ' ) perfectly, never could work out what the difference was. Now the program listed in "Teaser for all Experts" is working perfectly even in auto mode. Amazing!

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

Post to forums  

Autodesk Design & Make Report

”Boost