jammie Posted February 13, 2009 Share Posted February 13, 2009 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 (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 Quote Link to comment Share on other sites More sharing options...
JohnM Posted February 13, 2009 Share Posted February 13, 2009 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. Quote Link to comment Share on other sites More sharing options...
jammie Posted February 13, 2009 Author Share Posted February 13, 2009 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 Quote Link to comment Share on other sites More sharing options...
JohnM Posted February 13, 2009 Share Posted February 13, 2009 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 Quote Link to comment Share on other sites More sharing options...
jammie Posted February 13, 2009 Author Share Posted February 13, 2009 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 Quote Link to comment Share on other sites More sharing options...
fuccaro Posted February 13, 2009 Share Posted February 13, 2009 Jammie Click this link, maybe you can find something usefull on that page: http://www.cadtutor.net/forum/showthread.php?t=1639& Quote Link to comment Share on other sites More sharing options...
jammie Posted February 15, 2009 Author Share Posted February 15, 2009 JammieClick 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 Quote Link to comment Share on other sites More sharing options...
Adesu Posted February 16, 2009 Share Posted February 16, 2009 I think you look for like this 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 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 (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 Quote Link to comment Share on other sites More sharing options...
jammie Posted February 16, 2009 Author Share Posted February 16, 2009 I think you look for like this codeCode: (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 Quote Link to comment Share on other sites More sharing options...
Adesu Posted February 17, 2009 Share Posted February 17, 2009 Ahh....I very glad can help one. 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 Quote Link to comment Share on other sites More sharing options...
Nicusors Posted September 17, 2009 Share Posted September 17, 2009 If I'm not asking to much, could You convert that to vba? Thank You I think you look for like this 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 Quote Link to comment Share on other sites More sharing options...
RichardR Posted February 27, 2015 Share Posted February 27, 2015 I think you look for like this 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 When I ran this .lsp app, the end points do not match the original end points for the ellipse. Is there a quick fix in the code that will fix this? Thanks! Richard Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 27, 2015 Share Posted February 27, 2015 You could perhaps try my Ellipse to Arc program here. Lee Quote Link to comment Share on other sites More sharing options...
RichardR Posted February 27, 2015 Share Posted February 27, 2015 You could perhaps try my Ellipse to Arc program here. Lee Thank you, Lee Mac! Shortly after posting my question, I found that same link! Very helpful and exactly what I was looking for! Have a great day! Richard Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 27, 2015 Share Posted February 27, 2015 You're welcome Richard, glad it helps. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.