Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Circle to lwpline problems

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
266 Views, 7 Replies

Circle to lwpline problems

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
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: Anonymous

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.
Message 3 of 8
Anonymous
in reply to: Anonymous

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
Message 4 of 8
Anonymous
in reply to: Anonymous

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)
)
Message 5 of 8
Anonymous
in reply to: Anonymous

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
>
Message 6 of 8
Anonymous
in reply to: Anonymous

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...
Message 7 of 8
Anonymous
in reply to: Anonymous

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
Message 8 of 8
Anonymous
in reply to: Anonymous

wonderful routine it works great!!!

thanks

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost