# Thread: Convert Ellipse to Arc

1. ## Convert Ellipse to Arc

Registered forum members do not see this ad.

I have been trying to figure this out for a couple of days now. The only thing I could find is this LISP that takes the Ellipse properties and uses them to creat an arc.

When I use this, the start and end angles are not correct in the drawing. Ellipses must have been drawn in a different UCS).

I have tried to get the LISP to use the start and end points of the ellipse along with the radius and center point. For the life of me I cannot figure it out. If anyone knows how to do this please let me know.

*NOTE* Elllipses that I am trying to convert have the same minor and major radii.

Code:
```
(if
(setq ss (ssget '((0 . "ellipse"))))
(progn
(setq ssn (ssname ss 0))
(setq obj (vlax-ename->vla-object ssn))
(if
obj ;(equal (vla-get-RadiusRatio obj) 1 0.0001)
(progn
(setq Startangle (vla-get-Startangle obj))
(setq Endangle (vla-get-Endangle obj))
(setq Center (vlax-get obj 'center))
(entdel ssn)
) ; progn
(alert "> Ellipse objects failed to be converted")
)   ; if
)     ; progn
)       ; if
(princ)
)       ; defun```

2. Hi Bill,

I would be inclined to use the entmake(x) function for this task, as transference of object properties can be accomplished with a single function call.

Here is my program:
Code:
```;; Ellipse 2 Arc  -  Lee Mac 2011  -  www.lee-mac.com
;; Converts Circular Ellipses (Axis Ratio = 1) to Circles/Arcs

(defun c:e2a ( / e i s )
(if (setq s (ssget "_:L" '((0 . "ELLIPSE") (40 . 1.0))))
(repeat (setq i (sslength s))
(setq e (entget (ssname s (setq i (1- i)))))
(if
(entmakex
(if (equal (abs (- (cdr (assoc 42 e)) (cdr (assoc 41 e)))) (+ pi pi))
(apply 'append
(cons
(list
(cons 0 "CIRCLE")
(cond ((assoc  6 e)) ('( 6 . "BYLAYER")))
(cond ((assoc 39 e)) ('(39 . 0.0)))
(cond ((assoc 62 e)) ('(62 . 256)))
(cons 10 (trans (cdr (assoc 10 e)) 0 (cdr (assoc 210 e))))
(cons 40 (distance '(0. 0. 0.) (cdr (assoc 11 e))))
)
(mapcar
(function
(lambda ( x )
(if (not (member (car x) '(-1 0 5 6 10 11 39 40 41 42 62 100 330)))
(list x)
)
)
)
e
)
)
)
(apply 'append
(cons
(list
(cons 0 "ARC")
(cond ((assoc  6 e)) ('( 6 . "BYLAYER")))
(cond ((assoc 39 e)) ('(39 . 0.0)))
(cond ((assoc 62 e)) ('(62 . 256)))
(cons 10 (trans (cdr (assoc 10 e)) 0 (cdr (assoc 210 e))))
(cons 40 (distance '(0. 0. 0.) (cdr (assoc 11 e))))
(cons 50 (+ (cdr (assoc 41 e)) (angle '(0. 0. 0.) (trans (cdr (assoc 11 e)) 0 1))))
(cons 51 (+ (cdr (assoc 42 e)) (angle '(0. 0. 0.) (trans (cdr (assoc 11 e)) 0 1))))
)
(mapcar
(function
(lambda ( x )
(if (not (member (car x) '(-1 0 5 6 10 11 39 40 41 42 62 100 330)))
(list x)
)
)
)
e
)
)
)
)
)
(entdel (cdr (assoc -1 e)))
)
)
)
(princ)
)```

I tried your program, and it ends up doing the same as what I had. It replaces the ellipse with an arc based on the start and end angles, causeing the arc to be created in a different location than where the ellipse currently is. The properties of the new arc and the old Ellipse have the same start and end angles, but the arc is drawn as if it was rotated. I hope that makes sense.

If the program could use the start and end points instead of the angles, I think it would work.

4. Hi Bill,

I missed something, try the updated code above

5. Lee Mac you are a genius! It works amazing. I cant thank you enough. You saved me lots time on here.

Thanks again!!

6. Thanks Bill, you're welcome

7. Just started using this lisp in 2014.

For some reason it will not select any ellipse. I suspect it has to do with how 2014 creates the ellipse.

Wonder if anyone else has encountered this, or if they have a different way to convert ellipses into arcs?

8. Originally Posted by Bill_Myron
For some reason it will not select any ellipse. I suspect it has to do with how 2014 creates the ellipse.
Could you upload a sample drawing?

9. Originally Posted by Bill_Myron
For some reason it will not select any ellipse. I suspect it has to do with how 2014 creates the ellipse.
Lee's code is fine, but I suspect that you are attempting to select real ellipse and not circular one - in selection filter that follows (ssget) function it was explicitly written that ratio between "small" and "big" ellipse radius is 1.0 which means that ellipse must be circular in order for (ssget) function to accept selecting entities filtered by written filter statement that follows inside (ssget) function...

10. Registered forum members do not see this ad.

Perhaps it may be some setting I have set.

The ellipse are circular with a radius ratio of 1.

Attached is a drawing that will not allow me to select the ellipses with the lisp.