Convert simple lines into cylinders

Convert simple lines into cylinders

Gdtech-Autocad
Explorer Explorer
1,004 Views
2 Replies
Message 1 of 3

Convert simple lines into cylinders

Gdtech-Autocad
Explorer
Explorer

Hello

I have a drawing containing simple lines.

I would like to convert these lines into 3D cylinders / pipes.

The idea is to select the entity UCS, create a circle at the end of each line and extrude this circle along the line.

 

This is below the code I have tested.

In some cases it works (fig A). In some other cases not (fig B.). It depends on the UCS orientation.

I use UCS E (entity) and then rotate the UCS 90° around Y axis.

My question is : how to place correctly the UCS on the entity to draw the circle and to get a correct result each time ?

Thanks for your help

 

(defun SUB_TUY(ly)
   (setq ly "TUY090")
   (setq sset (ssget "X" (list (cons 8 ly))))
   (setq ne (sslength sset))
   (princ "  Objects selected : ")(princ ne)
   (if (= ne 0) (progn (exit)))
   (setq index 0)
   (setq ne (- ne 1))
   (while (<= index ne)
      (setq en (ssname sset index))
      (command "UCS" "E" en)
      (command "UCS" "Y" "90")
      (setq dia 114.3))
      (command "CIRCLE" "0,0,0" "D" dia)
      (command "EXTRUDE" "L" "" "P" en)
      (setq index (+ 1 index))
   )
)

 

 

Entity DXF codes of the line A :

((-1 . <Entity name: 4f2d2f10>) (0 . LINE) (5 . 20DA) (330 . <Entity name: 4eed7470>) (100 . AcDbEntity) (67 . 0) (410 . Model) (8 . TUY080) (100 . AcDbLine) (10 2720.71 -150.000 2326.87) (11 2720.71 -150.000 2470.90)

(210 -1.00000 0.E+00 0.E+00))

 

Entity DXF codes of the line B :

((-1 . <Entity name: 4f2d2010>) (0 . LINE) (5 . 20A3) (330 . <Entity name: 4eed7470>) (100 . AcDbEntity) (67 . 0) (410 . Model) (8 . TUY080) (62 . 1) (100 . AcDbLine) (10 2720.71 -150.000 2154.87) (11 2720.71 -150.000 2036.63)

(210 0.E+00 0.E+00 1.00000))

 

 

pendean_0-1706905279817.png

 

0 Likes
Accepted solutions (1)
1,005 Views
2 Replies
Replies (2)
Message 2 of 3

Kent1Cooper
Consultant
Consultant
Accepted solution

Use SWEEP instead of EXTRUDE.  Draw the Circle in the XY plane, and SWEEP will orient it to the path.  These are all Sweeps, along Lines [green] running in various XYZ directions, of the same Circle at right, without messing with the Coordinate System:

Kent1Cooper_0-1706909661367.png

 

Kent Cooper, AIA
Message 3 of 3

Gdtech-Autocad
Explorer
Explorer

Hello thanks for your response.

It works.

Sweep is a much better solution.

Thanks a lot. 

0 Likes