Convert CIRCLE to Polyline

Convert CIRCLE to Polyline

Anonymous
Not applicable
64,083 Views
28 Replies
Message 1 of 29

Convert CIRCLE to Polyline

Anonymous
Not applicable

Hi Folks,

could you please help me anyone to convert circle to Polyline. I need C# Code to complete this action?

Regards

Alex Andrews.

0 Likes
64,084 Views
28 Replies
Replies (28)
Message 2 of 29

TheCADnoob
Mentor
Mentor

Not sure there is a clean way to do this. There is no simple convert, but there are a couple methods to get a polyline from your circle. 

 

Probably the easiest is to use BOUNDRY command. 

 

You can also try splitting the circle into two arcs and then use PEDIT to convert the arc to poly lines

 

Another method it to create a circle with a polyline ellipse. Set PELLIPSE to 1 and new ellipses will be drawn as polylines

 

I also read about using the DONUT command but that similar to splitting it into two arcs. 

 

CADnoob

EESignature

0 Likes
Message 3 of 29

GrantsPirate
Mentor
Mentor

A quick search on the internet will give you solutions, probably all in lisp, but they work.


GrantsPirate
Piping and Mech. Designer
EXPERT ELITE MEMBER
Always save a copy of the drawing before trying anything suggested here.
----------------------------------------------------------------------------
If something I wrote can be interpreted two ways, and one of the ways makes you sad or angry, I meant the other one.

Message 4 of 29

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

in AutoCAD I would trim the circle to get an arc, then use command _PEDIT and select this arc and chose then _CLOSE

For C# please look in that customization forum for AutoCAD and .NET >>>click<<< (I would start to create an object as described above and then use .NET to select and analyse this object).

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 5 of 29

Kent1Cooper
Consultant
Consultant

My AutoLisp routine to do that is the C2P command in CirclePolylineSwap.lsp, available >here<.  I don't know C#, but if anything in the C2P command there suggests an approach in C# terms, take whatever you can use.

Kent Cooper, AIA
Message 6 of 29

pendean
Community Legend
Community Legend
DONUT command
0 Likes
Message 7 of 29

Anonymous
Not applicable

Is there a way to convert multiple circles to polylines using this LISP routine?  I have thousands of circles on a drawing that i'm trying to convert easily.  When I use C2P, it only converts the first circle.  Any help would be appreciated!

0 Likes
Message 8 of 29

vinodkl
Mentor
Mentor

Hi,

 

you can use QSELECT first and isolate the circles first then you can use the command C2P and select all the circles. Thats it. I tried it and it works. Also check if the system variable PICKADD is set to "2", may that's what causing the problem on your end.

--------------------------------------------------------------------------------------------------------------------------
ವಿನೋದ್ ಕೆ ಎಲ್( System Design Engineer)
Likes is much appreciated if the information I have shared is helpful to you and/or others.

Please mark "Accept as Solution" if my reply resolves the issue or answers your question, to help others in the community.
--------------------------------------------------------------------------------------------------------------------------
Message 9 of 29

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

Is there a way to convert multiple circles to polylines using this LISP routine?  I have thousands of circles on a drawing that i'm trying to convert easily.  When I use C2P, it only converts the first circle.  Any help would be appreciated!


It is designed to do more than one, but as suggested, your PICKADD System Variable may be set wrong.

 

I'm not sure this will make any difference, but I'm attaching my current file, which says it was last edited on the very date of that link Message, though the file attached there doesn't say that's the last-edited date.  I may have simply noticed and updated it in mine without re-posting at the time, without any other changes, but just in case I did improve on anything else, here it is.

Kent Cooper, AIA
0 Likes
Message 10 of 29

Anonymous
Not applicable

This is not as elegant as writing a lisp routine but, this is the way I did it.  I used MAPEXPORT and exported the circles as a line .shp file.  Then used MAPIMPORT to import that shapefile and they came in as polylines.  It took about 3 minutes for 664 circles so I am not sure the difference in timing between this method and the lisp routine.

0 Likes
Message 11 of 29

Anonymous
Not applicable

If you have access to Civil 3d you can easily do it with "MAPCLEAN" command

Message 12 of 29

leeminardi
Mentor
Mentor

You might also consider using the polygon command with a high number of sides.

lee.minardi
Message 13 of 29

dlanorh
Advisor
Advisor

A closed lwpolyline with a bulge also works

 

(defun rh:c2p (ent / spc obj)
  (setq spc (vlax-get-property (vla-get-activedocument (vlax-get-acad-object)) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))
        obj (vlax-invoke spc 'addlightweightpolyline (apply 'append (list (reverse (cdr (reverse (vlax-curve-getstartpoint ent)))) (reverse (cdr (reverse (vlax-curve-getpointatparam ent pi)))))))
  )
  (vlax-put-property obj 'closed :vlax-true)
  (foreach x '(0 1) (vla-setbulge obj x -1.0))
  (vla-delete (vlax-ename->vla-object ent))
);end_defun

 

feed it an entity and it produces a polyline. If you want to keep the circle comment out the (vla-delete..)

I am not one of the robots you're looking for

0 Likes
Message 14 of 29

Kent1Cooper
Consultant
Consultant

People seem to be forgetting that they're looking for C# code for this.  More AutoLisp routines than have already been suggested are not going to be their answer.

Kent Cooper, AIA
0 Likes
Message 15 of 29

Sea-Haven
Mentor
Mentor

Can not c# call a lisp ? Why not go down that path. VBA can call a lisp or use a send command method "(Load "Mycirc-pline")"

 

A quick google

https://forums.autodesk.com/t5/net/problem-calling-a-lisp-routine-from-c/td-p/6023176

0 Likes
Message 16 of 29

Sea-Haven
Mentor
Mentor

Nice idea add on say another layer or delete.

 

Re comment elsewhere 1600 circles about 1 second to make.

0 Likes
Message 17 of 29

Raymarcher
Enthusiast
Enthusiast

Use boundary in circle

0 Likes
Message 18 of 29

Anonymous
Not applicable

I wanted to do this myself and was hitting a wall. However, I found a simple solution.

 

First, use the PELLIPSE command and set the value to 1 (this converts an ellipse to a 2D polyline).

Second, draw and ellipse the same size as the circle you want. 

Third, click on the ellipse and edit the global width in the geometry section of properties.

 

I hope this helps 🙂

Message 19 of 29

Kent1Cooper
Consultant
Consultant

It may be a way to draw a new Polyline in the shape of a Circle, but:

1.  It's not in C# code as in the original request;

2.  It doesn't convert an existing Circle to a Polyline as in the original request and the Topic heading;

3.  It results in a Polyline of 16 segments, when it can be done with no more than 2 by other suggested approaches.

 

Kent Cooper, AIA
0 Likes
Message 20 of 29

Anonymous
Not applicable

Dear Ken1Cooper (Consultant),

 

Thank you for the response. I must admit that using C# code in AutoCAD is beyond my abilities and I cannot help with that part of the request. The question asked how to convert a circle into a polyline and I like to keep things simple, so I provided a simple solution. Other suggestions may result in a circle with less segments, but they are far more complex than my solution. Therefore, if you like things to be complicated, then please ignore my solution and try one of the others! 😉