PDA

View Full Version : Circle to polyline



sid.fontenot550
2006-05-08, 06:51 PM
This seems so easy but I don't remember.
Can you change a circle to a polyline so you can add a width to it?
My user does not want to use a donut.

Wanderer
2006-05-08, 06:56 PM
does Circle as a Polyline (http://forums.augi.com/showthread.php?t=14477)help you?


~says the girl who pities those who don't have MAP cleanup tools~

This seems so easy but I don't remember.
Can you change a circle to a polyline so you can add a width to it?
My user does not want to use a donut.

Opie
2006-05-08, 07:00 PM
This seems so easy but I don't remember.
Can you change a circle to a polyline so you can add a width to it?
My user does not want to use a donut.
What does your user think a donut is? ;)

sid.fontenot550
2006-05-08, 07:02 PM
does Circle as a Polyline (http://forums.augi.com/showthread.php?t=14477)help you?


~says the girl who pities those who don't have MAP cleanup tools~

~sigh~ Why would they put that in Map and not in vanilla Autocad? Thanks Pony.

jaberwok
2006-05-08, 07:02 PM
Wouldn't it be nice to be able to specify a donut by mean diameter and width?
There obviously is a demand.

sid.fontenot550
2006-05-08, 07:03 PM
What does your user think a donut is? ;)

He's an engineer ~sigh~

sid.fontenot550
2006-05-08, 07:04 PM
Wouldn't it be nice to be able to specify a donut by mean diameter and width?
There obviously is a demand.

You can but you have to calculate the inside and outside diameter.

jaberwok
2006-05-08, 07:05 PM
Wouldn't it be nice to be able to specify a donut by mean diameter and width?
There obviously is a demand.


You can but you have to calculate the inside and outside diameter.

Yes, you can't. My point exactly.

sid.fontenot550
2006-05-08, 07:08 PM
Yes, you can't. My point exactly.

Hey quit pointing, thats not nice.
I knew your point Brother John. I just wasn't sure if you knew that or not.

jaberwok
2006-05-08, 07:10 PM
:cool: Brother Sid.

Perhaps I should make a wish though I don't believe that it's not been asked for before.

Opie
2006-05-08, 07:18 PM
:cool: Brother Sid.

Perhaps I should make a wish though I don't believe that it's not been asked for before.
Brothers John and Sid, try this. ;) Let me know if you have any problems.

(defun C:CPOLY (/ ENTITY WIDTH DIAMETER INSIDEDIAMETER OUTSIDEDIAMETER CENTERPNT )
(command "_circle")
(while (> (getvar "cmdactive") 0)
(command PAUSE)
) ;end while
(setq ENTITY (entget (entlast)) ;_get the circle
WIDTH (getreal "\nSpecify width: ") ;_ Specify Polyline Width
DIAMETER (* 2 (cdr (assoc 40 ENTITY))) ;_ Select diameter of Circle
INSIDEDIAMETER (- DIAMETER WIDTH) ;_ Calculate Inside Diameter
OUTSIDEDIAMETER (+ DIAMETER WIDTH) ;_ Calculate Inside Diameter
CENTERPNT (cdr (assoc 10 ENTITY)) ;_ Select Center of Circle
)
(entdel (cdr (assoc -1 ENTITY)))
(command "donut" INSIDEDIAMETER OUTSIDEDIAMETER CENTERPNT "") ;_ Draw the donut
)

And no. I don't think it has been asked for.

Arben.Allaraj
2006-05-08, 07:22 PM
My think is that you should use "Pedit" command .

jaberwok
2006-05-08, 07:23 PM
Thanks Brother Richard. It's not something I use but I've saved it "in case". ;-)

Opie
2006-05-08, 07:23 PM
My think is that you should use "Pedit" command .
PEDIT does not convert a circle to a polyline.

Opie
2006-05-08, 07:24 PM
Thanks Brother Richard. It's not something I use but I've saved it "in case". ;-)
Neither do I, but it's there "just in case". ;)

jaberwok
2006-05-08, 07:28 PM
... no. I don't think it has been asked for.

In over 25 years? I'm surprised. :shock:

Opie
2006-05-08, 07:31 PM
In over 25 years? I'm surprised. :shock:
In the current AUGI wish (http://forums.augi.com/forumdisplay.php?f=246) list. :roll: ;)

BrenBren
2006-05-08, 08:02 PM
In the current AUGI wish (http://forums.augi.com/forumdisplay.php?f=246) list. :roll: ;)
Yea, somebody just submitted a wish for this though... wonder who it was ;)

jaberwok
2006-05-08, 08:37 PM
Yea, somebody just submitted a wish for this though... wonder who it was ;)

Wow. Who could that have been? ;-)

zoomharis
2006-05-08, 08:47 PM
Can you change a circle to a polyline so you can add a width to it?

You can do that if you REALLY want to do. Just break the circle in two different portions. Then using grips drag the end points of the arcs to the other to fill the gap. Use PEDIT command to join the two arcs. If you select the object, it will apprear like a circle. But if you list it, it will show the object name as 'LWPOLYLINE'. Now you can use PEDIT to change the width. We can wrap these steps into a Lisp or VBA Macro to cut down the tasks.

:)
har!s

Opie
2006-05-08, 09:21 PM
You can do that if you REALLY want to do. Just break the circle in two different portions. Then using grips drag the end points of the arcs to the other to fill the gap. Use PEDIT command to join the two arcs. If you select the object, it will apprear like a circle. But if you list it, it will show the object name as 'LWPOLYLINE'. Now you can use PEDIT to change the width. We can wrap these steps into a Lisp or VBA Macro to cut down the tasks.

:)
har!s
psst: har!s, keep reading

Mike.Perry
2006-05-08, 11:30 PM
This seems so easy but I don't remember.
Can you change a circle to a polyline so you can add a width to it?
My user does not want to use a donut.Hi

I realise I am late to the party, but have you seen this thread...

Circle width

Have a good one, Mike

zoomharis
2006-05-09, 02:17 PM
How about using BOUNDARY command with Polyline object type option?.It creates a closed circular polyline (LWPOLYLINE) provided there is no overlaping. Here is some code based on the idea.



Sub CircleToPline()
On Error Resume Next
Dim vPickPnt As Variant
Dim objCircle As AcadCircle
With ThisDrawing
.Utility.GetEntity objCircle, vPickPnt, "Select a circle to convert: "
If Err.Number = 0 Then
Dim strEntLyr, StrEntLType As String
Dim EntColor, vCenPnt As Variant
Dim strCommand As String
Dim dblStartWidth, dblEndwidth
Dim strCenPnt As String
Dim objPLine As AcadLWPolyline
Dim objSS As AcadSelectionSet
'|<-- Collect object properties for later use -->
With objCircle
strEntLyr = .Layer: StrEntLType = .Linetype: EntColor = .Color
End With
dblStartWidth = .Utility.GetReal("Enter polyline width <0>: ")
If IsEmpty(dblStartWidth) Then
dblStartWidth = 0
End If
dblEndwidth = dblStartWidth
vCenPnt = objCircle.Center
strCenPnt = Trim(str(vCenPnt(0))) & "," & Trim(str(vCenPnt(1)))
'|<-- Command sequence: -boundary <point> [advanced] [object type] [polyline]-->|
strCommand = "-boundary" & vbCr & strCenPnt & vbCr & "a" & vbCr & _
"o" & vbCr & "p" & vbCr & vbCr & vbCr
.SendCommand strCommand
Set objSS = .SelectionSets.Add("LastEnt")
objSS.Select acSelectionSetLast
Set objPLine = objSS(0)
'|<-- Set back the object properties -->|
With objPLine
.Layer = strEntLyr: .Linetype = StrEntLType: .Color = EntColor
End With
Dim i As Integer
For i = 0 To 1
objPLine.SetWidth i, dblStartWidth, dblEndwidth
Next
objCircle.Delete
objSS.Delete
ThisDrawing.Regen acActiveViewport
Else
.Utility.prompt "a circle must be selected...."
End If
End With
End Sub


I know that we have already discussed better options. Does anybody know how to create a boundary from a closed object programmatically without using the SendCommand procedure? Then this program can be improved a lot.

har!s

Opie
2006-05-09, 05:57 PM
How about using BOUNDARY command with Polyline object type option?.It creates a closed circular polyline (LWPOLYLINE) provided there is no overlaping. Here is some code based on the idea.



