View Full Version : RADIUS ELBOW (HVAC DUCTWORK LSP)
CAD Brad
2008-07-09, 06:15 PM
Does anyone have a lisp routine they are willing to share that fillets two sets of 90 degree lines so that a radius is made? See attached image. X is the variable and it would be the width of the lines and also the radius of the inside arc. The outside arc would be 2x the inner radius. It would also need to insert lines from the endpoints of the arcs. What I would like the routine to do is have the user select the inside corner of the duct, then the outside corner and have it fillet the lines automatically. We have always done this process manually and there has to be lsp routines out there that do such a basic thing. Any help is greatly appreciated.
In all fairness I should post a lisp routine for you all. It's simple but very cool. 2 keystrokes to change from tilemode 1 to 0 or vis versa. T Enter
(defun c:t ()
(setvar "tilemode" (- 1 (getvar "tilemode")))
(princ))
BoKirra
2008-07-10, 05:43 AM
Hi,
I used to work with HVAC industry for years.
What I understood was that you probably also need some thing for duct riser/dropper, duct transition, insulation, pipework, diffusser, etc.
You'd be better off if you have had an add-on package rather than a single function routine.
As I known so far, draPro is the one you're after. You may also need to do a search on the net.
Cheers.
Does anyone have a lisp routine they are willing to share that fillets two sets of 90 degree lines so that a radius is made? See attached image. X is the variable and it would be the width of the lines and also the radius of the inside arc. The outside arc would be 2x the inner radius. It would also need to insert lines from the endpoints of the arcs. What I would like the routine to do is have the user select the inside corner of the duct, then the outside corner and have it fillet the lines automatically. We have always done this process manually and there has to be lsp routines out there that do such a basic thing. Any help is greatly appreciated.
In all fairness I should post a lisp routine for you all. It's simple but very cool. 2 keystrokes to change from tilemode 1 to 0 or vis versa. T Enter
(defun c:t ()
(setvar "tilemode" (- 1 (getvar "tilemode")))
(princ))
tgambill
2008-07-11, 06:18 PM
Does anyone have a lisp routine they are willing to share that fillets two sets of 90 degree lines so that a radius is made? See attached image. X is the variable and it would be the width of the lines and also the radius of the inside arc. The outside arc would be 2x the inner radius. It would also need to insert lines from the endpoints of the arcs. What I would like the routine to do is have the user select the inside corner of the duct, then the outside corner and have it fillet the lines automatically. We have always done this process manually and there has to be lsp routines out there that do such a basic thing. Any help is greatly appreciated.
In all fairness I should post a lisp routine for you all. It's simple but very cool. 2 keystrokes to change from tilemode 1 to 0 or vis versa. T Enter
(defun c:t ()
(setvar "tilemode" (- 1 (getvar "tilemode")))
(princ))
I had one that I wrote years ago. I'll insert the code and you can go from there.
ELBOW.LSP
;*****************************************************************************
;*
;* ELBOW.LSP - Draws 90° Elbow using current layer.
;* T M Gambill 2/1/99
;*****************************************************************************
;
(defun 90elbow()
(setq dcl_id (load_dialog "elbow.dcl"))
(if (not (new_dialog "elbow" dcl_id))
(exit)
)
(if (not L1-DIM) (setq L1-DIM "6"))
(if (not L2-DIM) (setq L2-DIM "6"))
(if (not W1-DIM) (setq W1-DIM "12"))
(if (not W2-DIM) (setq W2-DIM "12"))
(set_tile "L1_DIM" L1-DIM)
(set_tile "L1_DIM_SLD" L1-DIM)
(set_tile "L2_DIM" L2-DIM)
(set_tile "L2_DIM_SLD" L2-DIM)
(set_tile "W1_DIM" W1-DIM)
(set_tile "W1_DIM_SLD" W1-DIM)
(set_tile "W2_DIM" W2-DIM)
(set_tile "W2_DIM_SLD" W2-DIM)
(action_tile "L1_DIM_SLD" "(up_l1_dim_box)")
(action_tile "L2_DIM_SLD" "(up_l2_dim_box)")
(action_tile "L1_DIM" "(up_l1_dim_sld)")
(action_tile "L2_DIM" "(up_l2_dim_sld)")
(action_tile "W1_DIM_SLD" "(up_w1_dim_box)")
(action_tile "W2_DIM_SLD" "(up_w2_dim_box)")
(action_tile "W1_DIM" "(up_w1_dim_sld)")
(action_tile "W2_DIM" "(up_w2_dim_sld)")
(action_tile "cancel" "(done_dialog)(setq gperr \"\")(exit)")
(action_tile "accept"
"(90get_data)(done_dialog)"
)
(start_dialog)
(unload_dialog dcl_id)
)
(defun up_l1_dim_box()
(setq L1-DIM (get_tile "L1_DIM_SLD"))
(set_tile "L1_DIM" L1-DIM)
)
(defun up_l2_dim_box()
(setq L2-DIM (get_tile "L2_DIM_SLD"))
(set_tile "L2_DIM" L2-DIM)
)
(defun up_l1_dim_sld()
(setq L1-DIM (get_tile "L1_DIM"))
(set_tile "L1_DIM_SLD" L1-DIM)
)
(defun up_l2_dim_sld()
(setq L2-DIM (get_tile "L2_DIM"))
(set_tile "L2_DIM_SLD" L2-DIM)
)
(defun up_w1_dim_box()
(setq W1-DIM (get_tile "W1_DIM_SLD"))
(set_tile "W1_DIM" W1-DIM)
)
(defun up_W2_dim_box()
(setq W2-DIM (get_tile "W2_DIM_SLD"))
(set_tile "W2_DIM" W2-DIM)
)
(defun up_w1_dim_sld()
(setq W1-DIM (get_tile "W1_DIM"))
(set_tile "W1_DIM_SLD" W1-DIM)
)
(defun up_w2_dim_sld()
(setq W2-DIM (get_tile "W2_DIM"))
(set_tile "W2_DIM_SLD" W2-DIM)
)
(defun 90get_data()
; input data
(setq L1 (atof (get_tile "L1_DIM")))
(setq L2 (atof (get_tile "L2_DIM")))
(setq W1 (atof (get_tile "W1_DIM")))
(setq W2 (atof (get_tile "W2_DIM")))
(setq W3 (+ L1 W2))
)
(defun 90draw_elbow()
(setvar "OSMODE" 2)
(setq p0 (getpoint "\nPick Insertion Point: "))
(setq ang0 (getangle p0 "\nPick Insertion Angle: "))
(setq ang1 (getangle p0 "\nPick Turn Direction: "))
(setvar "OSMODE" 0)
(setq ang2 (+ ang1 pi)
W1H (/ W1 2)
W2H (/ W2 2)
)
; calc point locations
(setq p1 (polar p0 ang1 W1H)
p2 (polar p0 ang2 W1H)
p3 (polar p1 ang0 L1)
p4 (polar p2 ang0 (+ L1 W2))
p5 (polar p3 ang1 L2)
p6 (polar p5 ang0 W2)
)
; draw Elbow
(command "LINE" p1 p2 p4 p6 p5 p3 p1 "")
(setq ccolor (getvar "CECOLOR"))
(setvar "CECOLOR" "8")
(command "LINE" p3 p4 "")
(setvar "CECOLOR" ccolor)
(setq W1-DIM W2-DIM)
)
(defun C:elbow ( / ltsave bpsave p0 p1 p2 p3 p4 p5 p6)
(setvar "CMDECHO" 0)
(setq ltsave (getvar "CELTYPE"))
(setq snapmode (getvar "OSMODE"))
(setq bpsave (getvar "BLIPMODE"))
(setvar "BLIPMODE" 0)
(90elbow)
(90draw_elbow)
(setvar "BLIPMODE" bpsave)
(setvar "OSMODE" snapmode)
(princ)
)
ELBOW.DCL
// child for Duct Elbow
elbow : dialog{
label = "Duct 90° Elbow";
:boxed_column {
label = " Elbow Properties";
:edit_box {
label = "Leg-1 Length:";
key = "L1_DIM";
edit_width = 6;
}
:slider {
key = "L1_DIM_SLD";
edit_width = 6;
min_value = 0;
max_value = 12;
small_increment = 2;
big_increment = 6;
}
:edit_box {
label = "Leg-2 Length:";
key = "L2_DIM";
edit_width = 6;
}
:slider {
key = "L2_DIM_SLD";
edit_width = 6;
min_value = 0;
max_value = 12;
small_increment = 2;
big_increment = 6;
}
:edit_box {
label = "Width 1:";
key = "W1_DIM";
edit_width = 6;
}
:slider {
key = "W1_DIM_SLD";
edit_width = 6;
min_value = 0;
max_value = 96;
small_increment = 2;
big_increment = 6;
}
:edit_box {
label = "Width 2:";
key = "W2_DIM";
edit_width = 6;
}
:slider {
key = "W2_DIM_SLD";
edit_width = 6;
min_value = 0;
max_value = 96;
small_increment = 2;
big_increment = 6;
}
}
ok_cancel;
}
A dynamic block could also be an option (draw an elbow at 1 units and use the scale action, could add a flip action as well).
CAD Brad
2008-08-01, 06:13 PM
BoKirrra, I did a little searching through google for "radius elbow lsp" and funny thing is, this post comes up as the #1 hit. I need to do some more searching to see if it is out there. Tgambill, what I am looking for is a round radius elbow. Your lisp routine works great for square elbows. OCD, a dynamic block would be good but it is a lot of clicking.
I guess to be more specific (see images) I would like to do this in 3 mouse clicks. 1) Click the button to start the lsp. 2) Pick the inside corner of the lines. 3) Pick the outside corner of the lines. Then the lsp routine would automatically trim all the lines and do the arcs and insert the lines.
This will get you started I hope
Works good for me in A2008eng
;; elb.lsp
;; load ActiveX dll
(vl-load-com)
;; local defun
;; get value by key
(defun dxf (key alist)
(cdr (assoc key alist))
)
;;================================ main programm ================================;;
(defun C:ELB (/ aep1 aep2 arc1 arc2 asp1 asp2 el1 el2 el3 el4 ep1 ep2 ep3
ep4 frad ip1 ip2 ln1 ln2 ln3 ln4 osm p1 p2 sp1 sp2 sp3 sp4 ss1 ss2 wid)
(setq osm (getvar "osmode"))
(setvar "osmode" 32)
(setq frad (getvar "filletrad"))
(setvar "cmdecho" 0)
(setq p1 (getpoint "\nPick intersection point of inner lines: "))
(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)
ip1 (inters sp1 ep1 sp2 ep2 nil)
)
(setq p2 (getpoint "\nPick intersection point of outer lines: "))
(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)
ip2 (inters sp3 ep3 sp4 ep4 nil)
)
(setq wid (* (distance ip1 ip2) (cos (/ pi 4))))
(setvar "filletrad" wid)
(command "fillet" ln1 ln2 "")
(setq arc1 (entlast))
(setq asp1 (vlax-curve-getstartpoint arc1)
aep1 (vlax-curve-getendpoint arc1)
)
(setvar "filletrad" (* wid 2.))
(command "fillet" ln3 ln4 "")
(setq arc2 (entlast))
(setq asp2 (vlax-curve-getstartpoint arc2)
aep2 (vlax-curve-getendpoint arc2)
)
(if (< (distance asp1 asp2) (distance asp1 aep2))
(progn
(command "line" "_non" asp1 "_non" asp2 "")
(command "line" "_non" aep1 "_non" aep2 "")
)
(progn
(command "line" "_non" asp1 "_non" aep2 "")
(command "line" "_non" aep1 "_non" asp2 "")
)
)
(setvar "cmdecho" 1)
(setvar "osmode" osm)
(setvar "filletrad" frad)
(princ)
)
(princ "\nStart command with ELB")
(princ)
~'J'~
BoKirra
2008-08-04, 03:02 AM
BoKirrra, I did a little searching through google for "radius elbow lsp" and funny thing is, this post comes up as the #1 hit. I need to do some more searching to see if it is out there.
I found the following for you:
1) http://www.hvacware.net
2) http://www.drapro.com
Obviously, it's all about the money.
If you're after a simple result, fixo's code may do for you.
BTW, his code can only be applied to LINEs, not PLINEs.
Hope it gives you a little help.
Cheers!
CAD Brad
2008-08-05, 12:29 AM
Thanks for the LSP fixo. That's exactly what I need.
You're welcome
Cheers :)
~'J'~
ReachAndre
2008-08-08, 04:56 PM
we use a block with scaling in the lisp.
This was set up with no error checking and may be a bit crude but it works.
Another benefit is that you have the option to use a 1.0 or a 1.5 radius elbo.
(defun c:r90 () (radius90))
(defun ductr901 (/ inspt currlay odctsize)
(command "undo" "begin")
(if
(not dctsize) (setq dctsize 12)
)
(setq odctsize dctsize)
(setq inspt (getpoint "\pick inside corner of duct for insertion: " ))
(princ "\inspt accepted")
(if
(= (setq dctsize (getdist (strcat "\nenter duct size<" (rtos odctsize 2 0) ">: ") inspt)) nil)
(setq dctsize odctsize)
)
(princ (strcat "Duxt Size = " (rtos dctsize 2 0)))
(setq currlay (getvar "Clayer"))
(princ "\currlay accepted")
(command "_ai_molc" inspt)
(command "insert" "T:/AEI CAD/Mechanical/Symbols/EL902" "s" dctsize inspt 0)
(command "move" (entlast) "" (list 0 0) (list (* -0.5 dctsize) 0))
(princ (strcat "Duct Size = " (rtos dctsize 2 0)))
(command "rotate" (entlast) "" inspt pause)
(setvar "CLayer" currlay)
(command "undo" "end")
(princ))
(defun radius90 (/ 91o915)
(if (=
(setq roinspt (getpoint "\pick inside corner for 1.5 radius elbo <use 1.0 radius elbo>: " ))
nil)
(setq 91o915 "91"))
(if (= 91o915 "91") (ductr901))
(if (/= 91o915 "91") (ductr9015))
(if (/= 91o915 "91") (setq 91o915 "90"))
(princ))
(defun ductr9015 (/ inspt currlay odctsize)
(setq inspt roinspt)
(command "undo" "begin")
(if
(not dctsize) (setq dctsize 12)
)
(setq odctsize dctsize)
;(setq inspt (getpoint "\pick inside corner of duct for insertion: " ))
;(princ "\inspt accepted")
(if
(= (setq dctsize (getdist (strcat "\nenter duct size<" (rtos odctsize 2 0) ">: ") inspt)) nil)
(setq dctsize odctsize)
)
(princ (strcat "Duxt Size = " (rtos dctsize 2 0)))
(setq currlay (getvar "Clayer"))
(princ "\currlay accepted")
(command "_ai_molc" inspt)
(command "insert" "T:/AEI CAD/Mechanical/Symbols/EL901" "s" dctsize inspt 0)
(command "move" (entlast) "" (list 0 0) (list (* -1 dctsize) 0))
(princ (strcat "Duct Size = " (rtos dctsize 2 0)))
(command "rotate" (entlast) "" inspt pause)
(setvar "CLayer" currlay)
(command "undo" "end")
(princ))
BoKirra
2008-08-11, 12:39 AM
In fact, we often use different radius ratio elbow in certain circumstances.
What if I want to draw a 2.0 or 3.0 radius elbow?
Cheers!
we use a block with scaling in the lisp.
...
Another benefit is that you have the option to use a 1.0 or a 1.5 radius elbo.
code...
ReachAndre
2008-08-11, 04:09 AM
because it is rare that we use any radius that is not 1.0 or 1.5, I never created a lsp to do that, if you frequently use a radius of 2.0 or 3.0, programming another option in the function would not be difficult to add more radius options. That is of course you would have to build a library of elbos.
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.