TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Shoey on March 13, 2018, 01:48:47 PM
-
Hello All
I have the lisp code below, which aligns a block in paper space (in this case a north point block) to the WCS (north) of the model space view.
I would like modifications to this but need help if anybody can help?
The modification i would like is for an error trap.
I would like it to loop if i miss or select anything but a viewport or the polyline boundary of the polygon viewport.
And also if i select anything but the block it errors.
Any help appreciated.
;;Wriiten by Mike Roberts
(defun c:RN()
(setq tw(entget(car(entsel" Select a Viewport:"))))
(setq new (cdr (assoc 0 tw)))
(cond
((= new "VIEWPORT")(setq rt(cdr(assoc 51 tw))))
((= new "LWPOLYLINE")(setq temp (entget(cdr (assoc 330 tw))))(setq rt(cdr(assoc 51 temp))))
)
(setq en(car(entsel" Select North Arrow: ")))
(setq elist(entget en))
(setq elist(subst (cons 50 rt)(assoc 50 elist) elist))
(entmod elist)
(princ)
)
Many thanks
-
Try the following instead:
(defun c:rn
( / ent obj sel
) )
)
)
(princ "\nMissed, try again.") )
(princ "\nMissed, try again.") )
(princ "\nThe selected object is not a block.") )
(princ "\nThe selected block is on a locked layer.") )
)
)
)
)
)
(princ "\nCommand only available in Paperspace.") )
)
-
There is also THIS (http://www.theswamp.org/index.php?topic=19285.msg234463#msg234463) from many moons ago.
-
Thanks to Lee Mac and Ronjonp.
Appreciate your time and feedback.