Sub CircleToPline()
On Error Resume Next
Dim vPickPnt As Variant
Dim objCircle As AcadCircle
With ThisDrawing
.Utility.GetEntity objCircle, vPickPnt, "Select a circle to convert: "
If Err.Number = 0 Then
Dim strEntLyr, StrEntLType As String
Dim EntColor, vCenPnt As Variant
Dim strCommand As String
Dim dblStartWidth, dblEndwidth
Dim strCenPnt As String
Dim objPLine As AcadLWPolyline
Dim objSS As AcadSelectionSet
'|<-- Collect object properties for later use -->
With objCircle
strEntLyr = .Layer: StrEntLType = .Linetype: EntColor = .Color
End With
dblStartWidth = .Utility.GetReal("Enter polyline width <0>: ")
If IsEmpty(dblStartWidth) Then
dblStartWidth = 0
End If
dblEndwidth = dblStartWidth
vCenPnt = objCircle.Center
strCenPnt = Trim(str(vCenPnt(0))) & "," & Trim(str(vCenPnt(1)))
'|<-- Command sequence: -boundary <point> [advanced] [object type] [polyline]-->|
strCommand = "-boundary" & vbCr & strCenPnt & vbCr & "a" & vbCr & _
"o" & vbCr & "p" & vbCr & vbCr & vbCr
.SendCommand strCommand
Set objSS = .SelectionSets.Add("LastEnt")
objSS.Select acSelectionSetLast
Set objPLine = objSS(0)
'|<-- Set back the object properties -->|
With objPLine
.Layer = strEntLyr: .Linetype = StrEntLType: .Color = EntColor
End With
Dim i As Integer
For i = 0 To 1
objPLine.SetWidth i, dblStartWidth, dblEndwidth
Next
objCircle.Delete
objSS.Delete
ThisDrawing.Regen acActiveViewport
Else
.Utility.prompt "a circle must be selected...."
End If
End With
End Sub


I know that we have already discussed better options. Does anybody know how to create a boundary from a closed object programmatically without using the SendCommand procedure? Then this program can be improved a lot.

har!s
That sure is an awful lot of code to draw a donut, but then again, so is mine.

zoomharis
2006-05-09, 07:38 PM
That sure is an awful lot of code to draw a donut, but then again, so is mine.
There is no object named 'Donut' listed in the AutoCAD Object Model :shock: . That means 'Donut' is only an alias used for 'Closed Polylines with Thickness'?. I wasted too much time on coding to save 'Closed Polyline' from Donut. Thanks Richarad,Now (only) I understood what were you taking about.

:)
har!s

andy.manninen
2006-05-09, 07:52 PM
There is no object named 'Donut' listed in the AutoCAD Object Model :shock: . That means 'Donut' is only an alias used for 'Closed Polylines with Thickness'?. I wasted too much time on coding to save 'Closed Polyline' from Donut. Thanks Richarad,Now (only) I understood what were you taking about.

:)
har!s

You goof balls!
Snip~
Donuts are filled rings or solid-filled circles that actually are closed polylines with width.
~Snip
right out of the help menu.....
:Cheers:

andy.manninen
2006-05-09, 07:56 PM
You goof balls!
Snip~
Donuts are filled rings or solid-filled circles that actually are closed polylines with width.
~Snip
right out of the help menu.....
:Cheers:

How about making a DONUT with an outside diameter and inside diameter that are the same, so that is the mean diameter. Then edit global width? :roll:
:Cheers:

zoomharis
2006-05-09, 08:28 PM
Snip~
Donuts are filled rings or solid-filled circles that actually are closed polylines with width.
~Snip

I think Autodesk should rename the 'DONUT' command to something like 'CPLINE' in order to avoid confusion ;)


How about making a DONUT with an outside diameter and inside diameter that are the same, so that is the mean diameter. Then edit global width? :roll:
:Cheers:
That sounds really nice. But we do have an almost similar method already existing here (http://forums.augi.com/showthread.php?p=335468#post335468)

andy.manninen
2006-05-09, 08:32 PM
That sounds really nice. But we do have an almost similar method already existing here (http://forums.augi.com/showthread.php?p=335468#post335468)

Thats true, although the donut command is inherent to autocad, they should just make an option to insert the donut with a certain diameter and width...

Wouldn't it be nice to be able to specify a donut by mean diameter and width?

jaberwok
2006-05-10, 12:19 PM
Here y'are. It's primitive but works -


;;; PCIRC.LSP by John A Bogie, FEL. ;;;
;;; May 2006 ;;;
;;; Asks for mean circle radius and ;;;
;;; width and draws a donut to suit. ;;;
;;; No error handling included. ;;;


(defun c:pcirc (/ meanrad meandia width od id)
(setq meanrad (getdist "Enter centreline radius:"))
(setq width (getdist "Enter Width:"))
(setq meandia (* 2 meanrad))
(Setq od (+ meandia width))
(setq id (- meandia width))
(command "donut" od id)
)