regsamp
asked on
Programming issue/question
In AutoCad we are trying to use AutoLISP and with other languages like C to run a small program with endlines. It works fine until we go to do a Return. We get an error message saying unknown command. We are probably missing something simple but how could a return statement be added to this program without the error so we can just Return out of it? The code is posted below.
Any assistance offered would be greatly appreciated.
Any assistance offered would be greatly appreciated.
(defun C:pipebends ( )
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(setq PT2 (getpoint "\n Select Location for Bends: "))
(while
(progn
(setq pt5 nil)
(setq PT3 (car (nentselp PT2)))
(setq PT (list PT3 PT2))
(setq XP (entget (car PT)))
(setq YP (osnap (cadr PT) "nea"))
(setq YREM (cdr (assoc 0 XP)))
(cond
((equal "LINE" YREM)
(setq ST (cdr (assoc 10 XP)))
(setq END (cdr (assoc 11 XP)))
)
((or (equal "ARC" YREM) (equal "CIRCLE" YREM))
(setq DIST (distance (cdr (assoc 10 XP)) YP))
(setq ANGA (angle (cdr (assoc 10 XP)) YP))
(setq ST (cdr (assoc 10 XP)))
(setq END (polar ST (+ ANGA (cvunit 90 "degree" "radian")) DIST))
)
((or (equal "POLYLINE" YREM) (equal "LWPOLYLINE" YREM))
(setq CEN (OSNAP (CADR PT) "CEN"))
(if (/= cen nil)
(progn
(setq DIST2 (distance YP CEN))
(setq ANGA2 (angle CEN YP))
(setq END2 (polar YP (+ ANGA2 (cvunit 90 "degree" "radian")) DIST2))
(setq ST YP)
(setq END END2)
)
(progn
(setq PL (OSNAP (CADR PT) "MID"))
(setq DIST3 (distance YP PL))
(setq ANGA3 (angle PL YP))
(setq END3 (polar YP (+ ANGA3 (cvunit 0 "degree" "radian")) DIST3))
(setq ST YP)
(setq END END3)
)
)
)
)
(setq ANG (angle ST END))
(if (and (<= ANG 4.71239) (> ANG 1.5708))
(setq ANG (angle END ST)))
(setq ANGF (* ANG (/ 180 pi)))
(command "INSERT" "Bends" YP "" "" ANGF)
(setq lo (entlast))
(setq pt5 (getpoint pt2 "\nSelect Second Point for Pipe Bend: "))
(if (= pt5 nil)
(princ)
)
(command "line" pt2 pt5 "")
(command "erase" lo "")
(setq pt2 pt5)
); end progn
); end while
(setvar "osmode" 0)
(setvar "cmdecho" 1)
(princ)
)
What line are you trying to break at? I can't see a return statement anywhere in your code
ASKER
That is it chaau, we are not sure how and where to put it. In AutoCad, when you right click the mouse the program running in AutoCad should return and leave but this displays the unknown command on the return
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
We were able to get it with an IF statement