Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
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
@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.
@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.
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:
where beaufordt's original concept first appeared, for those who may find the topic there.
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.
@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.
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!
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.
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. 😄👍
@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.
@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.