Visual LISP, AutoLISP and General Customization

Reply
*Krous, Mike
Message 1 of 8 (102 Views)

Circle to lwpline problems

102 Views, 7 Replies
09-11-2003 05:33 AM
I am trying to convert a circle entity to a lwpline entity so it may be used
by a routine that only likes plines...I am having problems converting from
the circle information to lwpline information. My script takes a circle and
converts it to an lwpline...anyone know where im going wrong? It works
sometimes but alot of the time it just gives me odd shaped arcs.

(edata holds a circle entity, ename holds the entity name)
...
(setq cenPt (getdxf 10 edata))
;get centerpoint
(setq rad (getdxf 40 edata))
;get radius
(setq startPt (polar cenPt 0 rad))
;get the point at 0 degrees
(setq endPt (polar cenPt pi rad))
;get the point at 180 degrees
(command "pline" startPt "a" "ce" cenPt endPt "")
;draw a pline from 0 degrees to 180 degrees
(setq ent1 (entlast))
;get our newly created entity for later join to ent2
(command "pline" endPt "a" "ce" cenPt startPt "")
;draw a pline from 180 degrees to 0 degrees
(setq ent2 (entlast))
;get our newly created entity for later join to ent1
(command "pedit" ent1 "j" ent2 "" "")
;join ent1 and ent2 to create our new "pline-circle"
(entdel ename)
;get rid of the original circle
...
;---------------------------------------------------------------------------
----------
(defun getdxf (dxfcode ent)
(cdr (assoc dxfcode ent))
)

All suggestions are appreciated.

Mike Krous
*Piercey, Jason
Message 2 of 8 (102 Views)

Re: Circle to lwpline problems

09-11-2003 05:33 AM in reply to: *Krous, Mike
Here is one that I wrote a couple of years ago.

--

-Jason
Member of the Autodesk Discussion Forum Moderator Program


"Mike Krous" wrote in message
news:481562ECCE908A2CE13124B7FE45E8C4@in.WebX.maYIadrTaRb...
> I am trying to convert a circle entity to a lwpline entity so it may be used
> by a routine that only likes plines...I am having problems converting from
> the circle information to lwpline information.
*morawetz, ruul
Message 3 of 8 (102 Views)

Re: Circle to lwpline problems

09-11-2003 05:34 AM in reply to: *Krous, Mike
Hi Mike,
I'm lazy and like sweets. Therefore DONUTs mustn't be ignored ;-)

;circle 2 pline - ruul 03/09/11
(defun c:c2p ( / ent eli cd pc)
(cond
((null (setq ent (entsel))))
((/= "CIRCLE" (cdr (assoc 0 (setq eli (entget (setq ent (car
ent))))))))
(T
(setq cd (* 2.0 (cdr (assoc 40 eli)))
pc (cdr (assoc 10 eli)))
(command "_donut" cd cd pc ^C)
(entdel ent)
)
)
(prin1)
)


On 11.09.2003 22:33 Mike Krous wrote:

[... a lot ...]

>All suggestions are appreciated.
>
>Mike Krous
>

ok, you got one here
;^)

--
ruul
*Krous, Mike
Message 4 of 8 (102 Views)

Re:

09-12-2003 04:38 AM in reply to: *Krous, Mike
Thanks for the reply jason, I tried your routine and it works like one
should...thank you very much...

Mike Krous

"Jason Piercey" wrote in message
news:3BCD499F238A930D6B7EB8B10E6D7501@in.WebX.maYIadrTaRb...
> Here is one that I wrote a couple of years ago.
>
> --
>
> -Jason
> Member of the Autodesk Discussion Forum Moderator Program
>
>
> "Mike Krous" wrote in message
> news:481562ECCE908A2CE13124B7FE45E8C4@in.WebX.maYIadrTaRb...
> > I am trying to convert a circle entity to a lwpline entity so it may be
used
> > by a routine that only likes plines...I am having problems converting
from
> > the circle information to lwpline information.
>
>


----------------------------------------------------------------------------
----


;Written By: Jason Piercey 07.31.01
;Revised: 01.16.02 To handle multiple selection

(defun C:Circle2Pline (/ CirEnt CirElst CirCen CirRad CirLay
CirLin CirClr CirLts PlineEnt ss
i );ss1)

