CAD/CAM discussion forum > CAD Tutorial & Tips > How to Convert Ellipse to Arc by using lisp in ZWCAD? ellipse arc

How to Convert Ellipse to Arc by using lisp in ZWCAD? ellipse arc

Rank: 1

davies65

Newbie

posts: 6

Registered: 2012-7-11

Message 1 of 1

 How to Convert Ellipse to Arc by using lisp in ZWCAD? ellipse arc
12-07-2012 11:34 . am | View his/her posts only
How to Convert Ellipse to Arc? Conversation of ellipse arc.

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
See also