Ellipse to Arc

Discussion in 'AutoCAD' started by Adesu, Dec 23, 2004.

  1. Adesu

    Adesu Guest

    _$ (setq ss (ssget))
    (setq ent (ssname ss 0))
    (setq dxf (entget ent))
    (setq ctrel (cdr (assoc 10 dxf)))
    (setq info11 (cdr (assoc 11 dxf)))
    (setq info11y (cadr info11))
    (setq majel (atof (rtos (car info11) 2 2)))
    (setq info40 (cdr (assoc 40 dxf)))
    (setq minel (atof (rtos (float (* majel info40))2 3)))
    (setq ang (angle ctrel info11))
    <Selection set: 41>
    <Entity name: 14842d0>
    ((-1 . <Entity name: 14842d0>) (0 . "ELLIPSE") (330 . <Entity name:
    14840f8>) (5 . "72") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0")
    (100 . "AcDbEllipse") (10 0.0 0.0 0.0) (11 5.0 0.0 0.0) (210 0.0 0.0 1.0)
    (40 . 0.5) (41 . 0.0) (42 . 6.28319))
    (0.0 0.0 0.0)
    (5.0 0.0 0.0)
    0.0
    5.0
    0.5
    2.5
    0.0
    _$ (setq p1 (polar ctrel (+ ang pi) majel))
    (setq p2 (polar ctrel (+ ang (/ pi 2)) minel))
    (setq p3 (polar ctrel (+ ang pi)(* 2 majel)))
    (-5.0 6.12303e-016 0.0) >>>> it must be (5.0
    0.0 0.0)
    (1.53076e-016 2.5 0.0) >>>> (0.0 2.5 0.0)
    (-10.0 1.22461e-015 0.0) >>>> (-10.0 0.0 0.0)
    _$

    I just create my code an ellipse to become arc,I've got problem it to
    determine angle,how to revise this code?,thanks
     
    Adesu, Dec 23, 2004
    #1
  2. Adesu

    BillZ Guest

    BillZ, Dec 23, 2004
    #2
  3. Adesu

    Adesu Guest

    Thanks BillZ
     
    Adesu, Dec 28, 2004
    #3
  4. Rogerio_Brazil, Dec 28, 2004
    #4
  5. Analise the routine:

    Verify the angles ANG1 and ANG2.

    ;=================================================;;REPETIÇÃO - CENTERLINE IN ELLIPSE - BEGIN
    (defun CLE (/ sel OSMODE RAD P1 CEN DIAM QY+ QY- QX+ QX- SS SEL INDEX QTDE ENT E1)
    (command "UNDO" "begin")
    ;(defun DTR (a)(* PI (/ a 180.0)))
    ; The dtr function converts degrees to radians
    (defun dtr (d)(* pi (/ d 180.0))) ; end defun dtr
    ; The rtd function converts radians to degrees
    (defun rtd (r)(/ (* r 180.0) pi)) ; end defun rtd
    (setq osmode (getvar "osmode"))
    (setvar "osmode" 0)
    (setvar "cmdecho" 0)
    (setq index 0)
    (IF (NOT (TBLSEARCH "LAYER" "CENTRO"))(COMMAND "LAYER" "M" "CENTRO" "C" "1" "" "L" "DASHDOT" "" "LW" "0.09" "" ""))
    (command "layer" "set" "centro" "")
    (princ "\n Centerline in Ellipses... ")
    (prompt "\n Select Ellipse(s):")
    (setq SEL (ssget))
    (if SEL
    (progn
    (setq QTDE (sslength SEL))
    (command "undo" "begin")
    (repeat QTDE
    (setq ENT (ssname SEL index))
    (setq E1 (entget ENT))
    (setq TIPO (strcase (cdr (assoc 0 E1))))
    (if TIPO
    (progn
    (setq centerPt(cdr(assoc 10 E1)))
    (setq endPt(cdr(assoc 11 E1)))

    (setq newPt
    (list
    (- (car centerPt)(car endPt))
    (- (cadr centerPt)(cadr endPt))
    )
    )

    (setq newPt+
    (list
    (+ (car centerPt)(car endPt))
    (+ (cadr centerPt)(cadr endPt))
    )
    )

    (setq SS (ssadd))
    (setq SS1 (ssadd))

    (command "line" newPt newPt+ "")
    (setq SS (ssadd (entlast) SS))

    (setq majorAxisLength(* 2.0 (distance centerPt newPt)))
    (setq minorAxisLength (* majorAxisLength (cdr(assoc 40 E1))))
    (setq 1/2minorAxisLength (* 0.5 majorAxisLength (cdr(assoc 40 E1))))

    (setq ANG (angle centerPt newPt))
    (setq ANG1 (+ ang (/ pi 2)));;preciso do oposto desse ângulo
    (setq ANG2 (- ang (/ pi 2)));;preciso do oposto desse ângulo

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (setq newPt1 (polar centerPt ANG1 1/2minorAxisLength))
    (setq newPt2 (polar centerPt ANG2 1/2minorAxisLength))

    (command "line" newPt1 newPt2 "")
    (setq SS1 (ssadd (entlast) SS1))

    ;=====================================

    (setq Fator1 1.1)
    (setq newmajorAxisLength (* majorAxisLength Fator1))
    (setq Fator2 (/ (+ newmajorAxisLength (* -1. majorAxisLength) minorAxisLength) minorAxisLength))
    ;=====================================
    (command "scale" SS "" centerPt Fator1)
    (command "scale" SS1 "" centerPt Fator2)
    (setq index (+ index 1))
    )
    )
    )
    )
    )
    ;===============================================
    (setvar "CLAYER" "0")
    (setvar "osmode" OSMODE)
    (command "UNDO" "end")
    (princ))

    Rogério
     
    Rogerio_Brazil, Dec 28, 2004
    #5
  6. Oops!

    Use C:CLE.

    (defun C:CLE (/ sel OSMODE RAD P1 CEN DIAM QY+ QY- QX+ QX- SS SEL INDEX QTDE ENT E1)


    Rogerio
     
    Rogerio_Brazil, Dec 28, 2004
    #6
  7. Adesu

    Adesu Guest

    Thanks Rogerio
     
    Adesu, Dec 29, 2004
    #7
  8. Adesu

    Adesu Guest

    ELLIPSE - BEGIN
    --------------------------------------------------------snip

    Hi Rogerio,what do you mean and fuction of "(command "undo"
    "begin")",thanks.

    "1" "" "L" "DASHDOT" "" "LW" "0.09" "" ""))
    minorAxisLength) minorAxisLength))
     
    Adesu, Dec 30, 2004
    #8
  9. Hello Adesu,

    Error:
    The function (command "undo" "begin") is written in the routine begin to mark the start of operations number, and
    (command "undo" "end") mark the end of operations.

    If you execute a command Undo after run the routine, all operations executed came back.


    (command "undo" "begin");;start of the routine
    .......
    ...all operations
    .........
    (command "undo" "end");;end of the routine

    If a comand Undo after run a routine, all operations came back.

    Try and verify. Run CLE, make a centerlines and after, type undo comando in command prompt of cad.

    All centerlines are removeds.

    []s,

    Rogerio
     
    Rogerio_Brazil, Dec 30, 2004
    #9
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.