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

How do I make this work?

3 REPLIES 3
Reply
Message 1 of 4
Davmt
159 Views, 3 Replies

How do I make this work?

I found this lisp online that will snap to the center of a rectangle but after I load it, I can't get it to work, would someone please take a look and see why it won't work?
Thanks!


defun c:SnapToCenter (/ a1 cen d1 ent p1 p2 RecObj)
(vl-load-com)
(setq ent (car (entsel "\nSelect Rectangle: <> "))
RecObj (vlax-ename->vla-object ent)
p1 (safearray-value (variant-value (vla-get-Coordinate RecObj 0)))
p2 (safearray-value (variant-value (vla-get-Coordinate RecObj 2)))
a1 (angle p1 p2)
d1 (distance p1 p2)
cen (polar p1 a1 (* d1 0.5))
)
(vl-cmdf ".move" ent "" cen pause)
(princ)
)


David
Jacobs Tech.
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Davmt

[Could it be that it's missing the ( at the beginning?]
--
Kent Cooper


wrote...
I found this lisp online that will snap to the center of a rectangle but after I load it, I can't
get it to work, would someone please take a look and see why it won't work?
Thanks!


defun c:SnapToCenter (/ a1 cen d1 ent p1 p2 RecObj)
(vl-load-com)
(setq ent (car (entsel "\nSelect Rectangle: <> "))
RecObj (vlax-ename->vla-object ent)
p1 (safearray-value (variant-value (vla-get-Coordinate RecObj 0)))
p2 (safearray-value (variant-value (vla-get-Coordinate RecObj 2)))
a1 (angle p1 p2)
d1 (distance p1 p2)
cen (polar p1 a1 (* d1 0.5))
)
(vl-cmdf ".move" ent "" cen pause)
(princ)
)


David
Jacobs Tech.
Message 3 of 4
Davmt
in reply to: Davmt

Thats what it was, Thanks Kent!
Message 4 of 4
Anonymous
in reply to: Davmt

[A Homer Simpson (D'oh!!) moment, perhaps?]
--
Kent Cooper


wrote...
Thats what it was, Thanks Kent!

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

Post to forums  

Autodesk Design & Make Report

”Boost