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

Lines to pline in one step

16 REPLIES 16
SOLVED
Reply
Message 1 of 17
jjorovi
8232 Views, 16 Replies

Lines to pline in one step

Hi!
Is there any routine to select multiple lines and convert them to form a single polyline without use join option in "pedit" command?
16 REPLIES 16
Message 2 of 17
john-B
in reply to: jjorovi

If you use the pedit command and then join, when ask to select the lines to be joined if you type 'ALL'

all valid lines will be joined to the first line picked. This sometimes give unexpected results if lines not wanted

in the polyline are valid.

Hope this is of some help

JohnB

Message 3 of 17
jjorovi
in reply to: john-B

Thanks for the adviceSmiley Happy but I want to know if there is a more direct method.

Message 4 of 17
Kent1Cooper
in reply to: jjorovi


@jjorovi wrote:
.... Is there any routine to select multiple lines and convert them to form a single polyline without use join option in "pedit" command?

Here's what I use -- PolylineJoin.lsp and its PJ command.  If you select one object, it joins everything it can to it [with the same possibility for unwanted results as mentioned by john-B, so make sure only things you want joined are contiguous to the selected object and to each other].  If you select multiple objects, it joins just those selected, into as many Polylines as it takes.  Works on not just Lines, but all Pedit-joinable entity types.

Kent Cooper, AIA
Message 5 of 17
jjorovi
in reply to: Kent1Cooper

It is much more than I expected.

Thank you very much Kent! Smiley Very Happy

 JohnnyJ

Message 6 of 17
Kent1Cooper
in reply to: jjorovi


@jjorovi wrote:

It is much more than I expected.

Thank you very much Kent!

 JohnnyJ


You're welcome [and thanks to beaufordt for the initial concept] -- I have found it very handy.  But I find there is one little "drawback," if you want to call it that.  When selecting multiple objects, if any of them are Lines or Arcs that don't connect at their ends to any other objects, and therefore can't be joined to anything, they still get turned into one-segment Polylines.  Often, I'd rather they were left as Lines or Arcs.  If I can find a way to have them left that way, I'll try to remember to come back here and post a revised routine.

Kent Cooper, AIA
Message 7 of 17
Kent1Cooper
in reply to: Kent1Cooper


Kent1Cooper wrote:

 

....  But I find there is one little "drawback," if you want to call it that.  When selecting multiple objects, if any of them are Lines or Arcs that don't connect at their ends to any other objects, and therefore can't be joined to anything, they still get turned into one-segment Polylines.  Often, I'd rather they were left as Lines or Arcs.  If I can find a way to have them left that way, I'll try to remember to come back here and post a revised routine.


I have worked that out, and also added error handling, and it accepts selection of 2D "heavy" Polylines, but only those that have not been spline- or fit-curved [because joining them to other things removes their curvature], but rejects 3D Polylines [which can't be joined].  There are also a few other small refinements, described in the code.

 

Also posted on this thread:

http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Silent-Pedit/m-p/3075520/highlight/fa...

where beaufordt's original concept first appeared, for those who may find the topic there.

Kent Cooper, AIA
Message 8 of 17

Great utility Kent. Thanks for that.
Message 9 of 17

Love this script, thank you @Kent1Cooper!

 

Could we get a version that just selects the objects it thinks should be joined, without joining them? That way you can see what all will be joined before running the join command. Sadly, I don't know enough autolisp to know if that would break the error handling.

Message 10 of 17


@PerryLackowski wrote:

.... Could we get a version that just selects the objects it thinks should be joined, without joining them? ....


I don't know of a way to do that other than to have it join them, then Explode the result and highlight the results of that, and ask whether you want to proceed.  The problem there is that if any of the source objects are multi-segment Polylines, they will become single Lines/Arcs, and if any are Polylines with any non-zero width(s), they will lose that.  The first problem could be solved by, if you choose not to go ahead, not simply stopping but Undoing.  The second one, if you choose to go ahead, I can't think of a way to get around, but maybe you would never need to.

 

I was hoping the FS Express Tool with FSMODE turned on could help, but that selects things of any object type that merely touch in any way, not restricted to end-to-end meetings of objects that could be joined.

 

But if any way of doing it occurs to me, I'll write back.

Kent Cooper, AIA
Message 11 of 17

Thanks Kent, I appreciate your response! Figured it wouldn't hurt to ask. I looked at the code a little closer, and I see now how it depends on the built-in joining from the PEDIT command. Either way, certainly better than manually selecting all the lines!

Message 12 of 17

It occurs to me that sometimes the need for a whether-to-go-ahead evaluation could be eliminated if you use LAYISO to show only the Layer(s) containing things you might want joined, before running the command.

Kent Cooper, AIA
Message 13 of 17
ВeekeeCZ
in reply to: jjorovi

See if THIS Lee's routine helps.

Message 14 of 17
PerryLackowski
in reply to: ВeekeeCZ

That's exactly what I had in mind @ВeekeeCZ , thank you!

Message 15 of 17
andelo523
in reply to: jjorovi

I got this.

 

Simply select the elements and type PJ in the command line. One of the first LISP's I've started using, and it helped me a lot since then. 😄👍

Message 16 of 17
ВeekeeCZ
in reply to: andelo523


@andelo523 wrote:

I got this.

 

Simply select the elements and type PJ in the command line. One of the first LISP's I've started using, and it helped me a lot since then. 😄👍


 

These days you can simply use the JOIN command instead. It's good enough.

Message 17 of 17
Kent1Cooper
in reply to: andelo523


@andelo523 wrote:

... select the elements and type PJ in the command line. .... 


That PJ command in Message 15 does one of the things that my PolylineJoin.lsp routine at Message 7 [which uses the same command name] does [and that the JOIN command will do in recent versions, as @ВeekeeCZ noted in Message 16].  BUT mine also has the feature that if you select only one object, it joins everything to it that can be joined, without your needing to select them all.  So you can [for example] change four Lines that form a rectangle into a closed Polyline by selecting only one of them.  It's that feature that @PerryLackowski in Message 9 wanted modified so that you could see what it found to join, and choose whether or not to go ahead with joining that group of objects.

Kent Cooper, AIA

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

Post to forums  

Autodesk Design & Make Report

”Boost