# Thread: Convert Ellipse to Arcs

1. ## Convert Ellipse to Arcs

Registered forum members do not see this ad.

Hi all,

I am currently working on a drawing that has been done using ellipses instead of arcs. I need to create a polyline so I can take off an area

The major and minor radii of the ellipses are equal.

I was hoping to be able to extact the relvant properties from an ellipse and produce an arc at its location. Here is a routine I have been working on but it does not work correctly.

It inserts an arc with the correct radius but there seems to be a problem with the start and end angles

Code:
```(defun ellipse->arc ();/ SS LI_ENAME ACADOBJ acaddoc acadms PASS FAIL radius OBJ StartAngle EndAngle Center)

(if
(and
(setq ss (ssget '((0 . "ellipse"))))
(setq li_enames (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
)

(progn
;Load ActiveX Support

(vl-load-com)
(setq acadobj  (vlax-get-acad-object)
acaddoc	 (vla-get-activeDocument acadobj )
acadms 	 (vla-get-modelspace acaddoc)
pass  0
fail  0
)

(FOREACH N li_enames
(setq obj (vlax-ename->vla-object n))

(if
(equal
(vla-get-RadiusRatio obj) 1 0.0001)

(progn

(setq  radius     (vla-get-MajorRadius obj )
StartAngle (vla-get-StartAngle OBJ)
EndAngle   (vla-get-EndAngle obj)
Center     (vla-get-Center obj)
)

(vla-addarc acadms Center radius StartAngle EndAngle  )
(entdel n)
(setq pass (1+ pass))
)

(setq fail (1+ fail))
)
)

(alert (strcat "\n<" (rtos pass 2 0) "> Ellipse objects converted to Arcs" )
(strcat "\n<" (rtos fail 2 0) "> Ellipse objects failed to be converted" ))
)
(alert "\No Ellipses selected")
)
)```
Any help would be greatly appreciated

Thanks

Jammie

2. Could you be a little more detailed in what you want to accomplish.
If drawing an ellipse set the AutoCAD system variable pellipse to 1 so when you draw an ellipse it is made with a polyline.
If an ellipse is in the drawing you can save it down to the lowest DXF like R12 then open it back up and the ellipse will be converted to a polyline.
There are many methods that can be used to make an ellipse. I believe the math AutoCAD uses will use about 8 – 10 different arcs to make an ellipse.

3. Thanks John,

I didn't create the drawing myself. I just need to do an area check. The particular boundary that I needed was drawn using lines and ellipses

If an ellipse is in the drawing you can save it down to the lowest DXF like R12 then open it back up and the ellipse will be converted to a polyline.
That worked fine for finding the area I required,

Thanks

-Jammie

4. I don’t know exactly what you are doing but you might want to check out the boundary command. If an area is closed you can create a boundary the list the area and perimeter
Type –boundary (hyphen boundary) then pick a point inside the closed area and it will create a polyline outline of the area then you can use list last to get info or have lisp do it for you.
Note: if the area contains a ellipse you will be asked to create a region and then you can get info

5. I don’t know exactly what you are doing
Hah I spend most of the day wondering that myself...

Note: if the area contains a ellipse you will be asked to create a region and then you can get info
Creating a region works very well.

Interestingly AutoCAD seems to convert the ellipses to arcs when creating the region. (I am positive they are ellipses though)

When I explode the region, it creates a series of ARCs and lines

-Jammie

6. Jammie
Click this link, maybe you can find something usefull on that page:
http://www.cadtutor.net/forum/showthread.php?t=1639&

7. Jammie
Click this link, maybe you can find something usefull on that page:
http://www.cadtutor.net/forum/showthread.php?t=1639&
fuccaro,

That is an interesting thread and very nice work on the routine to convert an ellipse to a pline.

That also explains why offsetting an ellipse creates a spline

Thanks for your help

Jammie

