DWS44
2006-12-09, 12:27 AM
Admittedly I'm not the greatest @ LISP. I found some code on the net and edited it a bit to accomplish what I wanted it to do (create a pipe w/ multiple lines in plan view formatted to company standards) It's probably not pretty, but I've managed to get it to do exactly what I wanted it to do and it works great, however when I load it I get " error: bad argument type: lentitype nil"
The program still works fine, but the error is annoying, and I'd like to get rid of it if I can before rolling it out to users. Perhaps someone could take a gander at the code and see what might be causing this error?
(Defun C:3L ()
(command "UNDO" "MARK")
(Setvar "Cmdecho" 0)
(Progn
(Prompt "\nEnter size of pipe (in feet):<")
(Princ (Rtos (Getvar "Userr3") 2 3))
(Initget 6)
(Setq A (Getdist ">: "))
(If (= nil A)
(Setq A (Getvar "Userr3"))
(Setvar "Userr3" A)
)
)
(Initget 1)
(Setq P1 (Getpoint "\nFrom point: "))
(Initget 1)
(Setq P2 (Getpoint P1 "\nTo point: "))
(Command "Pline" P1 "w" A A P2)
(Setq P4 t)
(While
(Boundp 'P4)
(Initget "U C")
(Setq P4 (Getpoint (Getvar "Lastpoint") "\nTo point: "))
(Cond
((= nil P4)(Command ""))
((= "C" P4)(Command "CL")(Setq P4 nil))
((= "U" P4)(Command "U"))
((= 'LIST (Type P4))(Command P4))
)
)
;******** Routine to fillet (make elbows) of the centerline.********
(setq rad nil)
(Initget "Y N")
(Setq B (Getkword "\nDo you wish Pipe to have elbows? [N/<Y>]: "))
(If
(Or (= B "Y")(= B nil))
(progn
(setq Rad (getreal "\nSize of radius <1.5xPipe size> or Specify :
"))
(progn
(if (= Rad nil)
(setq rad (* 1.5 (getvar "Userr3")))
)
(command ".fillet" "r" Rad )
)
)
)
(Setq E1 (Entlast))
(if (/= rad nil)
(command "fillet" "p" E1)
)
;****** End of routine to make elbows, Start to do the Offset **********
(command "offset" (/ a 2.0) e1 (polar p1 (+ (angle p1 p2)(/ pi 2)) a) "")
(Setq E2 (Entlast))
(command "offset" (/ a 2.0) e1 (polar p1 (- (angle p1 p2)(/ pi 2)) a) "")
(Setq E3 (Entlast))
(Command "pedit" E2 "w" "0" ^C "pedit" E3 "w" "0" ^C "pedit" E1 "l" "OFF" ^C)
(Initget "EX PRO")
(Prompt "\nIs this pipe Existing or Proposed?")
(Setq AP (Getkword "\n[EXisting/<PROposed>]: "))
(Cond
((= AP "EX")
(Command "Change" E1 "" "P" "LA" "drainage-dashed-ex" "" "Change" E2 "" "P" "LA" "drainage-ex" "" "Change" E3 "" "P" "LA" "drainage-ex" "")
)
((Or (= AP "PRO")(= AP nil))
(Command "Change" E1 "" "P" "LA" "drainage-dashed-pro" "" "Change" E2 "" "P" "LA" "drainage-pro" "" "Change" E3 "" "P" "LA" "drainage-pro" "")
);end of this specific condition
);end of cond
(draw_welds)
(Initget "Y N")
(Princ)
)
(defun draw_welds ();/ polyline1 vert vertg polylist1 polyline2 polylist2
vert_no count)
(setq polylist1 nil polylist2 nil)
(setq polyline1 E2)
(setq vert (entnext polyline1))
(setq vertg (entget vert))
(while (/= (cdr (assoc 0 vertg)) "SEQEND")
(setq polylist1 (cons (cdr (assoc 10 vertg)) polylist1))
(setq vert (entnext vert))
(setq vertg (entget vert))
)
(setq polyline2 E3)
(setq vert (entnext polyline2))
(setq vertg (entget vert))
(while (/= (cdr (assoc 0 vertg)) "SEQEND")
(setq polylist2 (cons (cdr (assoc 10 vertg)) polylist2))
(setq vert (entnext vert))
(setq vertg (entget vert))
)
(setq vert_no (length polylist1))
(setq count 0)
(while (/= count vert_no)
(command "line" (nth count polylist1) (nth count polylist2) "")
(setq count (1+ count))
)
)
Thanks!
The program still works fine, but the error is annoying, and I'd like to get rid of it if I can before rolling it out to users. Perhaps someone could take a gander at the code and see what might be causing this error?
(Defun C:3L ()
(command "UNDO" "MARK")
(Setvar "Cmdecho" 0)
(Progn
(Prompt "\nEnter size of pipe (in feet):<")
(Princ (Rtos (Getvar "Userr3") 2 3))
(Initget 6)
(Setq A (Getdist ">: "))
(If (= nil A)
(Setq A (Getvar "Userr3"))
(Setvar "Userr3" A)
)
)
(Initget 1)
(Setq P1 (Getpoint "\nFrom point: "))
(Initget 1)
(Setq P2 (Getpoint P1 "\nTo point: "))
(Command "Pline" P1 "w" A A P2)
(Setq P4 t)
(While
(Boundp 'P4)
(Initget "U C")
(Setq P4 (Getpoint (Getvar "Lastpoint") "\nTo point: "))
(Cond
((= nil P4)(Command ""))
((= "C" P4)(Command "CL")(Setq P4 nil))
((= "U" P4)(Command "U"))
((= 'LIST (Type P4))(Command P4))
)
)
;******** Routine to fillet (make elbows) of the centerline.********
(setq rad nil)
(Initget "Y N")
(Setq B (Getkword "\nDo you wish Pipe to have elbows? [N/<Y>]: "))
(If
(Or (= B "Y")(= B nil))
(progn
(setq Rad (getreal "\nSize of radius <1.5xPipe size> or Specify :
"))
(progn
(if (= Rad nil)
(setq rad (* 1.5 (getvar "Userr3")))
)
(command ".fillet" "r" Rad )
)
)
)
(Setq E1 (Entlast))
(if (/= rad nil)
(command "fillet" "p" E1)
)
;****** End of routine to make elbows, Start to do the Offset **********
(command "offset" (/ a 2.0) e1 (polar p1 (+ (angle p1 p2)(/ pi 2)) a) "")
(Setq E2 (Entlast))
(command "offset" (/ a 2.0) e1 (polar p1 (- (angle p1 p2)(/ pi 2)) a) "")
(Setq E3 (Entlast))
(Command "pedit" E2 "w" "0" ^C "pedit" E3 "w" "0" ^C "pedit" E1 "l" "OFF" ^C)
(Initget "EX PRO")
(Prompt "\nIs this pipe Existing or Proposed?")
(Setq AP (Getkword "\n[EXisting/<PROposed>]: "))
(Cond
((= AP "EX")
(Command "Change" E1 "" "P" "LA" "drainage-dashed-ex" "" "Change" E2 "" "P" "LA" "drainage-ex" "" "Change" E3 "" "P" "LA" "drainage-ex" "")
)
((Or (= AP "PRO")(= AP nil))
(Command "Change" E1 "" "P" "LA" "drainage-dashed-pro" "" "Change" E2 "" "P" "LA" "drainage-pro" "" "Change" E3 "" "P" "LA" "drainage-pro" "")
);end of this specific condition
);end of cond
(draw_welds)
(Initget "Y N")
(Princ)
)
(defun draw_welds ();/ polyline1 vert vertg polylist1 polyline2 polylist2
vert_no count)
(setq polylist1 nil polylist2 nil)
(setq polyline1 E2)
(setq vert (entnext polyline1))
(setq vertg (entget vert))
(while (/= (cdr (assoc 0 vertg)) "SEQEND")
(setq polylist1 (cons (cdr (assoc 10 vertg)) polylist1))
(setq vert (entnext vert))
(setq vertg (entget vert))
)
(setq polyline2 E3)
(setq vert (entnext polyline2))
(setq vertg (entget vert))
(while (/= (cdr (assoc 0 vertg)) "SEQEND")
(setq polylist2 (cons (cdr (assoc 10 vertg)) polylist2))
(setq vert (entnext vert))
(setq vertg (entget vert))
)
(setq vert_no (length polylist1))
(setq count 0)
(while (/= count vert_no)
(command "line" (nth count polylist1) (nth count polylist2) "")
(setq count (1+ count))
)
)
Thanks!