Wanted: Ellipse to Arc routine

Discussion in 'AutoCAD' started by Matt W, Dec 15, 2004.

  1. Matt W

    Matt W Guest

    Does anyone have a routine to convert a portion of an ellipse to an arc?
    I need to join them together with plines to create an area for a take-off.

    Thanks in advance!
     
    Matt W, Dec 15, 2004
    #1
  2. You can avoid the approximation accuracy loss involved, and the
    conversion-to-arc process entirely, if you use Boundary to measure the
    enclosed area. If an ellipse (or partial ellipse, and I think if a spline)
    is part of the enclosure, it tells you it can't make a polyline boundary,
    and asks if you want to make a Region instead. Say yes, and the resulting
    Region will have an area you can use.
     
    Kent Cooper, AIA, Dec 15, 2004
    #2
  3. Matt W

    Matt W Guest

    I've tried that but I've got a huge area, with a lot of ellipses (or would
    that be ellipsi??) and it can't always find a valid boundary, so I'd like to
    convert them to arcs, then use PEDIT with a fuzz factor to join them all.

    Got anything I can "borrow"??
     
    Matt W, Dec 15, 2004
    #3
  4. I have a vague recollection of a system variable or something that would let
    you draw ellipses as they used to be done years back (the ellipse command
    originally made multiple-polyline-arc approximations instead of true
    ellipses). But I can't find it in help. Maybe it used to be there and
    isn't any more.
     
    Kent Cooper, AIA, Dec 15, 2004
    #4
  5. Matt W

    Paul Turvill Guest

    If you set the PELLIPSE variable to 1 before drawing your ellipses, they
    will by approximated by polylines, which may then be trimmed, PEDITed and
    joined to other lines/polylines as needed.
    ___
     
    Paul Turvill, Dec 16, 2004
    #5
  6. Matt W

    Matt W Guest

    Thanks for that tid-bit of information but it doesn't help me now.
    They were drawn by somebody else unfortunately.


    Thanks anyways.
     
    Matt W, Dec 16, 2004
    #6
  7. Matt W

    T.Willey Guest

    So then just make a routine to redraw all the ellipse after setting the variable as it needs.

    Tim
     
    T.Willey, Dec 16, 2004
    #7
  8. Matt W

    Matt W Guest

    I'd love to, however, time does not allow hence the reason I was asking if
    anyone already had one that he/she would like to share.
     
    Matt W, Dec 16, 2004
    #8
  9. Matt W

    BillZ Guest

    Are these all on the WCS?
     
    BillZ, Dec 16, 2004
    #9
  10. Matt W

    T.Willey Guest

    See if this works for you. This will change all ellipse. If you want you can modify to only change one's selected.

    Tim

    (defun c:Ellipse2Spline (/ ActDoc BlkCol SpcList temp1)

    (setq ActDoc (vla-get-ActiveDocument (vlax-get-ACAD-Object)))
    (setq BlkCol (vla-get-Blocks ActDoc))
    (vlax-for item BlkCol
    (if (= (vla-get-IsLayout item) ':vlax-true)
    (setq SpcList (cons item SpcList))
    )
    )
    (foreach item SpcList
    (vlax-for item2 item
    (if (= (vla-get-ObjectName item2) "AcDbEllipse")
    (progn
    (setq temp1 (vlax-invoke-method item2 'Offset 0.001))
    (setq temp1 (car (safearray-value (variant-value temp1))))
    (vlax-invoke-method temp1 'Offset -0.001)
    (vla-delete temp1)
    (vla-delete item2)
    )
    )
    )
    )
    )
     
    T.Willey, Dec 16, 2004
    #10
  11. Matt W

    T.Willey Guest

    Ok... only took a second. Here is one that works with selection sets.

    Tim

    (defun c:ssEllipse2Spline (/ ss Ent Obj temp1)

    (setq ss (ssget '((0 . "ELLIPSE"))))
    (while (setq Ent (ssname ss 0))
    (setq Obj (vlax-ename->vla-object Ent))
    (setq temp1 (vlax-invoke-method Obj 'Offset 0.001))
    (setq temp1 (car (safearray-value (variant-value temp1))))
    (vlax-invoke-method temp1 'Offset -0.001)
    (vla-delete temp1)
    (vla-delete Obj)
    (ssdel Ent ss)
    )
    )
     
    T.Willey, Dec 16, 2004
    #11
  12. Matt W

    BillZ Guest

    This will turn ellipses to arcs.

    On partial ellipes you will have to trim to the lines.

    Code:
                 ;12/16/04 Bill Zondlo
    ;Program to read ellipse
    ;& create facsimle with
    ;a polyline ellipse.
    ;;
    ;;
    (defun c:Ellipse2Arcs (/ ent eli pt1 rp rt sp ep pt2 ds1 ang ds2 pt3 pst pstt an1 spt ept)
    ;-----------;
    (setvar "cmdecho" 0)
    (setq e 1)
    (while e
    (setq ent (car (entsel "\nSelect Ellipse: ")))                 ;select
    (if (or (null ent)                                            ;if missed pick
    (/= (cdr (assoc 0 (entget ent))) "ELLIPSE"))          ;or other entity.
    (prompt "\nNot an Ellipse")                           ;
    (setq e nil)                                          ;if a true ellipse.
    )                                                         ;end if
    )                                                              ;end while
    ;-----------;
    (setq eli (entget ent)
    pt1 (cdr (assoc 10 eli))                                ;center point.
    rp (cdr (assoc 11 eli))                                 ;major axis (relative to center)
    rt (cdr (assoc 40 eli))                                 ;ratio of major axis length.
    sp (cdr (assoc 41 eli))                                 ;start angle
    ep (cdr (assoc 42 eli))                                 ;end angle
    pt2 (list (+ (car pt1)(car rp))(+ (cadr pt1)(cadr rp))) ;major axis.
    ds1 (distance pt1 pt2)                                  ;major axis length.
    ang (angle pt1 pt2)                                     ;angle of ellipse
    ds2 (* ds1 rt)                                          ;minor axis length.
    pt3 (polar pt1 (+ ang (* pi 0.5)) ds2)
    )
    ;---;
    (setq pst (+ (car pt1)(* ds1 (cos sp)))                       ;formula
    pstt (+ (cadr pt1)(* ds2 (sin sp)))                     ;of ellipse from DXF group code.
    spt (list pst pstt)                                     ;point from center.
    an1  (angle pt1 spt)                                    ;angle from 0d.
    spt (polar pt1 (+ ang an1)(distance pt1 spt))           ;start point of ellipse.
    ;;;;
    pst (+ (car pt1)(* ds1 (cos ep)))                       ;formula
    pstt (+ (cadr pt1)(* ds2 (sin ep)))                     ;of ellipse
    ept (list pst pstt)                                     ;point from center.
    an1 (angle pt1 ept)                                     ;angle from 0d.
    ept (polar pt1 (+ ang an1)(distance pt1 ept))           ;end point of ellipse.
    )
    (setvar "pellipse" 1)
    (command "_.ellipse" "c" pt1 pt2 pt3)
    (command "_.explode" (entlast))
    (if (/= sp 0.0)
    (progn
    (command "_.line" pt1 spt "")  ;lines on partial arc ellipse start and end points to center.
    (command "_.line" pt1 ept "")
    )
    )
    (setvar "pellipse" 0)
    ;---;
    (entdel ent)                 ;add semi-colon to not delete original ellipse.
    ;---;
    (setvar "cmdecho" 1)
    (princ)
    )                                                      ;end defun
    Bill
     
    BillZ, Dec 16, 2004
    #12
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.