View Full Version : Round duct up lisp
CAD Brad
2009-04-02, 03:47 PM
I was wondering if anyone had a lisp routine they are willing to share where the end user types in the diameter of a circle and it draws what you see in the attached image. The hatch on the one side of the block isn’t necessary but would be nice to have.
Brad
mweaver
2009-04-02, 11:00 PM
Try this. It asks you to select the circle rather than enter the diameter.
(defun c:psect ( ;DRAW PIPE SECTION SYMBOL
/ test ent elist etype radius center clayer ccolor
osmode cmdecho)
(setq test T)
(while test
(princ "\nCircle for pipe section: ")
(setq
ent (entsel)
)
(cond
(ent
(setq
elist (entget (car ent))
etype (cdr (assoc 0 elist))
) ;end setq
(cond
((= "CIRCLE" etype)
(setq
radius (cdr (assoc 40 elist))
center (trans (cdr (assoc 10 elist)) (car ent) 1)
cmdecho (getvar "cmdecho")
osmode (getvar "osmode")
)
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(command "pline"
(polar center (/ pi 2.0) radius)
"arc"
"dir"
(rtd pi)
)
(command center (polar center (dtr 270) radius) "close")
(setq
clayer (getvar "clayer")
ccolor (getvar "ccolor")
)
;(command "layer" "M" "hatch" "")
;(command "color" "2")
(command "hatch"
"u"
"90"
(* 0.01 (/ (getvar "cannoscalevalue")))
"N"
(entlast)
""
)
;(command "layer" "s" clayer "")
(command "color" ccolor)
(setvar "cmdecho" cmdecho)
(setvar "osmode" osmode)
) ;end cond was circle
(T (setq test nil)) ;entity wasn't a circle
) ;end cond what was entity type
) ;end cond entity selected
(T (setq test nil)) ;no entity found
) ;end cond entity selected?
) ;end while entity selected
)
andrea.andreetti
2009-04-06, 04:37 AM
I was wondering if anyone had a lisp routine they are willing to share where the end user types in the diameter of a circle and it draws what you see in the attached image. The hatch on the one side of the block isn’t necessary but would be nice to have.
Brad
why fo not use simple block ? with diameter set to 1 ?
CAD Brad
2009-04-09, 04:57 PM
Thanks for the replies. The lisp fails for me when it hits "rtd" and "dtr".
TimSpangler
2009-04-09, 05:27 PM
Thanks for the replies. The lisp fails for me when it hits "rtd" and "dtr".
Try these
;;; ------------ SUBROUTINE TO CONVERT DEGREES TO RADIANS
(defun DTR (NumberOfDegrees)
(* pi (/ NumberOfDegrees 180.0))
)
;;; ------------ SUBROUTINE TO CONVERT RADIANS TO DEGREES
(defun RTD (NumberOfRadians)
(* 180.0 (/ NumberOfRadians pi))
)
mweaver
2009-04-10, 03:21 AM
Thanks, Tim. You beat me to it.
Mike
irneb
2009-04-24, 03:47 PM
"Slightly as per Andrea's suggestion :mrgreen:. This is a dynamic block. You may have to edit the block to modify the hatch scaling, the contained block uses horizontal lines scaled at 0.5 units.
vBulletin® v3.6.7, Copyright ©2000-2010, Jelsoft Enterprises Ltd.