I've seen a number of challenges and "why I wrote this" type threads so I thought I try one out:
What initially drew me to AutoLISP was the ability to write quick and dirty routines, on the fly when needed, to cut drafting times in half! Of course as I learned more my routines became more robust and thus much more complicated. Did I get caught up in the "figuring out" of a complex process? (remember, I'm an architect, my knowledge of all things digital is very limited!)
So my question is: Which one of the following routines is more beautiful to you? Don't make the decision too complicated by arguing function, use, etc. Just which one are you first drawn too?
A
(defun c:MyLine( / )
(command "line" pause pause "")
(princ)
)
B
(defun c:MyLine (/ *Error* doc act space p1 p2 pt1 pt2)
(defun *Error* (Msg)
(cond ((or (not Msg)
(member Msg '("console break" "Function cancelled" "quit / exit abort"))
)
)
((princ (strcat "\nError: " Msg)))
)
(princ)
)
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vla-StartUndoMark doc)
(setq act (vlax-get doc 'activespace))
(cond ((= act 1)
(setq space (vlax-get doc 'modelspace))
)
((= act 0)
(setq space (vlax-get doc 'paperspace))
)
)
(setq p1 (getpoint "\nSelect start point: "))
(if p1
(setq p2 (getpoint p1 "\nSelect end point: "))
)
(if (and p1 p2)
(progn
(setq pt1 (vlax-3d-point p1)
pt2 (vlax-3d-point p2)
)
(vla-addline space pt1 pt2)
)
)
(vla-EndUndoMark doc)
(princ)
)