(setq ss (ssget '((0 . "CIRCLE"))))
(if ss
(progn
(setq i 0 );ss1 (ssadd))
(repeat (sslength ss)
(setq CirEnt (ssname ss i)
CirElst (entget CirEnt)
CirCen (cdr (assoc 10 CirElst))
CirRad (cdr (assoc 40 CirElst))
CirLay (cdr (assoc 8 CirElst))
CirLin (cdr (assoc 6 CirElst))
CirClr (cdr (assoc 62 CirElst))
CirLts (cdr (assoc 48 CirElst))
)

(setq PlineEnt (list '(0 . "LWPOLYLINE")
'(100 . "AcDbEntity")
(cons 8 CirLay)
'(100 . "AcDbPolyline")
'(90 . 2)
'(70 . 1)
'(43 . 0.0)
'(38 . 0.0)
'(39 . 0.0)
(cons 10 (polar CirCen (* pi) CirRad))
'(40 . 0.0)
'(41 . 0.0)
'(42 . 1.0)
(cons 10 (polar CirCen (* pi 2.0) CirRad))
'(40 . 0.0)
'(41 . 0.0)
'(42 . 1.0)
'(210 0.0 0.0 1.0)
)
)

(if CirLin (setq PlineEnt (append PlineEnt (list (cons 6
CirLin)))))
(if CirClr (setq PlineEnt (append PlineEnt (list (cons 62
CirClr)))))
(if CirLts (setq PlineEnt (append PlineEnt (list (cons 48
CirLts)))))
(entmake PlineEnt)
(entdel CirEnt)
(setq i (1+ i))
)
)
)
;(ssget "p")
(princ (strcat "\n"(itoa i) " Circles converted to LwPolylines"))
(princ)
)
*Krous, Mike
Message 5 of 8 (102 Views)

Re:

09-12-2003 04:40 AM in reply to: *Krous, Mike
Thanks for the reply ruul, Jasons's post was a little faster for me to
decipher, thanks again..

Mike Krous

"ruul morawetz" wrote in message
news:97FF9AAD68941430540956DED72B560A@in.WebX.maYIadrTaRb...
> Hi Mike,
> I'm lazy and like sweets. Therefore DONUTs mustn't be ignored ;-)
>
> ;circle 2 pline - ruul 03/09/11
> (defun c:c2p ( / ent eli cd pc)
> (cond
> ((null (setq ent (entsel))))
> ((/= "CIRCLE" (cdr (assoc 0 (setq eli (entget (setq ent (car
> ent))))))))
> (T
> (setq cd (* 2.0 (cdr (assoc 40 eli)))
> pc (cdr (assoc 10 eli)))
> (command "_donut" cd cd pc ^C)
> (entdel ent)
> )
> )
> (prin1)
> )
>
>
> On 11.09.2003 22:33 Mike Krous wrote:
>
> [... a lot ...]
>
> >All suggestions are appreciated.
> >
> >Mike Krous
> >
>
> ok, you got one here
> ;^)
>
> --
> ruul
>
*Piercey, Jason
Message 6 of 8 (102 Views)

Re:

09-12-2003 05:11 AM in reply to: *Krous, Mike
You're welcome.

--

-Jason
Member of the Autodesk Discussion Forum Moderator Program


"Mike Krous" wrote in message
news:66B13D32977354DF0F6B5F8A98135678@in.WebX.maYIadrTaRb...
> Thanks for the reply jason, I tried your routine and it works like one
> should...thank you very much...
*morawetz, ruul
Message 7 of 8 (102 Views)

Re:

09-14-2003 05:38 AM in reply to: *Krous, Mike
On 12.09.2003 21:40 Mike Krous wrote:

>Thanks for the reply ruul, Jasons's post was a little faster for me to
>decipher, thanks again..
>
>
>
Don't worry, if you don't want the DONUTs I eat 'em myself ;-)

Of course when trying to avoid the command function Jason's method for
sure is one to go.

OTOH I try to let AutoCAD do as much as possible ;-)
and a DONUT creates a POLYLINE in the shape of a circle.

The type of the polyline is dependant on the PLINETYPE setting.

>Mike Krous
>
>

--
ruul
Contributor
Posts: 18
Registered: ‎12-13-2006
Message 8 of 8 (102 Views)

Re: Circle to lwpline problems

08-08-2007 11:40 AM in reply to: *Krous, Mike
wonderful routine it works great!!!

thanks

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you interested in helping shape the Autodesk Community?
We’re looking at a few different ways to improve the “All Forums” landing page and need your feedback! If interested, please take a few minutes to fill out the following Usability Study. Thank you for your time!

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community