PDA

View Full Version : Making block with lisp. Name?



J-LYLE
16th Mar 2005, 08:19 pm
ok ive made some adjustments to the previous posted lisp(thanks for your help Paul) and i wanted to add a couple of more things.

1. I want to turn the whole thing into a block with the block name coming from the user input that created it in the first place ie "Enter Radius of elbow" -12 "Enter size Pipe"-4 then blk name 4p12 or 4-12 or something like that.

2. i want to prompt the user for rotation around insertion point. I think i can get this maby if i can figure out how to make it a block then just ill just do (command "rotate" p "" d1 pickpoint)? right or something close?

(defun c:elb()
(setq d1 (getpoint "\n Pick point start of elbow:"))
(setq d2 (getdist "\n Enter Radius of elbow:"))
(setq d4 (getdist "\n Enter size Pipe:"))
(setq os (/ d4 2))
(setq p1 (polar d1 0 os))
(setq p2 (polar d1 pi os))
(setq bp1(polar p1 (* pi 0.5)(* d4 2)))
(setq bp2(polar p2 (* pi 0.5)(* d4 2)))
(setq cp (polar bp2 0 (+ d2 os)))
(setq tp1 (polar cp (* pi 0.5)(- d2 os)))
(setq tp2 (polar tp1 (* pi 0.5)d4))
(setq p3 (polar tp1 0 (* d4 2)))
(setq p4 (polar tp2 0 (* d4 2)))

(command "arc" "ce" cp tp1 bp1)
(command "arc" "ce" cp tp2 bp2)
(command "pline" bp2 p2 p1 bp1 "")
(command "pline" tp2 p4 p3 tp1 "")
(princ)
)

Adesu
20th Oct 2005, 10:15 am
Hi J-LYLE,how about this,it's you mean?



(defun c:elb(/ d1 d2 d4 os p1 p2 bp1 bp2 cp tp1 tp2 p3 p4
es1 es2 es3 es4 nam)
(setq d1 (getpoint "\n Pick point start of elbow:"))
(setq d2 (getdist "\n Enter Radius of elbow:"))
(setq d4 (getdist "\n Enter size Pipe:"))
(setq os (/ d4 2))
(setq p1 (polar d1 0 os))
(setq p2 (polar d1 pi os))
(setq bp1 (polar p1 (* pi 0.5)(* d4 2)))
(setq bp2 (polar p2 (* pi 0.5)(* d4 2)))
(setq cp (polar bp2 0 (+ d2 os)))
(setq tp1 (polar cp (* pi 0.5)(- d2 os)))
(setq tp2 (polar tp1 (* pi 0.5)d4))
(setq p3 (polar tp1 0 (* d4 2)))
(setq p4 (polar tp2 0 (* d4 2)))
(command "arc" "ce" cp tp1 bp1)
(setq es1 (entlast))
(command "arc" "ce" cp tp2 bp2)
(setq es2 (entlast))
(command "pline" bp2 p2 p1 bp1 "")
(setq es3 (entlast))
(command "pline" tp2 p4 p3 tp1 "")
(setq es4 (entlast))
(command "_pedit" es1 "y" "j" es1 es2 es3 es4 "" "")
(setq es5 (entlast))
(setq ang (getreal "\nEnter angle: "))
(command "_rotate" es5 "" d1 ang "")
(setq nam (strcat (rtos d2 2 0) "p" (rtos d4 2 0)))
(command "wblock" nam "" d1 es5 "" "erase" es5 "")
(princ)
)

J-LYLE
20th Oct 2005, 10:59 pm
wow hay this was a wile back. :D

im looking for i did with that lisp i cant seem to find it ive changed jobs since then. when i find it ill post it. i finished it with some help from the cadtutor forumn. :D