Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Line/Pline into Cylinder/Tube

12 REPLIES 12
Reply
Message 1 of 13
Anonymous
2682 Views, 12 Replies

Line/Pline into Cylinder/Tube

Hi -

Does anyone have a script available that will turn a line or pline into a cylinder or tube, i.e. extrude a circle along the path of the line/pline. If there isn't a script out there, could someone point me in the right direction as to how to make one?

Thanks,
Stephen R. Heard
12 REPLIES 12
Message 2 of 13
Anonymous
in reply to: Anonymous

The 'Extrude' command has a 'Path' option.
wrote in message news:5420222@discussion.autodesk.com...
Hi -

Does anyone have a script available that will turn a line or pline into a
cylinder or tube, i.e. extrude a circle along the path of the line/pline.
If there isn't a script out there, could someone point me in the right
direction as to how to make one?

Thanks,
Stephen R. Heard
Message 3 of 13
_gile
in reply to: Anonymous

Hi,

(defun c:line2cyl (/ rad)
(command "_.undo" "_begin")
(if (and
(setq rad (getdist "\nCylinders radius: "))
(setq ss (ssget '((0 . "LINE"))))
)
(foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
(command "_.cylinder"
(trans (cdr (assoc 10 (entget x))) 0 1)
rad
"_c"
(trans (cdr (assoc 11 (entget x))) 0 1)
)
)
)
(command "_.undo" "_end")
(princ)
)


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 4 of 13
_gile
in reply to: Anonymous

Another one (attached) working with arcs, circles, ellipses, lines lwpolylines, 2D polylines, 3D polylines and splines.


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 5 of 13
_gile
in reply to: Anonymous

Sorry, I forgot a (vl-load-com) and a (vla-EndUndoMark AcDoc)

Please, don't load nor the pevious attached file nor this one. Message was edited by: gile


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 6 of 13
_gile
in reply to: Anonymous

Here is, I hope the good file.


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 7 of 13
Anonymous
in reply to: Anonymous

Thanks for the responses everybody.

Gile-

I ran your script and it gave an unknown command error for VXV. It looks like this may be crossing two vectors? Any help would be appreciated.

Thanks,
Stephen Heard
Message 8 of 13
Anonymous
in reply to: Anonymous

Gile-

I found this in another thread:

(defun vxv (v1 v2)
(apply '+ (mapcar '* v1 v2))
)

So I tried it in the script and it works great. Thanks so much for your help!

Thanks,
Stephen Heard
Message 9 of 13
_gile
in reply to: Anonymous

One more time, I'm sorry.

VXV is one of my startup sub routines, I forgot to add it.

Here's, I hope, a good version


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 10 of 13
Anonymous
in reply to: Anonymous

Works great! Thanks a million.

-Stephen Heard
Message 11 of 13
Anonymous
in reply to: Anonymous

I need 2 lisps to streamline a workflow, hope there is someone who can help...

 

1. Cylinder from Line

Command: CL

CYLINDER FROM LINE Select Line or specify [Radius] ,<265.0>:

(The lisp saves the last used Radius for the session and draws a cylinder of saved radius with centre line along the line)

 

 

2. Cylinder from 2 Points

Command: CTP

CYLINDER FROM 2 POINTS Select First Point or specify [Radius] ,<265.0>:

Select Second Point:

(The lisp saves the last used Radius for the session and draws a cylinder of saved radius with centre line from one point to the other)

 

 

Anyone keen for the challenge?

Message 12 of 13
Kent1Cooper
in reply to: Anonymous

Do a Search for "tube" and/or "cylinder" and you'll find a lot of threads, some of which may well do exactly what you want already.  One of them probably contains this, that I did a while back [I haven't plowed through to find which one]:

 

(defun C:TUBE (/ ss ent)
  (initget (if *tubedia 6 7)); no 0, no negative, no Enter on first use
  (setq *tubedia
    (cond
      ((getdist
          (strcat
            "\nDiameter of Tubular Cross-Section(s)"
            (if *tubedia (strcat " <" (rtos *tubedia) ">") ""); offer default only on subsequent use
            ": "
          ); strcat
        ); getdist
      ); User-gives-distance condition
      (*tubedia); Enter for default on subsequent use
    ); cond
  ); setq
  (prompt "\nTo make tubular extrusions along paths,")
  (setq ss (ssget '((0 . "*POLYLINE,LINE,ARC,CIRCLE,ELLIPSE,SPLINE"))))
  (repeat (sslength ss)
    (setq ent (ssname ss 0))
    (command
      "_.ucs" "_ZA"
        (vlax-curve-getStartPoint ent)
        (mapcar '+
          (getvar 'lastpoint)
          (vlax-curve-getFirstDeriv ent (vlax-curve-getStartParam ent))
        ); mapcar & UCS
      "_.circle" "0,0" (/ *tubedia 2)
      "_.ucs" "_previous"
      "_.extrude" (entlast) "" "_path" ent
    ); command
    (ssdel (ssname ss 0) ss)
  ); repeat
); defun

 

It works on lots of entity types, whether you use it on any other than Lines or not.  It does remember the User's diameter and offers it as a default on subsequent use.  Are you capable of editing it to ask for the Radius instead of the Diameter, and to make a version that asks for two points instead of the selection of an object?

Kent Cooper, AIA
Message 13 of 13
Maruchinesu
in reply to: _gile

I used this routine on my project and it works great! Thank you very much

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost