Jump to content

Search the Community

Showing results for tags 'ellipse'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • CADTutor
    • News, Announcements & FAQ
    • Feedback
  • AutoCAD
    • AutoCAD Beginners' Area
    • AutoCAD 2D Drafting, Object Properties & Interface
    • AutoCAD Drawing Management & Output
    • AutoCAD 3D Modelling & Rendering
    • AutoCAD Vertical Products
    • AutoCAD LT
    • CAD Management
    • AutoCAD Bugs, Error Messages & Quirks
    • AutoCAD General
    • AutoCAD Blogs
  • AutoCAD Customization
    • The CUI, Hatches, Linetypes, Scripts & Macros
    • AutoLISP, Visual LISP & DCL
    • .NET, ObjectARX & VBA
    • Application Beta Testing
    • Application Archive
  • Other Autodesk Products
    • Autodesk 3ds Max
    • Autodesk Revit
    • Autodesk Inventor
    • Autodesk Software General
  • Other CAD Products
    • BricsCAD
    • SketchUp
    • Rhino
    • SolidWorks
    • MicroStation
    • Design Software
    • Catch All
  • Resources
    • Tutorials & Tips'n'Tricks
    • AutoCAD Museum
    • Blocks, Images, Models & Materials
    • Useful Links
  • Community
    • Introduce Yourself
    • Showcase
    • Work In Progress
    • Jobs & Training
    • Chat
    • Competitions

Categories

  • Programs and Scripts
  • 2D AutoCAD Blocks
  • 3D AutoCAD Blocks
  • Images
    • Backgrounds

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Found 5 results

  1. I am pretty new to lisp programming and have only been working in it for a few months and I am pretty stuck on how to get this lisp program I've hacked together into what I need. Any help would be greatly appreciated. I would like help optimizing the lisp to be more like autocad's save as an old dxf way of converting an ellipse to a polyline. The current way I am converting an ellipse to poly line is by moving a static degree of distance between each point, the way I cannot figure out and the ideal way for me to do this is by specifying the maximum gap between the true ellipse and the polyline version. I have looked at other lisp programs out there and they are not high resolution enough for what I need, I need the data to be extremely close to the actual ellipse. I would appreciate help in pointing me towards how to do this mathematically, help implement that into a lisp, and any tips on best practice lisp programming that I might be really messing up here. Below is the function I have written to handle this so far, it takes in el which is the vla ellipse object and angleIncrement which is the degree difference between two points of the polyline. In a perfect world the second argument would be changed to be the maximum distance between the true ellipse and the polyline version. This is a function used in another script that then chains the data and does a few other things as well. (defun EllipseToLine (el angleIncrement / majorradius minorradius startangle endangle startpoint endpoint centerpoint tempVar) (vl-load-com) (setvar "cmdecho" 0) (setq majorradius (vla-get-MajorRadius el)) (setq minorradius (vla-get-MinorRadius el)) (setq startangle (* (vla-get-StartAngle el) (/ 180 pi))) (setq endangle (* (vla-get-EndAngle el)(/ 180 pi))) (setq startpoint (vlax-safearray->list (vlax-variant-value (vla-get-startpoint el)))) (setq endpoint (vlax-safearray->list (vlax-variant-value (vla-get-endpoint el)))) (setq centerpoint (vlax-safearray->list (vlax-variant-value (vla-get-center el)))) (setq centerx (nth 0 centerpoint)) (setq centery (nth 1 centerpoint)) (princ "End angle: ")(princ endangle)(princ "\n") (princ "Start angle: ")(princ startangle)(princ "\n") (setq startx (nth 0 startpoint)) (setq starty (nth 1 startpoint)) (setq endx (nth 0 endpoint)) (setq endy (nth 1 endpoint)) ; make sure we convert the ellipse on the correct layer and then later return to the layer we were on (setq ellipseLayer (vla-get-layer el)) (setq currentLayer (getvar "clayer")) (setvar "clayer" ellipseLayer) ; calculate angle between start angle and start point because the start point ; is not at the start angle so we have to adjust so numbers match up (setq angleOffset (- (* (angle centerpoint startpoint) (/ 180 pi)) startangle)) (setq radianOffset (* angleOffset (/ pi 180))) ; a = major radius ; b = minor radius (setq ecc (sqrt (- 1 (/ (expt minorradius 2) (expt majorradius 2))))) (setq angleInverted 0) (setq done 0) (setq i 0) (setq currentAngle startangle) (setq nintyDegrees 90.0) (setq twoHundredSeventyDegrees 270.0) (while (= done 0) (if (< currentAngle 0) (progn (setq currentAngle (+ currentAngle 360)) (setq angleInverted 1) ) ) (if (> currentAngle 360) (progn (setq currentAngle (- currentAngle 360)) (setq angleInverted 1) ) ) (cond ((or (and (> startangle endangle) (= angleInverted 0)) (and (> endangle startangle) (= angleInverted 1))) (if (< currentAngle endangle) (setq currentAngle endangle) ) ) ((or (and (> endangle startangle) (= angleInverted 0)) (and (> startangle endangle) (= angleInverted 1))) (if (> currentAngle endangle) (setq currentAngle endangle) ) ) ) (setq newAngle currentAngle) (if (or (> newAngle 0) (< newAngle 0)) (setq newAngle (* newAngle (/ pi 180))) ) (setq factor -1) (if (or (<= currentAngle nintyDegrees) (>= currentAngle twoHundredSeventyDegrees)) (setq factor 1) ) ; using the origional un rotated angle get the next point on the ellipse (setq x2 (/ (* majorradius minorradius) (* factor (sqrt (+ (expt minorradius 2) (* (expt majorradius 2) (expt (/ (sin newAngle) (cos newAngle)) 2))))))) (setq y2 (* x2 (/ (sin newAngle) (cos newAngle)))) (setq x2 (+ x2 centerx) y2 (+ y2 centery) ) ; rotate point on the ellipse by radian/angle offset so it matches the cad data (setq rotatedx (+ (- (* (cos radianOffset) (- x2 centerx)) (* (sin radianOffset) (- y2 centery))) centerx)) (setq rotatedy (+ (+ (* (sin radianOffset) (- x2 centerx)) (* (cos radianOffset) (- y2 centery))) centery)) (setq x2 rotatedx y2 rotatedy ) (if (= currentAngle endangle) (setq done 1) ) (if (> i 0) (if (= i 1) (command "_.line" (strcat (rtos startx) "," (rtos starty)) (strcat (rtos x2) "," (rtos y2)) "") (if (= done 1) (command "_.line" (strcat (rtos x1) "," (rtos y1)) (strcat (rtos endx) "," (rtos endy)) "") (command "_.line" (strcat (rtos x1) "," (rtos y1)) (strcat (rtos x2) "," (rtos y2)) "") ) ) ) (setq x1 x2 y1 y2 ) (setq currentAngle (+ currentAngle angleIncrement) i (+ 1 i) ) ) ; delete the origional ellipse (vla-delete el) (setvar "clayer" currentLayer) (princ) )
  2. 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. Thanks in advance!! (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 [/Code]
  3. Hello, I need to join an ellipse to a circle then trim the ellipse but keep the whole thing joined. I know how to trim. But I can not join the trimmed to the circle. HELP!!!! Richard
  4. Hi CADmates, how is it possible to recognize an ellipse object is closed (i.e. full ellipse) or open (i.e ellipse arc)? Any reply appreciated.
  5. Bill_Myron

    Convert Ellipse to Arc

    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. Thanks in advance!! (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
×
×
  • Create New...