mdbdesign Posted March 26, 2009 Share Posted March 26, 2009 We got large project for aluminum duct system ranging Ø from 100 to 1000 mm involving lots of elbows My question is: is there somewhere lisp that can draw side view of elbow with only user input as: duct OD, # of segments and elbow degree. Please help:) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 26, 2009 Share Posted March 26, 2009 Try this for starters: (defun c:duct (/ *error* oVars vLst dPt dOd Segs dAng vEnt i PntEve PntOdd cAngE sPtE ePtE cAngO sPtO ePtO last_pt1 last_pt2) (defun *error* (msg) (if oVars (mapcar 'setvar vLst oVars)) (princ (strcat "\nError: " (strcase msg))) (princ)) (setq vLst '("CMDECHO" "OSMODE") oVars (mapcar 'getvar vLst)) (if (and (setq dPt (getpoint "\nSelect Point for Elbow: ")) (not (initget 7)) (setq dOd (getdist "\nSpecify Duct OD: ")) (not (initget 7)) (setq Segs (getint "\nSpecify No. of Segments: ")) (setq dAng (getreal "\nSpecify Elbow Angle: ")) (< 0 dAng 360)) (progn (mapcar 'setvar vlst '(0 0)) (command "_arc" "_C" (polar dPt (/ pi 2) dOd) dPt "_A" (rtos dAng)) (setq vEnt (vlax-ename->vla-object (entlast)) i 0.0 inc (/ (vla-get-ArcLength vEnt) Segs)) (while (or (setq PntEve (vlax-curve-GetPointatDist vEnt i) PntOdd (vlax-curve-GetPointatDist vEnt (setq i (+ inc i))))) (setq cAngE (+ (/ pi 2) (angle '(0 0 0) (vlax-curve-getFirstDeriv vEnt (vlax-curve-GetParamAtPoint vEnt PntEve))))) (command "_line" (setq sPtE (polar PntEve cAngE 4.0)) (setq ePtE (polar PntEve (+ pi cAngE) 4.0)) "") (if (and last_pt1 last_pt2) (progn (command "_line" last_pt1 sPtE "") (command "_line" last_pt2 ePtE ""))) (setq cAngO (+ (/ pi 2) (angle '(0 0 0) (vlax-curve-getFirstDeriv vEnt (vlax-curve-GetParamAtPoint vEnt PntOdd))))) (command "_line" (setq sPtO (polar PntOdd cAngO 3.0)) (setq ePtO (polar PntOdd (+ pi cAngO) 3.0)) "") (command "_line" sPtE sPtO "") (command "_line" ePtE ePtO "") (setq last_pt1 sPtO last_pt2 ePtO) (setq i (+ inc i))) (vla-put-Color vEnt acblue)) (princ "\n<!> Points Specified Incorrectly <!>")) (mapcar 'setvar vLst oVars) (princ)) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 26, 2009 Share Posted March 26, 2009 My apologies, this is better: (defun c:duct (/ *error* oVars vLst dPt dOd Segs dAng vEnt i PntEve PntOdd cAngE sPtE ePtE cAngO sPtO ePtO last_pt1 last_pt2) (defun *error* (msg) (if oVars (mapcar 'setvar vLst oVars)) (princ (strcat "\nError: " (strcase msg))) (princ)) (setq vLst '("CMDECHO" "OSMODE") oVars (mapcar 'getvar vLst)) (if (and (setq dPt (getpoint "\nSelect Point for Elbow: ")) (not (initget 7)) (setq dOd (getdist "\nSpecify Duct OD: ")) (not (initget 7)) (setq Segs (getint "\nSpecify No. of Segments: ")) (setq dAng (getreal "\nSpecify Elbow Angle: ")) (< 0 dAng 360)) (progn (mapcar 'setvar vlst '(0 0)) (command "_arc" "_C" (polar dPt (/ pi 2) (* 1.5 dOd)) dPt "_A" (rtos dAng)) (setq vEnt (vlax-ename->vla-object (entlast)) i 0.0 inc (/ (vla-get-ArcLength vEnt) Segs)) (while (setq PntEve (vlax-curve-GetPointatDist vEnt i)) (setq cAngE (+ (/ pi 2) (angle '(0 0 0) (vlax-curve-getFirstDeriv vEnt (vlax-curve-GetParamAtPoint vEnt PntEve))))) (command "_line" (setq sPtE (polar PntEve cAngE (/ (+ dOd (* inc 2.0)) 2.0))) (setq ePtE (polar PntEve (+ pi cAngE) (/ (+ dOd (* inc 2.0)) 2.0))) "") (if (and last_pt1 last_pt2) (progn (command "_line" last_pt1 sPtE "") (command "_line" last_pt2 ePtE ""))) (if (setq PntOdd (vlax-curve-GetPointatDist vEnt (setq i (+ inc i)))) (progn (setq cAngO (+ (/ pi 2) (angle '(0 0 0) (vlax-curve-getFirstDeriv vEnt (vlax-curve-GetParamAtPoint vEnt PntOdd))))) (command "_line" (setq sPtO (polar PntOdd cAngO (/ dOd 2.0))) (setq ePtO (polar PntOdd (+ pi cAngO) (/ dOd 2.0))) "") (command "_line" sPtE sPtO "") (command "_line" ePtE ePtO "") (setq last_pt1 sPtO last_pt2 ePtO i (+ inc i))))) (vla-put-Color vEnt acblue)) (princ "\n<!> Points Specified Incorrectly <!>")) (mapcar 'setvar vLst oVars) (princ)) Quote Link to comment Share on other sites More sharing options...
mdbdesign Posted March 26, 2009 Author Share Posted March 26, 2009 Lee, it got any restriction about Autocad version for this rutine? See dwg. elbow.dwg Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 26, 2009 Share Posted March 26, 2009 Not restrictions, I just thought you wanted ducting like this: Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 26, 2009 Share Posted March 26, 2009 Ok, I've given you an "adjustment menu" at the top of the LISP, play around with it til your hearts content (defun c:duct (/ *error* oVars vLst dPt dOd Segs dAng vEnt i PntEve PntOdd cAngE sPtE ePtE cAngO sPtO ePtO last_pt1 last_pt2 Cent str) ;; ==== Adjustments ==== (setq Cent T) ; Duct Centreline (setq str T) ; Straight/Corrugated Duct (T = Straight, nil = Corrugated) ;; ===================== (defun *error* (msg) (if oVars (mapcar 'setvar vLst oVars)) (princ (strcat "\nError: " (strcase msg))) (princ)) (setq vLst '("CMDECHO" "OSMODE") oVars (mapcar 'getvar vLst)) (if (and (setq dPt (getpoint "\nSelect Point for Elbow: ")) (not (initget 7)) (setq dOd (getdist "\nSpecify Duct OD: ")) (not (initget 7)) (setq Segs (getint "\nSpecify No. of Segments: ")) (setq dAng (getreal "\nSpecify Elbow Angle: ")) (< 0 dAng 360)) (progn (mapcar 'setvar vlst '(0 0)) (or (and str (setq j 0.0)) (setq j 1.0)) (command "_arc" "_C" (polar dPt (/ pi 2) (* 1.5 dOd)) dPt "_A" (rtos dAng)) (setq vEnt (vlax-ename->vla-object (entlast)) i 0.0 inc (/ (vla-get-ArcLength vEnt) Segs)) (while (setq PntEve (vlax-curve-GetPointatDist vEnt i)) (setq cAngE (+ (/ pi 2) (angle '(0 0 0) (vlax-curve-getFirstDeriv vEnt (vlax-curve-GetParamAtPoint vEnt PntEve))))) (command "_line" (setq sPtE (polar PntEve cAngE (/ (+ dOd (* j inc 2.0)) 2.0))) (setq ePtE (polar PntEve (+ pi cAngE) (/ (+ dOd (* j inc 2.0)) 2.0))) "") (if (and last_pt1 last_pt2) (progn (command "_line" last_pt1 sPtE "") (command "_line" last_pt2 ePtE ""))) (if (setq PntOdd (vlax-curve-GetPointatDist vEnt (setq i (+ inc i)))) (progn (setq cAngO (+ (/ pi 2) (angle '(0 0 0) (vlax-curve-getFirstDeriv vEnt (vlax-curve-GetParamAtPoint vEnt PntOdd))))) (command "_line" (setq sPtO (polar PntOdd cAngO (/ dOd 2.0))) (setq ePtO (polar PntOdd (+ pi cAngO) (/ dOd 2.0))) "") (command "_line" sPtE sPtO "") (command "_line" ePtE ePtO "") (setq last_pt1 sPtO last_pt2 ePtO i (+ inc i))))) (if Cent (vla-put-Color vEnt acblue) (vla-delete vEnt))) (princ "\n<!> Points Specified Incorrectly <!>")) (mapcar 'setvar vLst oVars) (princ)) Quote Link to comment Share on other sites More sharing options...
mdbdesign Posted March 26, 2009 Author Share Posted March 26, 2009 Will try at home. Big thanks Lee Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 26, 2009 Share Posted March 26, 2009 Will try at home. Big thanks Lee No probs, I had fun working on it Quote Link to comment Share on other sites More sharing options...
mdbdesign Posted March 27, 2009 Author Share Posted March 27, 2009 Perfect. Lee, I will explain... on attached dwg ELBOW.dwg Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 27, 2009 Share Posted March 27, 2009 Ok, will have a look when I get home Quote Link to comment Share on other sites More sharing options...
mdbdesign Posted March 27, 2009 Author Share Posted March 27, 2009 Lee, Cadtutor will be temporary shutdown on weekend so you have lots of time. Don't rush, is weekend: have fun! Quote Link to comment Share on other sites More sharing options...
fixo Posted March 27, 2009 Share Posted March 27, 2009 Hi M! Here is a simple parametric lisp change to your suit O DU.LSP Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 27, 2009 Share Posted March 27, 2009 Lee, Cadtutor will be temporary shutdown on weekend so you have lots of time. Don't rush, is weekend: have fun! Cheers, will see what I can do for you Quote Link to comment Share on other sites More sharing options...
mdbdesign Posted March 27, 2009 Author Share Posted March 27, 2009 Thanks Oleg, now I will got time to go on Cadtutor instead of loosing time for drawing. I am so happy now. Will buy bottle today and wait when you coming visit me. You too Lee (drinking limit in Canada is 19 years of age) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 27, 2009 Share Posted March 27, 2009 Thanks Oleg, now I will got time to go on Cadtutor instead of loosing time for drawing. I am so happy now. Will buy bottle today and wait when you coming visit me.You too Lee (drinking limit in Canada is 19 years of age) Many thanks - seems that Fixo hit the nail on the head Have a good weekend Lee Quote Link to comment Share on other sites More sharing options...
rbeldua Posted April 8, 2009 Share Posted April 8, 2009 hi guys....am new here, just a thought... will it be possible to have a lisp like the elbow flex duct except it goes straight and makes elbow too, like the duct lisp and wpipe...it will be great if i could have one lisp like that... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 8, 2009 Share Posted April 8, 2009 I made this a while back, not sure if it helps or not (defun c:duct (/ *error* oVars vLst p1 p2 vEnt i PntEve PntOdd cAngE sPtE ePtE cAngO sPtO ePtO last_pt1 last_pt2) (defun *error* (msg) (if oVars (mapcar 'setvar vLst oVars)) (princ (strcat "\nError: " (strcase msg))) (princ)) (setq vLst '("CMDECHO" "CLAYER" "FILLMODE" "OSMODE" "PLINEWID") oVars (mapcar 'getvar vLst)) (setvar "CMDECHO" 0) (setvar "FILLMODE" 0) (if (not (tblsearch "LAYER" "DUCT")) (command "-layer" "M" "DUCT" "_C" "1" "DUCT" "") (setvar "CLAYER" "DUCT")) (vl-load-com) (if (and (setq p1 (getpoint "\nSpecify First Point: ") p2 (getpoint p1 "\nIndicate Direction of Duct: "))) (progn (setvar "PLINEWID" 6) (setvar "OSMODE" 0) (command "_pline" p1 (polar p1 (angle p1 p2) 2.0) "_arc") (while (> (getvar "CMDACTIVE") 0) (command pause)) (setq vEnt (vlax-ename->vla-object (entlast)) i 2.0) (while (and (setq PntEve (vlax-curve-GetPointatDist vEnt i) PntOdd (vlax-curve-GetPointatDist vEnt (setq i (1+ i))))) (setq cAngE (+ (/ pi 2) (angle '(0 0 0) (vlax-curve-getFirstDeriv vEnt (vlax-curve-GetParamAtPoint vEnt PntEve))))) (command "_line" (setq sPtE (polar PntEve cAngE 4.0)) (setq ePtE (polar PntEve (+ pi cAngE) 4.0)) "") (if (and last_pt1 last_pt2) (progn (command "_line" last_pt1 sPtE "") (command "_line" last_pt2 ePtE ""))) (setq cAngO (+ (/ pi 2) (angle '(0 0 0) (vlax-curve-getFirstDeriv vEnt (vlax-curve-GetParamAtPoint vEnt PntOdd))))) (command "_line" (setq sPtO (polar PntOdd cAngO 3.0)) (setq ePtO (polar PntOdd (+ pi cAngO) 3.0)) "") (command "_line" sPtE sPtO "") (command "_line" ePtE ePtO "") (setq last_pt1 sPtO last_pt2 ePtO) (setq i (1+ i))) (vla-put-ConstantWidth vEnt 0.0) (vla-put-Color vEnt acblue)) (princ "\n<!> Points Specified Incorrectly <!>")) (mapcar 'setvar vLst oVars) (princ)) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 8, 2009 Share Posted April 8, 2009 Or there's this offering from CAB Flex 17 CAB.LSP Quote Link to comment Share on other sites More sharing options...
tzframpton Posted April 8, 2009 Share Posted April 8, 2009 Someone over at the swamp has an entire HVAC Lisp program suite, actually. I think CAB has like 3 or 4 different flex LISP. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 8, 2009 Share Posted April 8, 2009 I think TimSpangler has also got a whole suite - posted somewhere on here. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.