Hi Folks,
could you please help me anyone to convert circle to Polyline. I need C# Code to complete this action?
Regards
Alex Andrews.
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
A quick search on the internet will give you solutions, probably all in lisp, but they work.
GrantsPirate
Piping and Mech. Designer
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.
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 -
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!
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.
@lewis724 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.
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.
If you have access to Civil 3d you can easily do it with "MAPCLEAN" command
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
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.
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
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 🙂
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.
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! 😉