Originally Posted by
Opie
Do you mind sharing what you have already? Maybe someone here could help you over the hump with your code.
I was able to work with someone today and he helped me with this, it is actually from autocad 2006, but I want to use it in 2011. When I try to use it, I get this error.
Also, I am having problems with layers. As you can see, I want to use the "0" layer. I know it is probably not right, but any help is greatly appreciated.
Pick Orientation: bad argument type: numberp: nil
Code:
;# THIS IS FOR CREATING A UNION (1UNION.LSP).
(DEFUN C:1union(/ a1 a2 s1 ang1 ang2 p1 p2 p3 p4 p5 p6 p7 p8 p9
p10 p11 p12 p13)
(setvar "cmdecho" 0)
(setvar "coords" 2)
(setq kla (getvar "clayer"))
(command "LAYER" "S" "0" "")
(prompt "\nPresent Scaling Factor For The 1Union Is: ")
(princ nzscle)
(defun loop1()
(setq p2 (polar p1 ang1 (* 0.05 nzscle)))
(setq p3 (polar p1 ang1 (* -0.05 nzscle)))
(setq p4 (polar p2 ang2 (* 0.0875 nzscle)))
(setq p5 (polar p2 ang2 (* -0.0875 nzscle)))
(setq p6 (polar p3 ang2 (* 0.0875 nzscle)))
(setq p7 (polar p3 ang2 (* -0.0875 nzscle)))
(setq p8 (polar p1 ang2 (* 0.125 nzscle)))
(setq p9 (polar p1 ang2 (* -0.125 nzscle)))
(initget "Yes No")
(setq a2 (getkword "\nCut Pipe Out? <Y>: "))
(if (= a2 nil) (command "BREAK" p1 "F" p2 p3))
(if (= a2 "Yes") (command "BREAK" p1 "F" p2 p3))
(if (= a2 "No") (prompt "\nNo Pipe Will Be Cut."))
(command "PLINE" p4 "W" (* 0.009 nzscle) (* 0.009 nzscle) p5 ""
"PLINE" p6 "W" (* 0.009 nzscle) (* 0.009 nzscle) p7 ""
"PLINE" p8 "W" (* 0.009 nzscle) (* 0.009 nzscle) p9 "")
(command "INSERT" "WELD" p2 nzscle nzscle "0")
(command "INSERT" "WELD" p3 nzscle nzscle "0")
)
(defun loop2()
(setq p2 (polar p1 ang1 (* 0.05 nzscle)))
(setq p3 (polar p1 ang1 (* -0.05 nzscle)))
(setq p4 (polar p2 ang2 (* 0.0875 nzscle)))
(setq p5 (polar p2 ang2 (* -0.0875 nzscle)))
(setq p6 (polar p3 ang2 (* 0.0875 nzscle)))
(setq p7 (polar p3 ang2 (* -0.0875 nzscle)))
(setq p8 (polar p1 ang2 (* 0.125 nzscle)))
(setq p9 (polar p1 ang2 (* -0.125 nzscle)))
(setq p10 (polar p2 ang2 (* 0.0625 nzscle)))
(setq p11 (polar p2 ang2 (* -0.0625 nzscle)))
(setq p12 (polar p3 ang2 (* 0.0625 nzscle)))
(setq p13 (polar p3 ang2 (* -0.0625 nzscle)))
(setq p14 (polar p10 ang1 (* 0.0625 nzscle)))
(setq p15 (polar p11 ang1 (* 0.0625 nzscle)))
(setq p16 (polar p12 ang1 (* -0.0625 nzscle)))
(setq p17 (polar p13 ang1 (* -0.0625 nzscle)))
(initget "Yes No")
(setq a2 (getkword "\nCut Pipe Out? <Y>: "))
(if (= a2 nil) (command "BREAK" p1 "F" p2 p3))
(if (= a2 "Yes") (command "BREAK" p1 "F" p2 p3))
(if (= a2 "No") (prompt "\nNo Pipe Will Be Cut."))
(command "PLINE" p4 "W" (* 0.009 nzscle) (* 0.009 nzscle) p5 ""
"PLINE" p6 "W" (* 0.009 nzscle) (* 0.009 nzscle) p7 ""
"PLINE" p10 "W" (* 0.009 nzscle) (* 0.009 nzscle) p14 ""
"PLINE" p11 "W" (* 0.009 nzscle) (* 0.009 nzscle) p15 ""
"PLINE" p12 "W" (* 0.009 nzscle) (* 0.009 nzscle) p16 ""
"PLINE" p13 "W" (* 0.009 nzscle) (* 0.009 nzscle) p17 ""
"PLINE" p8 "W" (* 0.009 nzscle) (* 0.009 nzscle) p9 "")
)
(defun loop3()
(setq p2 (polar p1 ang1 (* 0.05 nzscle)))
(setq p3 (polar p1 ang1 (* -0.05 nzscle)))
(setq p4 (polar p2 ang2 (* 0.0875 nzscle)))
(setq p5 (polar p2 ang2 (* -0.0875 nzscle)))
(setq p6 (polar p3 ang2 (* 0.0875 nzscle)))
(setq p7 (polar p3 ang2 (* -0.0875 nzscle)))
(setq p8 (polar p1 ang2 (* 0.125 nzscle)))
(setq p9 (polar p1 ang2 (* -0.125 nzscle)))
(initget "Yes No")
(setq a2 (getkword "\nCut Pipe Out? <Y>: "))
(if (= a2 nil) (command "BREAK" p1 "F" p2 p3))
(if (= a2 "Yes") (command "BREAK" p1 "F" p2 p3))
(if (= a2 "No") (prompt "\nNo Pipe Will Be Cut."))
(command "PLINE" p4 "W" (* 0.009 nzscle) (* 0.009 nzscle) p5 ""
"PLINE" p6 "W" (* 0.009 nzscle) (* 0.009 nzscle) p7 ""
"PLINE" p8 "W" (* 0.009 nzscle) (* 0.009 nzscle) p9 "" )
)
(if (null onion)
(progn
(initget 1 "Butt-weld Socket-weld Threaded")
(prompt "\nType Of Union? ")
(setq onion (getkword " Butt-weld/Socket-weld/Threaded: "))
)
(progn
(setq a1 onion)
(initget "Butt-weld Socket-weld Threaded")
(prompt "\nType Of 1Union / <")
(princ (strcat onyon ">: "))
(setq onion (getkword "\n Butt-weld/Socket-weld/Threaded: "))
(if (= onion nil) (setq onion a1))
)
)
(cond ((= onion "Butt-weld") (setq s1 loop1) (setq onyon "Butt-weld"))
((= onion "Socket-weld") (setq s1 loop2) (setq onyon "Socket-weld"))
((= onion "Threaded") (setq s1 loop3) (setq onyon "Threaded"))
)
(setq p1 (getpoint "\nPick Center Of Union: "))
(setq ang1 (getangle p1 "\nPick Run Direction: "))
(setq ang2 (getangle p1 "\nPick Orientation: "))
(s1)
(command "LAYER" "S" kla "")
(princ)
)