8. I think you look for like this code
Code:
```(defun c:e2a (/ acaddoc acadms acadobj center endangle obj radius ss ssn startangle)
(vl-load-com)
(if
(setq ss (ssget '((0 . "ellipse"))))
(progn
(setq acadobj (vlax-get-acad-object))
(setq acaddoc (vla-get-activeDocument acadobj))
(setq acadms (vla-get-modelspace acaddoc))
(setq ssn (ssname ss 0))
(setq obj (vlax-ename->vla-object ssn))
(if
obj ;(equal (vla-get-RadiusRatio obj) 1 0.0001)
(progn
(setq radius (vla-get-MajorRadius obj))
(setq StartAngle (vla-get-StartAngle OBJ))
(setq EndAngle (vla-get-EndAngle obj))
(setq Center (vlax-get obj 'center))
(entdel ssn)
(vla-addarc acadms (vlax-3d-point Center) radius StartAngle EndAngle)
) ; progn
(alert "> Ellipse objects failed to be converted")
)   ; if
)     ; progn
)       ; if
(princ)
)       ; defun```
Originally Posted by jammie
Hi all,

I am currently working on a drawing that has been done using ellipses instead of arcs. I need to create a polyline so I can take off an area

The major and minor radii of the ellipses are equal.

I was hoping to be able to extact the relvant properties from an ellipse and produce an arc at its location. Here is a routine I have been working on but it does not work correctly.

It inserts an arc with the correct radius but there seems to be a problem with the start and end angles

Code:
```(defun ellipse->arc ();/ SS LI_ENAME ACADOBJ acaddoc acadms PASS FAIL radius OBJ StartAngle EndAngle Center)

(if
(and
(setq ss (ssget '((0 . "ellipse"))))
(setq li_enames (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
)

(progn
;Load ActiveX Support

(vl-load-com)
(setq acadobj  (vlax-get-acad-object)
acaddoc	 (vla-get-activeDocument acadobj )
acadms 	 (vla-get-modelspace acaddoc)
pass  0
fail  0
)

(FOREACH N li_enames
(setq obj (vlax-ename->vla-object n))

(if
(equal
(vla-get-RadiusRatio obj) 1 0.0001)

(progn

(setq  radius     (vla-get-MajorRadius obj )
StartAngle (vla-get-StartAngle OBJ)
EndAngle   (vla-get-EndAngle obj)
Center     (vla-get-Center obj)
)

(vla-addarc acadms Center radius StartAngle EndAngle  )
(entdel n)
(setq pass (1+ pass))
)

(setq fail (1+ fail))
)
)

(alert (strcat "\n<" (rtos pass 2 0) "> Ellipse objects converted to Arcs" )
(strcat "\n<" (rtos fail 2 0) "> Ellipse objects failed to be converted" ))
)
(alert "\No Ellipses selected")
)
)```
Any help would be greatly appreciated

Thanks

Jammie

9. I think you look for like this code
Code:

(defun c:e2a (/ acaddoc acadms acadobj center endangle obj radius ss ssn startangle)
(vl-load-com)
(if
(setq ss (ssget '((0 . "ellipse"))))
(progn
(setq acadobj (vlax-get-acad-object))
(setq acaddoc (vla-get-activeDocument acadobj))
(setq acadms (vla-get-modelspace acaddoc))
(setq ssn (ssname ss 0))
(setq obj (vlax-ename->vla-object ssn))
(if
obj ;(equal (vla-get-RadiusRatio obj) 1 0.0001)
(progn
(setq radius (vla-get-MajorRadius obj))
(setq StartAngle (vla-get-StartAngle OBJ))
(setq EndAngle (vla-get-EndAngle obj))
(setq Center (vlax-get obj 'center))
(entdel ssn)
(vla-addarc acadms (vlax-3d-point Center) radius StartAngle EndAngle)
) ; progn
(alert "> Ellipse objects failed to be converted")
) ; if
) ; progn
) ; if
(princ)
) ; defun
Adesu,

I have just tested your code and it works very well. It converts the ellipses to arcs which is exactly what I was hoping for.

Thank you for you help

Regards,

Jammie

10. Registered forum members do not see this ad.

Ahh....I very glad can help one.

Originally Posted by jammie
Adesu,

I have just tested your code and it works very well. It converts the ellipses to arcs which is exactly what I was hoping for.

Thank you for you help

Regards,

Jammie

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts