Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
*Expert Elite*
Kent1Cooper
Posts: 5,879
Registered: ‎09-13-2004
Message 1 of 24 (9,360 Views)

Circle to Polyline, circular Polyline to Circle

9360 Views, 23 Replies
05-25-2011 07:59 AM

I had occasion to want to convert a Circle to a circular Polyline [so I could give it width, but I can imagine other reasons to want to do that].  Since Pedit won't do that conversion with a Circle as it will with a Line or an Arc, I looked for a routine here [assuming I would need to do this again from time to time], that would do the conversion by a simple selection of the Circle, so I didn't have to go through all the steps needed to construct an equivalent Polyline over the Circle and then erase the Circle.  I found some things that were prior to the existence of Lightweight Polylines, and/or that didn't take into account different Coordinate Systems, or a locked Layer, or non-default overrides of color, linetype, etc.

 

So I made one, and while I was at it, made one to go the other way -- convert a circular Polyline (Donut) into a Circle.  [I also found something here to do that, but along with the shortcomings above, it also didn't quite determine whether the selected Polyline is actually circular in Donut-like fashion.]  The Polyline-to-Circle converter works with either heavy or lightweight circular Polylines, and if the selected one has a global non-zero width, the User gets the choice of whether to draw the Circle along the Polyline's center-line or along its inside or outside edge.  It even saves that choice to offer as a default on further use.

 

CirclePolylineSwap.lsp contains two commands:  C2P [= Circle To Polyline] and P2C [= Polyline To Circle].  I hope others will find them useful.

Kent Cooper
*Expert Elite*
Kent1Cooper
Posts: 5,879
Registered: ‎09-13-2004
Message 2 of 24 (9,251 Views)

Re: Circle to Polyline, circular Polyline to Circle

08-05-2011 09:06 AM in reply to: Kent1Cooper

Upgraded version.

 

The original didn't undo as you'd expect, which I've fixed.  There's nothing different about the operation of the commands.

Kent Cooper
*Expert Elite*
azrdgldr
Posts: 1,250
Registered: ‎01-09-2007
Message 3 of 24 (9,247 Views)

Re: Circle to Polyline, circular Polyline to Circle

08-05-2011 09:45 AM in reply to: Kent1Cooper

At first I was going to reply to use the donut command but I remembered that uses two arcs.

 

Drink some warm milk before you go to bed, then may you'd sleep and not program while you sleep. 

*Expert Elite*
Lee_Mac
Posts: 1,270
Registered: ‎12-29-2009
Message 4 of 24 (9,242 Views)

Re: Circle to Polyline, circular Polyline to Circle

08-05-2011 10:07 AM in reply to: Kent1Cooper

Hi Kent,

 

Nice work :smileyhappy:

 

A suggestion: you can use the following ssget mode to prompt for single selection (with behaviour akin to entsel), whilst excluding objects on locked layers:

 

(ssget "_+.:E:S:L")

 

Lee

Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)
Expert Elite
With Mathematics there is the possibility of perfect rigour, so why settle for less?
*Expert Elite*
azrdgldr
Posts: 1,250
Registered: ‎01-09-2007
Message 5 of 24 (9,244 Views)

Re: Circle to Polyline, circular Polyline to Circle

08-05-2011 10:15 AM in reply to: Kent1Cooper

Kent, Since you do your work in AutoCAD 2004.  I thought I saw this fix in the forums but I can't seem to find it.  Dual monitor system, is there a setting to control which monitor it "sits" in upon opening each time.  I have tried the usual float, move and maximize but if I exit the program and restart it reverts back to the way it was.

 

I know Civil3D 2011 and AutoCAD 2010 don't to this, they stay anchored where you put them, so no display driver issue in my opinion.

*Expert Elite*
Kent1Cooper
Posts: 5,879
Registered: ‎09-13-2004
Message 6 of 24 (9,237 Views)

Re: Circle to Polyline, circular Polyline to Circle

08-05-2011 12:02 PM in reply to: azrdgldr

azrdgldr wrote:

....Dual monitor system, is there a setting to control which monitor it "sits" in upon opening each time. ....


I can't help you there -- I only have a single monitor.

Kent Cooper
*Expert Elite*
Kent1Cooper
Posts: 5,879
Registered: ‎09-13-2004
Message 7 of 24 (9,237 Views)

Re: Circle to Polyline, circular Polyline to Circle

08-05-2011 12:09 PM in reply to: Lee_Mac

Lee_Mac wrote:

.... 

A suggestion: you can use the following ssget mode to prompt for single selection (with behaviour akin to entsel), whilst excluding objects on locked layers:

 

(ssget "_+.:E:S:L")

....


That looks potentially very useful.  But I can't find any documentation about use of the underscore or plus sign or period or :L parts of it in the AutoLISP Reference or AutoLISP Developer's Guide.  Can you explain what those parts do, whether the order of them matters, etc., or point me to something that does?

Kent Cooper
*Expert Elite*
azrdgldr
Posts: 1,250
Registered: ‎01-09-2007
Message 8 of 24 (9,226 Views)

Re: Circle to Polyline, circular Polyline to Circle

08-05-2011 12:56 PM in reply to: Kent1Cooper

Got this from the 2010 help files, if he is referencing 2012, there may be some new ones.  If you have 2004, their older. 

 

 

sel-method

A string that specifies the object selection method. Valid selection methods are

C Crossing selection.

CP Cpolygon selection (all objects crossing and inside of the specified polygon).

F Fence selection.

I Implied selection (objects selected while PICKFIRST is in effect).

L Last visible object added to the database.

P Last selection set created.

W Window selection.

WP WPolygon (all objects within the specified polygon).

X Entire database. If you specify the X selection method and do not provide a filter-list, ssget selects all entities in the database, including entities on layers that are off, frozen, and out of the visible screen.

:E Everything within the cursor's object selection pickbox.

:N Call ssnamex for additional information on container blocks and transformation matrices for any entities selected during the ssget operation. This additional information is available only for entities selected through graphical selection methods such as Window, Crossing, and point picks.

Unlike the other object selection methods, :N may return multiple entities with the same entity name in the selection set. For example, if the user selects a subentity of a complex entity such as a BlockReference, PolygonMesh, or old style polyline, ssget looks at the subentity that is selected when determining if it has already been selected. However, ssget actually adds the main entity (BlockReference, PolygonMesh, and so on) to the selection set. The result could be multiple entries with the same entity name in the selection set (each will have different subentity information for ssnamex to report).

:R Allows entities in a long transaction to be selected.

:smileyfrustrated: Allow single selection only.

:U Enables subentity selection. Cannot be combined with the duplicate (":smileyvery-happy:") or nested (":N") selection modes. In this mode, top-level entities are selected by default, but the user can attempt to select subentities by pressing the CTRL key while making the selection. This option is supported only with interactive selections, such as window, crossing, and polygon. It is not supported for all, filtered, or group selections.

:V Forces subentity selection. Treats all interactive, graphic selections performed by the user as subentity selections. The returned selection set contains subentities only. This option cannot be combined with the duplicate (":smileyvery-happy:") or nested (":N") selection modes. This option is supported only with interactive selections, such as window and crossing. It is not supported for all, filtered, or group selections.

pt1

 

*Expert Elite*
Lee_Mac
Posts: 1,270
Registered: ‎12-29-2009
Message 9 of 24 (9,219 Views)

Re: Circle to Polyline, circular Polyline to Circle

08-05-2011 05:08 PM in reply to: Kent1Cooper

Kent1Cooper wrote:

That looks potentially very useful.  But I can't find any documentation about use of the underscore or plus sign or period or :L parts of it in the AutoLISP Reference or AutoLISP Developer's Guide.  Can you explain what those parts do, whether the order of them matters, etc., or point me to something that does?


 The Help files don't document everything :smileywink:

 

Attached is my personal reference for ssget, using information collected from various places. Note that some modes do not work with all versions and some are temperamental - but I'll let you experiment for yourself.

 

Lee

Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)
Expert Elite
With Mathematics there is the possibility of perfect rigour, so why settle for less?
*Expert Elite*
Lee_Mac
Posts: 1,270
Registered: ‎12-29-2009
Message 10 of 24 (9,216 Views)

Re: Circle to Polyline, circular Polyline to Circle

08-05-2011 05:12 PM in reply to: Lee_Mac

BTW, what's with the smiley's appearing in code blocks? I thought that was exactly what the code blocks were meant to prevent happening?

Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)
Expert Elite
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.