Jump to content
FordForever5305913

How do I bend a 3d cylinder

Recommended Posts

FordForever5305913

i am trying to make a exaust pipe for a semi i am making in autocad 2006 and the pipe bends at the top. so i was wondering how can i bend a 3d cylinder/pipe?

 

Thanks

Share this post


Link to post
Share on other sites
ReMark

Draw the centerline of the exhaust pipe, using a polyline, then draw and extrude a circle along this "path" corresponding to the O.D. of the pipe.

Share this post


Link to post
Share on other sites
Spageddie

be sure to use a polyline with radiused corners for the bends...

Share this post


Link to post
Share on other sites
seanevans00

Hi,

 

I am a bit of a novice when it comes to design but I can make way around AutoCAD 2006. How did you go about creating your exhaust pipe based on poly line?

 

Regards

 

Sean

Share this post


Link to post
Share on other sites
ASMI

Try this two LISPs.

 

(defun c:xpipe(/ ACTDOC ACTLAY ACTSP BASELINE 
         BASESET CIRENT DICOUNT DIVDID 
         EXCIR LAYST OBJTYPE OLDDIA 
         OLDECHO STARTPT XORD YORD 
         ZORD *ERROR*) 
 (vl-load-com) 

 (defun *error* (msg) 
   (vla-put-Lock actLay laySt) 
   (setvar "CMDECHO" oldEcho) 
   (vla-EndUndoMark actDoc) 
   (princ) 
   ); end of *error* 

 (if(not pipe:exDia)(setq pipe:exDia 40.0)) 
 (setq actDoc 
   (vla-get-ActiveDocument 
     (vlax-get-Acad-object)) 
  actLay(vla-get-ActiveLayer actDoc) 
       oldDia pipe:exDia 
       oldEcho(getvar "CMDECHO") 
  ); end setq 
 (vla-StartUndoMark actDoc) 
 (setvar "CMDECHO" 0) 
 (if(= 0(vla-get-ActiveSpace actDoc)) 
   (setq actSp(vla-get-PaperSpace actDoc)) 
   (setq actSp(vla-get-ModelSpace actDoc)) 
   ); end if 
 (setq laySt(vla-get-Lock actLay)) 
 (vla-put-Lock actLay :vlax-false) 
 (setq pipe:exDia 
   (getreal 
     (strcat 
       "\nSpecify pipe diameter <"(rtos pipe:exDia)">: "))) 
 (if(null pipe:exDia)(setq pipe:exDia oldDia))
 (initget "Yes No") 
  (setq delFlag 
         (getkword "\nDelete extrude path(s)? [Yes/No] <No>: ")) 
   (if(null delFlag)(setq delFlag "No")) 
 (princ "\n<<< Select objects to extrude and press Enter >>>") 
 (if 
   (setq baseSet 
     (ssget '((-4 . "<OR")(0 . "*LINE")(0 . "CIRCLE") 
          (0 . "ARC")(0 . "ELLIPSE")(-4 . "OR>") 
          (-4 . "<NOT")(-4 . "<OR")(0 . "SPLINE") 
               (0 . "MLINE")(-4 . "OR>")(-4 . "NOT>")))) 
   (progn 
     (setq baseSet(vl-remove-if 'listp 
                             (mapcar 
           'cadr 
           (ssnamex baseSet)))) 
     (foreach pathEnt baseSet 
     (setq baseLine 
       (vlax-ename->vla-object pathEnt) 
      objType(vla-get-ObjectName baseLine) 
           startPt(vlax-curve-getStartPoint baseLine) 
           3dPos 
       (vlax-curve-getFirstDeriv baseLine 
         (vlax-curve-getParamAtPoint baseLine startPt)) 
          diCount(strlen 
           (itoa 
        (apply 'max 
         (mapcar 'abs 
          (mapcar 'fix startPt))))) 
      divDid "1" 
      ); end setq 
     (repeat diCount 
  (setq divDid(strcat divDid "0")) 
  ); end repeat 
     (setq divDid(atoi divDid)) 
     (if(/= 0.0(car 3dPos)) 
  (setq XOrd(/(car 3dPos)divDid)) 
  (setq XOrd (car 3dPos)) 
  ); end if 
     (if(/= 0.0(cadr 3dPos)) 
  (setq YOrd(/(cadr 3dPos)divDid)) 
  (setq YOrd (cadr 3dPos)) 
  ); end if 
     (if(/= 0.0(nth 2 3dPos)) 
  (setq ZOrd(/(nth 2 3dPos)divDid)) 
  (setq ZOrd (nth 2 3dPos)) 
  ); end if 
     (setq 3dPos(list XOrd YOrd ZOrd)) 
 (setq exCir 
   (vla-addCircle actSp 
     (vlax-3d-Point startPt) 
     (/ pipe:exDia 2))) 
 (vla-put-Normal exCir(vlax-3D-point 3dPos)) 
 (setq cirEnt(vlax-vla-object->ename exCir)) 
 (command "_.extrude" cirEnt "" "_p" pathEnt) 
 (command "_.erase" cirEnt "")
(if(= "Yes" delFlag) 
   (vla-delete baseLine) 
      ); end if 
  ); end foreach 
     (vla-put-Lock actLay laySt) 
     (setvar "CMDECHO" oldEcho) 
     (vla-EndUndoMark actDoc) 
      ); end progn 
     ); end if 
   (princ) 
   ); end  of c:xpipe







(defun c:xtube(/ 3DPOS ACTDOC ACTLAY ACTSP BASELINE 
         BASESET DICOUNT DIVDID EXCIR EXENT 
         EXTUBE INCIR INENT INTUBE LAYST 
         OBJTYPE OLDECHO oldWidth oldHeight 
         STARTPT XORD YORD ZORD DELFLAG *ERROR*) 
 (vl-load-com) 

 (defun *error* (msg) 
   (vla-put-Lock actLay laySt) 
   (setvar "CMDECHO" oldEcho) 
   (vla-EndUndoMark actDoc) 
   (princ) 
   ); end of *error* 

 (if(not tube:Width)(setq tube:Width 40.0)) 
 (if(not tube:Height)(setq tube:Height 37.0)) 
 (setq actDoc 
   (vla-get-ActiveDocument 
     (vlax-get-Acad-object)) 
  actLay(vla-get-ActiveLayer actDoc) 
       oldWidth tube:Width 
  oldHeight tube:Height 
       oldEcho(getvar "CMDECHO") 
  ); end setq 
 (vla-StartUndoMark actDoc) 
 (setvar "CMDECHO" 0) 
 (if(= 0(vla-get-ActiveSpace actDoc)) 
   (setq actSp(vla-get-PaperSpace actDoc)) 
   (setq actSp(vla-get-ModelSpace actDoc)) 
   ); end if 
 (setq laySt(vla-get-Lock actLay)) 
 (vla-put-Lock actLay :vlax-false) 
 (setq tube:Width 
   (getreal 
     (strcat 
       "\nSpecify external diameter <"(rtos tube:Width)">: ")) 
      tube:Height 
   (getreal 
     (strcat 
       "\nSpecify internal diameter <"(rtos tube:Height)">: ")) 
  ); end setq 
 (if(null tube:Height)(setq tube:Height oldHeight)) 
 (if(null tube:Width)(setq tube:Width oldWidth)) 
 (if(< tube:Height tube:Width) 
   (progn 
       (initget "Yes No") 
  (setq delFlag 
         (getkword "\nDelete extrude path(s)? [Yes/No] <No>: ")) 
   (if(null delFlag)(setq delFlag "No")) 
 (princ "\n<<< Select objects to extrude and press Enter >>>") 
 (if 
   (setq baseSet 
     (ssget '((-4 . "<OR")(0 . "*LINE")(0 . "CIRCLE") 
          (0 . "ARC")(0 . "ELLIPSE")(-4 . "OR>") 
          (-4 . "<NOT")(-4 . "<OR")(0 . "SPLINE") 
               (0 . "MLINE")(-4 . "OR>")(-4 . "NOT>")))) 
   (progn 
     (setq baseSet(vl-remove-if 'listp 
                             (mapcar 
           'cadr 
           (ssnamex baseSet)))) 
     (foreach pathEnt baseSet 
     (setq baseLine 
       (vlax-ename->vla-object pathEnt) 
      objType(vla-get-ObjectName baseLine) 
           startPt(vlax-curve-getStartPoint baseLine) 
           3dPos 
       (vlax-curve-getFirstDeriv baseLine 
         (vlax-curve-getParamAtPoint baseLine startPt)) 
          diCount(strlen 
           (itoa 
        (apply 'max 
         (mapcar 'abs 
          (mapcar 'fix startPt))))) 
      divDid "1" 
      ); end setq
   (repeat diCount 
  (setq divDid(strcat divDid "0")) 
  ); end repeat 
     (setq divDid(atoi divDid)) 
     (if(/= 0.0(car 3dPos)) 
  (setq XOrd(/(car 3dPos)divDid)) 
  (setq XOrd (car 3dPos)) 
  ); end if 
     (if(/= 0.0(cadr 3dPos)) 
  (setq YOrd(/(cadr 3dPos)divDid)) 
  (setq YOrd (cadr 3dPos)) 
  ); end if 
     (if(/= 0.0(nth 2 3dPos)) 
  (setq ZOrd(/(nth 2 3dPos)divDid)) 
  (setq ZOrd (nth 2 3dPos)) 
  ); end if 
     (setq 3dPos(list XOrd YOrd ZOrd)) 
 (setq exCir 
   (vla-addCircle actSp 
     (vlax-3d-Point startPt) 
     (/ tube:Width 2)) 
  inCir 
   (vla-addCircle actSp 
     (vlax-3d-Point startPt) 
     (/ tube:Height 2)) 
  ); end setq 
 (vla-put-Normal exCir(vlax-3D-point 3dPos)) 
 (vla-put-Normal inCir(vlax-3D-point 3dPos)) 
 (setq exEnt(vlax-vla-object->ename exCir) 
  inEnt(vlax-vla-object->ename inCir) 
  ) ; end setq 
 (command "_.extrude" exEnt "" "_p" pathEnt) 
 (setq exTube(entlast)) 
 (command "_.extrude" inEnt "" "_p" pathEnt) 
 (setq inTube(entlast)) 
 (command "_subtract" exTube "" inTube "") 
 (command "_.erase" exEnt "") 
 (command "_.erase" inEnt "") 
 (if(= "Yes" delFlag) 
   (vla-delete baseLine) 
      ); end if 
  ); end foreach 
     (vla-put-Lock actLay laySt) 
     (setvar "CMDECHO" oldEcho) 
      ); end progn 
     ); end if 
    ); end progn 
   (princ "\nInternal diameter more or equal external diameter! ") 
   ); end if 
 (vla-EndUndoMark actDoc) 
   (princ) 
   ); end  of c:xtube

Share this post


Link to post
Share on other sites
ReMark

ASMI:

 

While I'm sure the two LISP programs work beautifully it begs the question, "Isn't that a bit over-the-top?"

 

How about drawing the I.D. and O.D. in plan view, use the Region and Subtract (Solids) command, then changing the UCS and drawing the centerline of the exhaust pipe. Radius the bend at the top and then extrude the circles along the "path"? Slice the exhaust pipe at the appropriate point along the curve. Done.

 

I think your LISP programs might be more suitable to someone doing a lot of piping runs. Just an observation...not a criticism. Please point out the error of my ways should I be mistaken. I can always benefit from learning something new. Thanks.

Share this post


Link to post
Share on other sites
ASMI

>ReMark

 

I draw sprinkler systems and I should draw hundreds pipes a day. Therefore XPIPE which allow to draw many pipes per time help to me very much . XTUBE I have written simply so.

Share this post


Link to post
Share on other sites
ReMark

ASMI:

 

Thank you for that explanation. As I suspected, you need to produce a good deal of piping runs in a short period of time. Your LISP program gives you that capability. I appreciate that you shared it with us.

Share this post


Link to post
Share on other sites
sibbles

Hello

 

I got Acad to load the lsp that are posted in here, but don't know how to get them to run :oops:

 

Could you tell me what I need to draw to get the lsp to work, I drew a polyline and a circle at the end of it reprecenting the diameter i needed but all I got from both lsp was

"; error: An error has occurred inside the *error* functionbad argument type:

VLA-OBJECT nil"

 

Any help is greatly appreciated

 

Regards

Atli F.

Share this post


Link to post
Share on other sites
ASMI

>sibbles

 

You use what version AutoCAD? Can be 2000 or 2002? I unfortunately do not have such version, but try this:

 

(defun c:xpipe(/ ACTDOC ACTLAY ACTSP BASELINE
         BASESET CIRENT DICOUNT DIVDID
         EXCIR LAYST OBJTYPE OLDDIA
         OLDECHO STARTPT XORD YORD
         ZORD *ERROR*)
 (vl-load-com)

 (defun *error* (msg)
   (vla-put-Lock actLay laySt)
   (setvar "CMDECHO" oldEcho)
     (if(= 16(Asmi-AcadVersion nil))
   (vla-EndUndoMark actDoc)
   ); end if
   (princ)
   ); end of *error*

 (if(not pipe:exDia)(setq pipe:exDia 40.0))
 (setq actDoc
   (vla-get-ActiveDocument
     (vlax-get-Acad-object))
  actLay(vla-get-ActiveLayer actDoc)
       oldDia pipe:exDia
       oldEcho(getvar "CMDECHO")
  ); end setq
 (vla-StartUndoMark actDoc)
 (setvar "CMDECHO" 0)
 (if(= 0(vla-get-ActiveSpace actDoc))
   (setq actSp(vla-get-PaperSpace actDoc))
   (setq actSp(vla-get-ModelSpace actDoc))
   ); end if
 (setq laySt(vla-get-Lock actLay))
 (vla-put-Lock actLay :vlax-false)
 (setq pipe:exDia
   (getreal
     (strcat
       "\nSpecify pipe diameter <"(rtos pipe:exDia)">: ")))
 (if(null pipe:exDia)(setq pipe:exDia oldDia))
 (initget "Yes No")
  (setq delFlag
         (getkword "\nDelete extrude path(s)? [Yes/No] <No>: "))
   (if(null delFlag)(setq delFlag "No"))
 (princ "\n<<< Select objects to extrude and press Enter >>>")
 (if
   (setq baseSet
     (ssget '((-4 . "<OR")(0 . "*LINE")(0 . "CIRCLE")
          (0 . "ARC")(0 . "ELLIPSE")(-4 . "OR>")
          (-4 . "<NOT")(-4 . "<OR")(0 . "SPLINE")
               (0 . "MLINE")(-4 . "OR>")(-4 . "NOT>"))))
   (progn
     (setq baseSet(vl-remove-if 'listp
                             (mapcar
           'cadr
           (ssnamex baseSet))))
     (foreach pathEnt baseSet
     (setq baseLine
       (vlax-ename->vla-object pathEnt)
      objType(vla-get-ObjectName baseLine)
           startPt(vlax-curve-getStartPoint baseLine)
           3dPos
       (vlax-curve-getFirstDeriv baseLine
         (vlax-curve-getParamAtPoint baseLine startPt))
          diCount(strlen
           (itoa
        (apply 'max
         (mapcar 'abs
          (mapcar 'fix startPt)))))
      divDid "1"
      ); end setq
     (repeat diCount
  (setq divDid(strcat divDid "0"))
  ); end repeat
     (setq divDid(atoi divDid))
     (if(/= 0.0(car 3dPos))
  (setq XOrd(/(car 3dPos)divDid))
  (setq XOrd (car 3dPos))
  ); end if
     (if(/= 0.0(cadr 3dPos))
  (setq YOrd(/(cadr 3dPos)divDid))
  (setq YOrd (cadr 3dPos))
  ); end if
     (if(/= 0.0(nth 2 3dPos))
  (setq ZOrd(/(nth 2 3dPos)divDid))
  (setq ZOrd (nth 2 3dPos))
  ); end if
     (setq 3dPos(list XOrd YOrd ZOrd))
 (setq exCir
   (vla-addCircle actSp
     (vlax-3d-Point startPt)
     (/ pipe:exDia 2)))
 (vla-put-Normal exCir(vlax-3D-point 3dPos))
 (setq cirEnt(vlax-vla-object->ename exCir))
 (command "_.extrude" cirEnt "" "_p" pathEnt)
 (command "_.erase" cirEnt "")
(if(= "Yes" delFlag)
   (vla-delete baseLine)
      ); end if
  ); end foreach
     (vla-put-Lock actLay laySt)
     (setvar "CMDECHO" oldEcho)
       (if(= 16(Asmi-AcadVersion nil))
     (vla-EndUndoMark actDoc)
   ); end if
      ); end progn
     ); end if
   (princ)
   ); end  of c:xpipe







(defun c:xtube(/ 3DPOS ACTDOC ACTLAY ACTSP BASELINE
         BASESET DICOUNT DIVDID EXCIR EXENT
         EXTUBE INCIR INENT INTUBE LAYST
         OBJTYPE OLDECHO oldWidth oldHeight
         STARTPT XORD YORD ZORD DELFLAG *ERROR*)
 (vl-load-com)

 (defun *error* (msg)
   (vla-put-Lock actLay laySt)
   (setvar "CMDECHO" oldEcho)
     (if(= 16(Asmi-AcadVersion nil))
    (vla-EndUndoMark actDoc)
   ); end if
   (princ)
   ); end of *error*

 (if(not tube:Width)(setq tube:Width 40.0))
 (if(not tube:Height)(setq tube:Height 37.0))
 (setq actDoc
   (vla-get-ActiveDocument
     (vlax-get-Acad-object))
  actLay(vla-get-ActiveLayer actDoc)
       oldWidth tube:Width
  oldHeight tube:Height
       oldEcho(getvar "CMDECHO")
  ); end setq
 (vla-StartUndoMark actDoc)
 (setvar "CMDECHO" 0)
 (if(= 0(vla-get-ActiveSpace actDoc))
   (setq actSp(vla-get-PaperSpace actDoc))
   (setq actSp(vla-get-ModelSpace actDoc))
   ); end if
 (setq laySt(vla-get-Lock actLay))
 (vla-put-Lock actLay :vlax-false)
 (setq tube:Width
   (getreal
     (strcat
       "\nSpecify external diameter <"(rtos tube:Width)">: "))
      tube:Height
   (getreal
     (strcat
       "\nSpecify internal diameter <"(rtos tube:Height)">: "))
  ); end setq
 (if(null tube:Height)(setq tube:Height oldHeight))
 (if(null tube:Width)(setq tube:Width oldWidth))
 (if(< tube:Height tube:Width)
   (progn
       (initget "Yes No")
  (setq delFlag
         (getkword "\nDelete extrude path(s)? [Yes/No] <No>: "))
   (if(null delFlag)(setq delFlag "No"))
 (princ "\n<<< Select objects to extrude and press Enter >>>")
 (if
   (setq baseSet
     (ssget '((-4 . "<OR")(0 . "*LINE")(0 . "CIRCLE")
          (0 . "ARC")(0 . "ELLIPSE")(-4 . "OR>")
          (-4 . "<NOT")(-4 . "<OR")(0 . "SPLINE")
               (0 . "MLINE")(-4 . "OR>")(-4 . "NOT>"))))
   (progn
     (setq baseSet(vl-remove-if 'listp
                             (mapcar
           'cadr
           (ssnamex baseSet))))
     (foreach pathEnt baseSet
     (setq baseLine
       (vlax-ename->vla-object pathEnt)
      objType(vla-get-ObjectName baseLine)
           startPt(vlax-curve-getStartPoint baseLine)
           3dPos
       (vlax-curve-getFirstDeriv baseLine
         (vlax-curve-getParamAtPoint baseLine startPt))
          diCount(strlen
           (itoa
        (apply 'max
         (mapcar 'abs
          (mapcar 'fix startPt)))))
      divDid "1"
      ); end setq
  (repeat diCount
  (setq divDid(strcat divDid "0"))
  ); end repeat
     (setq divDid(atoi divDid))
     (if(/= 0.0(car 3dPos))
  (setq XOrd(/(car 3dPos)divDid))
  (setq XOrd (car 3dPos))
  ); end if
     (if(/= 0.0(cadr 3dPos))
  (setq YOrd(/(cadr 3dPos)divDid))
  (setq YOrd (cadr 3dPos))
  ); end if
     (if(/= 0.0(nth 2 3dPos))
  (setq ZOrd(/(nth 2 3dPos)divDid))
  (setq ZOrd (nth 2 3dPos))
  ); end if
     (setq 3dPos(list XOrd YOrd ZOrd))
 (setq exCir
   (vla-addCircle actSp
     (vlax-3d-Point startPt)
     (/ tube:Width 2))
  inCir
   (vla-addCircle actSp
     (vlax-3d-Point startPt)
     (/ tube:Height 2))
  ); end setq
 (vla-put-Normal exCir(vlax-3D-point 3dPos))
 (vla-put-Normal inCir(vlax-3D-point 3dPos))
 (setq exEnt(vlax-vla-object->ename exCir)
  inEnt(vlax-vla-object->ename inCir)
  ) ; end setq
 (command "_.extrude" exEnt "" "_p" pathEnt)
 (setq exTube(entlast))
 (command "_.extrude" inEnt "" "_p" pathEnt)
 (setq inTube(entlast))
 (command "_subtract" exTube "" inTube "")
 (command "_.erase" exEnt "")
 (command "_.erase" inEnt "")
 (if(= "Yes" delFlag)
   (vla-delete baseLine)
      ); end if
  ); end foreach
     (vla-put-Lock actLay laySt)
     (setvar "CMDECHO" oldEcho)
      ); end progn
     ); end if
    ); end progn
   (princ "\nInternal diameter more or equal external diameter! ")
   ); end if
 (if(= 16(Asmi-AcadVersion nil))
 (vla-EndUndoMark actDoc)
   ); end if
   (princ)
   ); end  of c:xtube

(defun Asmi-AcadVersion(Generation)
 (if Generation
   (substr (getvar "ACADVER")1 4)
   (substr (getvar "ACADVER")1 2)
   ); end if
 ); end of Asmi-AcadVersion

Share this post


Link to post
Share on other sites
rusty105

ok, sorry to be late to the party, but xtube works good for me. The only question I have is when 2 tubes come together, how do I trim the parts of the tube I do not want?

 

Thanks

Rusty

Share this post


Link to post
Share on other sites
gender123

what command should i type in the commandline?

Share this post


Link to post
Share on other sites
areyes

does anyone out there know the command for 'xpipe? (xpipe) does not work

Share this post


Link to post
Share on other sites
JD Mather
does anyone out there know the command for 'xpipe? (xpipe) does not work

 

Did you load the LISP?

Share this post


Link to post
Share on other sites
SLW210

xpipe works for me on AutoCAD 2011.

Share this post


Link to post
Share on other sites
hoss
does anyone out there know the command for 'xpipe? (xpipe) does not work

 

You have to save the lisp on you pc first "name.lsp"

The use "Appload" to load it or simply drag and drop the file the drawing area

then you shoud get Command: (LOAD "C:/Users/xxxx/Desktop/test.lsp") C:XTUBE

now you can type xpipe or xtube and follow the command line

Share this post


Link to post
Share on other sites
hoss

For some reason I see "& # 4 0 ; " instead of open bracket "(" and same for all others

Is this something to do with the web codes

Share this post


Link to post
Share on other sites
the downing effect
:thumbsup: great routine, thanks for sharing

Share this post


Link to post
Share on other sites
Buzza

The xtube and xpipe seem great. only thing is when i try to use xtube i works the same as xpipe. It does not put a channel in the tube but just makes a pipe to the OD. Anyone know whats wrong?

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...