Some answers for you, I won't be in for the rest of the day.
Hope this helps.
Code:
(defun c:CPL ( / pld pps ps orsnap p1 p2); make variables local to the lisp
(null (initget 1)); << whats this null do?
because initget returns nil the null returns true and keeps you in the AND expression
(princ); << whats this do?
in this case it prevents the routine from returning nil at the command line
You are breaking out of the loop with the Escape key which doesn't let the routine finish.
Prevent this with an error handler or trapping the Escape key press.
Here is the example of the error routine.
Code:
(defun c:CPL (/ *error* pld pps ps useror p1 p2) ; << whats this do?
;; error function & Routine Exit
(defun *error* (msg)
(if
(not
(member
msg
'("console break" "Function cancelled" "quit / exit abort" "")
)
)
(princ (strcat "\nError: " msg))
) ; endif
;; reset all variables here
(and useror (setvar "orthomode" useror))
(and useros (setvar "osmode" useros))
(if usercmd
(setvar "CMDECHO" usercmd)
(setvar "CMDECHO" 1) ; preferred default
)
) ; end error function
;; Start routine here
(setq PLD "Canon iC2300 PCL5e") ; << Ploting Device
(setq PPS "(11x17)") ; << Paper Size
(setq PS "ARINC-BASE.ctb") ; << Plot yStyle Table
(setq useror (getvar "osmode"))
(setvar "OSMODE" 1)
(while
(and ; all must be true to stay in loop
(null (initget 1))
(setq P1 (getpoint "\n Upper Left Endpoint: "))
(null (initget 1))
(setq P2 (getcorner p1 "\n Lower Right Endpoint: "))
)
(command "-PLOT" "y" "" PLD "11x17" "in" "l" "n" "w" P1 P2 "f" "c" "" PS ""
"" "" "y" "")
)
(*error* "") ; run the error routine with no message to restore vars
(princ) ; exit quietly
)
This is an example of trapping the escape at each getpoint.
Code:
(defun c:CPL (/ pld pps ps useror p1 p2 err)
;; Start routine here
(setq PLD "Canon iC2300 PCL5e") ; << Ploting Device
(setq PPS "(11x17)") ; << Paper Size
(setq PS "ARINC-BASE.ctb") ; << Plot yStyle Table
(setq useror (getvar "osmode"))
(setvar "OSMODE" 1)
(while
(and ; all must be true to stay in loop
(null (initget 1))
(if
(vl-catch-all-error-p
(setq p1 (vl-catch-all-apply
'getpoint '("\n Upper Left Endpoint: ")))
)
(alert (vl-catch-all-error-message p1)) ; returns nil & exit AND
t ; stay in AND
)
(null (initget 1))
(if
(vl-catch-all-error-p
(setq p2 (vl-catch-all-apply
'getcorner (list p1 "\n Lower Right Endpoint: ")))
)
(alert (vl-catch-all-error-message p2)) ; returns nil & exit AND
t ; stay in AND
)
)
(command "-PLOT" "y" "" PLD "11x17" "in" "l" "n" "w" P1 P2 "f" "c" "" PS ""
"" "" "y" "")
)
(setvar "OSMODE" useror)
(princ) ; exit quietly
)
Bookmarks