In trying to solve this problem, I cobbled together the following:
Code:
(defun ellfix ( / ELL-LST MODLSPACE NEW-X X-CENTER X-MAJAX X-MINAX X-NEW-MAJAX X-NEW-MINAX X-NORM X-RADRATIO)
(setq modlspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
(vlax-for n modlspace
(if (not (equal "AcDbEllipse" (vla-get-objectname n)))
nil
(setq ell-lst (append ell-lst (list n)))
); if
); vlax-for
(if (> (length ell-lst) 0)
(progn
(foreach x ell-lst
(setq x-norm (vlax-safearray->list (vlax-variant-value (vla-get-normal x)))
x-center (vlax-safearray->list (vlax-variant-value (vla-get-center x)))
); setq
(if (equal (list 0.0 0.0 1.0) x-norm)
(vl-catch-all-apply 'vla-put-center x (list (vlax-3d-point (list (car x-center) (cadr x-center) 0.0))))
(progn
(setq x-ename (vlax-vla-object->ename x)
x-majax (trans (vlax-safearray->list (vlax-variant-value (vla-get-majoraxis x))) x-ename 1 T)
x-new-majax (list (car x-majax) (cadr x-majax) 0.0)
x-minax (trans (vlax-safearray->list (vlax-variant-value (vla-get-minoraxis x))) x-ename 1 T)
x-new-minax (list (car x-minax) (cadr x-minax) 0.0)
x-radratio (/ (distance (list 0.0 0.0 0.0) x-new-minax) (distance (list 0.0 0.0 0.0) x-new-majax))
x-center (trans x-center x-ename 1)
); setq
(if (= 1.0 x-radratio)
(setq new-x (vla-addcircle
modlspace
(vlax-3d-point (list (car x-center) (cadr x-center) 0.0))
(distance (list 0.0 0.0 0.0) x-new-majax)
); vla-addcircle
);setq
(progn
(if (> x-radratio 1.0)
(progn
(setq x-new-majax x-new-minax
x-radratio (/ 1.0 x-radratio)
); setq
); progn
); if
(setq
new-x (vla-addellipse
modlspace
(vlax-3d-point (list (car x-center) (cadr x-center) 0.0))
(vlax-3d-point x-new-majax)
x-radratio
); vla-addellipse
); setq
); progn
); if
(vl-catch-all-apply 'vla-put-layer (list new-x (vla-get-layer x)))
(vl-catch-all-apply 'vla-put-linetype (list new-x (vla-get-linetype x)))
(vl-catch-all-apply 'vla-put-linetypescale (list new-x (vla-get-linetypescale x)))
(vl-catch-all-apply 'vla-put-lineweight (list new-x (vla-get-lineweight x)))
(vl-catch-all-apply 'vla-put-material (list new-x (vla-get-material x)))
(vl-catch-all-apply 'vla-put-plotstylename (list new-x (vla-get-plotstylename x)))
(vl-catch-all-apply 'vla-put-truecolor (list new-x (vla-get-truecolor x)))
(vl-catch-all-apply 'vla-put-visible (list new-x (vla-get-visible x)))
(vl-catch-all-apply 'vla-delete (list x))
); progn
); if
); foreach
); progn
); if
); defun
Unfortunately, this will work (more-or-less) properly only for 3d-rotated ellipses which have been rotated around either the major or minor axis. If the axis of rotation is not parallel to one of the axes of the ellipse, the apparent shape no longer corresponds to an ellipse, and the new one created by this routine will not be a visual match.
If there is anything usefull you can cull from this, though, you are welcome to it.