# Thread: Convert Ellipse to Arc

1. Registered forum members do not see this ad.

Originally Posted by Bill_Myron
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.
Thank you for attaching the sample drawing.

The issue is that, although very close to being circular, the ellipse axis ratio is in fact not quite equal to 1.0.

You can verify this by using the following program to retrieve the axis ratio for a selected ellipse:
Code:
```(defun c:eratio ( / e )
(while
(and (setq e (car (entsel "\nSelect ellipse: ")))
(= "ELLIPSE" (cdr (assoc 0 (entget e))))
)
(princ (strcat "\nEllipse ratio: " (rtos (cdr (assoc 40 (entget e))) 2 15)))
)
(princ)
)```
Testing the program with a few ellipses from your drawing yields the following results:
Code:
```Select ellipse:
Ellipse ratio: 0.999999532781626
Select ellipse:
Ellipse ratio: 0.999999532795758
Select ellipse:
Ellipse ratio: 0.999999532786339
Select ellipse:
Ellipse ratio: 0.999999532749180
Select ellipse:
Ellipse ratio: 0.999999532857222```
The following code is a modification of the Ellipse to Arc program published on my site here, to incorporate some tolerance into the ellipse ratio filter:
Code:
```;;-------------------=={ Ellipse to Arc }==-------------------;;
;;                                                            ;;
;;  Converts circular Ellipses & Elliptical Arcs (i.e. for    ;;
;;  which the Ellipse Axis Ratio = 1.0) to Circles & Arcs,    ;;
;;  whilst retaining all original properties. Works with      ;;
;;  Ellipses & Elliptical Arcs constructed in any UCS.        ;;
;;------------------------------------------------------------;;
;;------------------------------------------------------------;;

(defun c:e2a ( / a b c e i m p q r s u v z )
(if (setq s (ssget "_:L" '((0 . "ELLIPSE") (-4 . ">=") (40 . 0.9999) (-4 . "<=") (40 . 1.0001))))
(repeat (setq i (sslength s))
(setq e (entget (ssname s (setq i (1- i))))
z (cdr (assoc 210 e))
c (trans (cdr (assoc 10 e)) 0 z)
p (trans (cdr (assoc 11 e)) 0 z)
a (distance '(0.0 0.0) p)
b (* a (cdr (assoc 40 e)))
r (angle '(0.0 0.0) p)
u (cdr (assoc 41 e))
v (cdr (assoc 42 e))
m (list (list (cos r) (- (sin r))) (list (sin r) (cos r)))
p (mapcar '+ c (mxv m (list (* a (cos u)) (* b (sin u)))))
q (mapcar '+ c (mxv m (list (* a (cos v)) (* b (sin v)))))
)
(if
(if (equal p q 1e-8)
(entmake
(cons '(0 . "CIRCLE")
(append (LM:defaultprops e)
(list
(cons  010 c)
(cons  040 a)
(assoc 210 e)
)
)
)
)
(entmake
(cons '(0 . "ARC")
(append (LM:defaultprops e)
(list
(cons  010 c)
(cons  040 a)
(cons  050 (angle c p))
(cons  051 (angle c q))
(assoc 210 e)
)
)
)
)
)
(entdel (cdr (assoc -1 e)))
)
)
)
(princ)
)

;; Default Properties  -  Lee Mac
;; Returns a list of DXF properties for the supplied DXF data,
;; substituting default values for absent DXF groups

(defun LM:defaultprops ( elist )
(mapcar
(function
(lambda ( pair )
(cond ((assoc (car pair) elist)) ( pair ))
)
)
'(
(008 . "0")
(006 . "BYLAYER")
(039 . 0.0)
(062 . 256)
(048 . 1.0)
(370 . -1)
)
)
)

;; Matrix x Vector  -  Vladimir Nesterovsky
;; Args: m - nxn matrix, v - vector in R^n

(defun mxv ( m v )
(mapcar '(lambda ( r ) (apply '+ (mapcar '* r v))) m)
)

(princ)```

2. Never thought of checking the ratio units that far.

Perfect. Thanks Lee Mac.

3. You're welcome Bill

4. I agree with Bill.... the program is not recognizing the ellipse.... so it is not getting selected.

i understand this is an old thread..... maybe the forum has shifted to another thread... it will be useful to convert ellipses to mathematically accurate circles / arcs

5. Originally Posted by Hsanon
I agree with Bill.... the program is not recognizing the ellipse.... so it is not getting selected.
What is the axis ratio of your ellipses? (use the above program to check this)

6. I have now updated the Ellipse to Arc program published on my site to incorporate the tolerance on the ellipse axis ratio.

Lee

7. ## Ellispse to arc convert

hi everyone,

8. Registered forum members do not see this ad.

Refer to the solution offered here.