Ellipse to Arc
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
Ellipse to Arc

 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization
Author Message
Adesu
Guest





Posted: Thu Dec 23, 2004 1:12 pm    Post subject: Ellipse to Arc Reply with quote

_$ (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

Back to top
BillZ
Guest





Posted: Thu Dec 23, 2004 6:41 pm    Post subject: Re: Ellipse to Arc Reply with quote

http://www.du.edu/~jcalvert/math/ellipse.htm

Merry Christmas!


Bill
Back to top
Adesu
Guest





Posted: Tue Dec 28, 2004 9:01 am    Post subject: Re: Ellipse to Arc Reply with quote

Thanks BillZ

BillZ <nospam@address.withheld> wrote in message
news:6504436.1103809303670.JavaMail.jive@jiveforum2.autodesk.com...
Quote:
http://www.du.edu/~jcalvert/math/ellipse.htm

Merry Christmas!


Bill


Back to top
Rogerio_Brazil
Guest





Posted: Tue Dec 28, 2004 3:52 pm    Post subject: Re: Ellipse to Arc Reply with quote

Try too:

http://www.jefferypsanders.com/autolispexp_enti.html#Ellipse

[]s,

Rogerio
Back to top
Rogerio_Brazil
Guest





Posted: Tue Dec 28, 2004 4:10 pm    Post subject: Re: Ellipse to Arc Reply with quote

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
Back to top
Rogerio_Brazil
Guest





Posted: Tue Dec 28, 2004 4:42 pm    Post subject: Re: Ellipse to Arc Reply with quote

Oops!

Use C:CLE.

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


Rogerio
Back to top
Adesu
Guest





Posted: Wed Dec 29, 2004 6:02 am    Post subject: Re: Ellipse to Arc Reply with quote

Thanks Rogerio
Rogerio_Brazil <nospam@address.withheld> wrote in message
news:33163548.1104231171650.JavaMail.jive@jiveforum1.autodesk.com...
Quote:
Try too:

http://www.jefferypsanders.com/autolispexp_enti.html#Ellipse

[]s,

Rogerio
Back to top
Adesu
Guest





Posted: Thu Dec 30, 2004 5:40 am    Post subject: Re: Ellipse to Arc Reply with quote

ELLIPSE - BEGIN
Quote:
(defun CLE (/ sel OSMODE RAD P1 CEN DIAM QY+ QY- QX+ QX- SS SEL INDEX QTDE
ENT E1)
(command "UNDO" "begin") >>>>>>>>???
--------------------------------------------------------snip
(setq QTDE (sslength SEL))
(command "undo" "begin") >>>>>>>>>???
--------------------------------------------------------snip
(setvar "osmode" OSMODE)
(command "UNDO" "end") >>>>>>>>>???
--------------------------------------------------------snip


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

Rogerio_Brazil <nospam@address.withheld> wrote in message
news:6826106.1104232247278.JavaMail.jive@jiveforum1.autodesk.com...
Quote:
Analise the routine:

Verify the angles ANG1 and ANG2.

;=================================================;;REPETIÃ?ÃfO -
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


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;
Quote:
(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
Back to top
Rogerio_Brazil
Guest





Posted: Thu Dec 30, 2004 7:04 am    Post subject: Re: Ellipse to Arc Reply with quote

Hello Adesu,

Error:

Quote:
(setq QTDE (sslength SEL))
(command "undo" "begin");;not here, my 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
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Contact Us
Powered by phpBB