+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 18
  1. #1
    Senior Member
    Using
    Civil 3D 2011
    Join Date
    Aug 2011
    Posts
    151

    Default Convert Ellipse to Arc

    Registered forum members do not see this ad.

    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!!


    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

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,368

    Default

    Hi Bill,

    I would be inclined to use the entmake(x) function for this task, as transference of object properties can be accomplished with a single function call.

    Here is my program:
    Code:
    ;; Ellipse 2 Arc  -  Lee Mac 2011  -  www.lee-mac.com
    ;; Converts Circular Ellipses (Axis Ratio = 1) to Circles/Arcs
    
    (defun c:e2a ( / e i s )
        (if (setq s (ssget "_:L" '((0 . "ELLIPSE") (40 . 1.0))))
            (repeat (setq i (sslength s))
                (setq e (entget (ssname s (setq i (1- i)))))
                (if
                    (entmakex
                        (if (equal (abs (- (cdr (assoc 42 e)) (cdr (assoc 41 e)))) (+ pi pi))
                            (apply 'append
                                (cons
                                    (list
                                        (cons 0 "CIRCLE")
                                        (cond ((assoc  6 e)) ('( 6 . "BYLAYER")))
                                        (cond ((assoc 39 e)) ('(39 . 0.0)))
                                        (cond ((assoc 62 e)) ('(62 . 256)))
                                        (cons 10 (trans (cdr (assoc 10 e)) 0 (cdr (assoc 210 e))))
                                        (cons 40 (distance '(0. 0. 0.) (cdr (assoc 11 e))))
                                    )
                                    (mapcar
                                        (function
                                            (lambda ( x )
                                                (if (not (member (car x) '(-1 0 5 6 10 11 39 40 41 42 62 100 330)))
                                                    (list x)
                                                )
                                            )
                                        )
                                        e
                                    )
                                )
                            )
                            (apply 'append
                                (cons
                                    (list
                                        (cons 0 "ARC")
                                        (cond ((assoc  6 e)) ('( 6 . "BYLAYER")))
                                        (cond ((assoc 39 e)) ('(39 . 0.0)))
                                        (cond ((assoc 62 e)) ('(62 . 256)))
                                        (cons 10 (trans (cdr (assoc 10 e)) 0 (cdr (assoc 210 e))))
                                        (cons 40 (distance '(0. 0. 0.) (cdr (assoc 11 e))))
                                        (cons 50 (+ (cdr (assoc 41 e)) (angle '(0. 0. 0.) (trans (cdr (assoc 11 e)) 0 1))))
                                        (cons 51 (+ (cdr (assoc 42 e)) (angle '(0. 0. 0.) (trans (cdr (assoc 11 e)) 0 1))))
                                    )
                                    (mapcar
                                        (function
                                            (lambda ( x )
                                                (if (not (member (car x) '(-1 0 5 6 10 11 39 40 41 42 62 100 330)))
                                                    (list x)
                                                )
                                            )
                                        )
                                        e
                                    )
                                )
                            )
                        )
                    )
                    (entdel (cdr (assoc -1 e)))
                )
            )
        )
        (princ)
    )
    Last edited by Lee Mac; 26th Aug 2011 at 12:01 am.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  3. #3
    Senior Member
    Using
    Civil 3D 2011
    Join Date
    Aug 2011
    Posts
    151

    Default

    Thanks for the reply!

    I tried your program, and it ends up doing the same as what I had. It replaces the ellipse with an arc based on the start and end angles, causeing the arc to be created in a different location than where the ellipse currently is. The properties of the new arc and the old Ellipse have the same start and end angles, but the arc is drawn as if it was rotated. I hope that makes sense.

    If the program could use the start and end points instead of the angles, I think it would work.

  4. #4
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,368

    Default

    Hi Bill,

    I missed something, try the updated code above
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  5. #5
    Senior Member
    Using
    Civil 3D 2011
    Join Date
    Aug 2011
    Posts
    151

    Default

    Lee Mac you are a genius! It works amazing. I cant thank you enough. You saved me lots time on here.

    Thanks again!!

  6. #6
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,368

    Default

    Thanks Bill, you're welcome
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  7. #7
    Senior Member
    Using
    Civil 3D 2011
    Join Date
    Aug 2011
    Posts
    151

    Default

    Just started using this lisp in 2014.

    For some reason it will not select any ellipse. I suspect it has to do with how 2014 creates the ellipse.

    Wonder if anyone else has encountered this, or if they have a different way to convert ellipses into arcs?

  8. #8
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,368

    Default

    Quote Originally Posted by Bill_Myron View Post
    For some reason it will not select any ellipse. I suspect it has to do with how 2014 creates the ellipse.
    Could you upload a sample drawing?
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  9. #9
    Super Member marko_ribar's Avatar
    Computer Details
    marko_ribar's Computer Details
    Operating System:
    Windows 7 Ultimate X64
    Computer:
    Intel quad core CPU 4x2.66GHz, 8GB RAM
    Motherboard:
    INTEL compatibile
    CPU:
    quad core 4x2.66GHz
    RAM:
    8GB
    Graphics:
    NVIDIA GeForce 6600 GT
    Primary Storage:
    250 GB
    Secondary Storage:
    500 GB
    Monitor:
    Samsung 17''
    Discipline
    Architectural
    marko_ribar's Discipline Details
    Occupation
    Architecture, project designer, project visualisation
    Discipline
    Architectural
    Details
    space design - modeling and animations
    Using
    AutoCAD 2014
    Join Date
    Feb 2010
    Location
    Belgrade, Serbia, Europe
    Posts
    1,233

    Default

    Quote Originally Posted by Bill_Myron View Post
    For some reason it will not select any ellipse. I suspect it has to do with how 2014 creates the ellipse.
    Lee's code is fine, but I suspect that you are attempting to select real ellipse and not circular one - in selection filter that follows (ssget) function it was explicitly written that ratio between "small" and "big" ellipse radius is 1.0 which means that ellipse must be circular in order for (ssget) function to accept selecting entities filtered by written filter statement that follows inside (ssget) function...

    Marko Ribar, d.i.a. (graduated engineer of architecture)
    M.R. on YouTube

  10. #10
    Senior Member
    Using
    Civil 3D 2011
    Join Date
    Aug 2011
    Posts
    151

    Default

    Registered forum members do not see this ad.

    Perhaps it may be some setting I have set.

    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.
    Attached Files

Similar Threads

  1. Convert Ellipse to Arcs
    By jammie in forum AutoLISP, Visual LISP & DCL
    Replies: 14
    Last Post: 27th Feb 2015, 10:05 pm
  2. How to convert LINE, ARC, SPLINE,ELLIPSE to POLYLINE
    By cadamrao in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 16th Jun 2010, 03:57 pm
  3. Ellipse Not Right
    By gsksun4 in forum AutoCAD Beginners' Area
    Replies: 2
    Last Post: 25th Mar 2010, 04:34 pm
  4. ellipse won't convert to polyline
    By zera in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 7
    Last Post: 17th Dec 2009, 09:19 pm
  5. Ellipse
    By johnengineer in forum AutoCAD Drawing Management & Output
    Replies: 6
    Last Post: 30th Mar 2007, 12:55 am

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts