View Full Version : HVAC - Turning vanes in Duct Corner (90 degrees)
CAD Brad
2008-08-12, 04:01 PM
See attached image. Does anyone have a lisp routine that draws turning vanes in the corner of the ductwork? Right now I am using a dynamic block and I would like to cut out the steps of having to stretch the vanes manually. What I would like is for the user to do it in 3 clicks. 1) Select the button to start the lisp. 2) Select the inside corner of the duct. 3) Select the outside corner of the duct. And the rest would automatically draw it in. The only requirements would be that the routine draws these lines on a specific layer and they are yellow. The other requirement is that the 2 lines not dashed are 3" offset from the inside corner of the ductwork. I've searched on augi for this lisp routine but I can't find any posts related to it. I have also googled it and again found very little info (unless I want to pay). Thanks in advance.
Brad
RobertB
2008-08-12, 05:20 PM
Why not continue to use the DBlock? You can automate the setting of the dynamic properties of the block reference given your data.
Brad,
Give this a shot
Just change the layer name on what you need
See red line inside the code
;;local defun
(defun dxf (a eList) (cdr (assoc a eList)))
;; main part
(defun c:DU (/ ang1 ang2 cec cp1 cp2 cp3 cp4 dp1 dp2 dp3 dp4
el1 el2 el3 el4 ep1 ep2 ep3 ep4 filename ln1 ln2
ln3 ln4 osm p1 p2 sp1 sp2 sp3 sp4 ss1 ss2 wid xp)
(setq osm (getvar "osmode"))
(setvar "osmode" 32)
(setq cec (getvar "cecolor"))
(setvar "cecolor" "256")
(setq cla (getvar "clayer"))
(setvar "cmdecho" 0)
(setq p1 (getpoint "\nPick the inside corner of the duct: "))
(setq ss1 (ssget "C" p1 p1 (list (cons 0 "LINE"))))
(if (/= (sslength ss1) 2)
(progn (exit) (princ)))
(setq ln1 (ssname ss1 0)
ln2 (ssname ss1 1)
el1 (entget ln1)
el2 (entget ln2)
sp1 (dxf 10 el1)
ep1 (dxf 11 el1)
sp2 (dxf 10 el2)
ep2 (dxf 11 el2)
)
(if (equal p1 sp1 0.0001)
(setq ang1 (angle sp1 ep1))
(setq ang1 (angle ep1 sp1))
)
(if (equal p1 sp2 0.0001)
(setq ang2 (angle sp2 ep2))
(setq ang2 (angle ep2 sp2))
)
(setq dp1 (polar p1 ang1 3.0)
dp2 (polar p1 ang2 3.0)
)
(setq p2 (getpoint "\nPick the outside corner of the duct: "))
(setq ss2 (ssget "C" p2 p2 (list (cons 0 "LINE"))))
(if (/= (sslength ss2) 2)
(progn (exit) (princ)))
(setq ln3 (ssname ss2 0)
ln4 (ssname ss2 1)
el3 (entget ln3)
el4 (entget ln4)
sp3 (dxf 10 el3)
ep3 (dxf 11 el3)
sp4 (dxf 10 el4)
ep4 (dxf 11 el4)
)
(setq xp (vlax-curve-getclosestpointto ln3 p1))
(setq wid (distance p1 xp))
(setq cp1 (vlax-curve-getclosestpointto ln3 dp1)
cp2 (vlax-curve-getclosestpointto ln4 dp1)
cp3 (vlax-curve-getclosestpointto ln3 dp2)
cp4 (vlax-curve-getclosestpointto ln4 dp2)
)
(if (< (distance cp1 dp1)(distance cp2 dp1))
(setq dp3 cp1)
(setq dp3 cp2)
)
(if (< (distance cp3 dp2)(distance cp4 dp2))
(setq dp4 cp3)
(setq dp4 cp4)
)
(setvar "clayer" "ELBOW");<== change the layer for ducts to suit
(command "line" "_non" dp1 "_non" dp3 "")
(command "line" "_non" dp2 "_non" dp4 "")
(if (not (tblsearch "ltype" "dashed"))
(progn
(if (zerop (getvar "measurement"))
(setq filename "acad.lin")
(setq filename "acadiso.lin"))
(command "-linetype" "load" "dashed" filename "")
)
)
(command "line" "_non" p1 "_non" p2 "")
(command "chprop" "L" "" "LT" "DASHED" "S" "30" "")
(setvar "cmdecho" 1)
(setvar "clayer" cla)
(setvar "cecolor" cec)
(setvar "osmode" osm)
(princ)
)
(princ "\nLisp loaded. Start command with DU")
(princ)
~'J'~
RobertB
2008-08-12, 06:16 PM
Fixo,
Brad isn't going to get to far without:
(defun dxf (a eList) (cdr (assoc a eList)))
Fixo,
Brad isn't going to get to far without:
(defun dxf (a eList) (cdr (assoc a eList)))
Yes, you're right, it's my bad
Thank you
I added this local function
Regards,
~'J'~
CAD Brad
2008-08-14, 09:45 PM
The amazing fixo does it again. Thanks. The lisp routine works perfectly. Thanks to you too RoberB.
Hi Brad,
Glad you got it to work
Cheers :)
~'J'~
nsalomone.student
2008-10-23, 01:08 PM
Does anyone know why I'm getting this error?
Command:
DU
Pick the inside corner of the duct: ; error: bad argument type: lselsetp nil
Command:
Thanks
ReachAndre
2008-10-30, 07:45 PM
We use a command that inserts a block depending on layer. Sorry, I am not the best with error checking but I RARELY have problems with this lisp.
(defun c:90 (/ inspt currlay odctsize curros)
(setq inspt (getpoint "\pick inside corner of duct for insertion: " ))
(princ "\inspt accepted")
(command "undo" "begin")
(if (not dctsizea) (setq dctsizea 1))
(if (not dctsizeb) (setq dctsizeb 1))
(setq odctsize dctsizea)
(setq cclayer (getvar "clayer"))
(if
(= (setq dctsizea (getdist (strcat "\nenter duct size<" (rtos odctsize 2 0) ">: ") inspt)) nil)
(setq dctsizea odctsize)
)
(if
(= (setq dctsizeb (getdist (strcat "\nenter duct size<" (rtos dctsizea 2 0) ">: ") inspt)) nil)
(setq dctsizeb dctsizea)
)
(princ (strcat "Duct Size = " (rtos dctsizea 2 0)))
(command "_ai_molc" inspt)
(setq runlay (strcase (getvar "clayer")))
(if (/= runlay "M-SUPP-DUCT")
(command "insert" "T:/CAD SUPP/Mechanical/Symbols/DYN ELR90" "x" dctsizea "y" dctsizeb "z" dctsizea inspt 0)
)
(if (= runlay "M-SUPP-DUCT")
(command "insert" "T:/CAD SUPP/Mechanical/Symbols/DYN ELRV90" "x" dctsizea "y" dctsizeb "z" dctsizea inspt 0)
)
(setvar "Clayer" cclayer)
(command "move" (entlast) "" (list 0 0) (list (* -0.070731 dctsizea) 0))
(princ (strcat "Duct Size = " (rtos dctsizea 2 0)))
(command "rotate" (entlast) "" inspt pause)
(command "undo" "end")
(princ))
Hope this works for you guys, Also, I would like to know any opinions on my method.
Thanks all,
Andre
Powered by vBulletin® Version 4.1.11 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.