Jump to content

Recommended Posts

Posted

If I have two polylines that won't join via MPEDIT, is there a way to select the two endpoints that are near and nonjoining, and have them move to the midpoint between them? I have just learned of m2p today, and have been trying to figure a way to utilize it in this fashion.

 

I can easily stretch one end point to m2p, and then the other, but I'd like to automate it. I wish this an option for Pedit, Join.

Posted

Wouldn't it make more sense to move them to the intersecting point, not the midpoint between the two points?

Posted

The polylines in question are often parallel, or near parallel. An intersection, if it exists, could be far from the location intended/preferred.

Posted

Ahh, right on.

Shame they aren't Lines, you could use the old CHANGE command quite easily.

Posted

Thank you very much. I wasn't familiar with that, but will use it when the situation warrants it.

Posted

Wow! That is incredible, and quite a bit more complex than I figured it would be. Thank you very much, alanjt.

A few minutes, eh ??? Very Nice.

Posted (edited)

This could work on LWPOLYLINEs only:

 

[b][color=BLACK]([/color][/b]defun c:jlwp [b][color=FUCHSIA]([/color][/b]/ ss e1 e2 d1 d2 l1 l2 s1 s2 f1 f2 m1 m2 mp md[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]defun massoc [b][color=NAVY]([/color][/b]key alist / x nlist[b][color=NAVY])[/color][/b]
  [b][color=NAVY]([/color][/b]foreach x alist
    [b][color=MAROON]([/color][/b]if [b][color=GREEN]([/color][/b]eq key [b][color=BLUE]([/color][/b]car x[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
        [b][color=GREEN]([/color][/b]setq nlist [b][color=BLUE]([/color][/b]cons [b][color=RED]([/color][/b]cdr x[b][color=RED])[/color][/b] nlist[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
  [b][color=NAVY]([/color][/b]reverse nlist[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget '[b][color=GREEN]([/color][/b][b][color=BLUE]([/color][/b]0 . [color=#2f4f4f]"LWPOLYLINE"[/color][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
      [b][color=NAVY]([/color][/b]= [b][color=MAROON]([/color][/b]sslength ss[b][color=MAROON])[/color][/b] 2[b][color=NAVY])[/color][/b]
      [b][color=NAVY]([/color][/b]setq e1 [b][color=MAROON]([/color][/b]ssname ss 0[b][color=MAROON])[/color][/b]  e2 [b][color=MAROON]([/color][/b]ssname ss 1[b][color=MAROON])[/color][/b]
            d1 [b][color=MAROON]([/color][/b]entget e1[b][color=MAROON])[/color][/b]    d2 [b][color=MAROON]([/color][/b]entget e2[b][color=MAROON])[/color][/b]
            l1 [b][color=MAROON]([/color][/b]massoc 10 d1[b][color=MAROON])[/color][/b] l2 [b][color=MAROON]([/color][/b]massoc 10 d2[b][color=MAROON])[/color][/b]
            s1 [b][color=MAROON]([/color][/b]car l1[b][color=MAROON])[/color][/b]       s2 [b][color=MAROON]([/color][/b]car l2[b][color=MAROON])[/color][/b]
            f1 [b][color=MAROON]([/color][/b]last l1[b][color=MAROON])[/color][/b]      f2 [b][color=MAROON]([/color][/b]last l2[b][color=MAROON])[/color][/b]
            md [b][color=MAROON]([/color][/b]1+ [b][color=GREEN]([/color][/b]distance s1 s2[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
      [b][color=NAVY]([/color][/b]foreach v [b][color=MAROON]([/color][/b]list s1 f1[b][color=MAROON])[/color][/b]
         [b][color=MAROON]([/color][/b]foreach p [b][color=GREEN]([/color][/b]list s2 f2[b][color=GREEN])[/color][/b]
            [b][color=GREEN]([/color][/b]if [b][color=BLUE]([/color][/b]<= [b][color=RED]([/color][/b]distance v p[b][color=RED])[/color][/b] md[b][color=BLUE])[/color][/b]
                [b][color=BLUE]([/color][/b]setq md [b][color=RED]([/color][/b]distance v p[b][color=RED])[/color][/b] m1 v m2 p[b][color=BLUE])[/color][/b] T[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
      [b][color=NAVY]([/color][/b]setq mp [b][color=MAROON]([/color][/b]mapcar '[b][color=GREEN]([/color][/b]lambda [b][color=BLUE]([/color][/b]a b[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]* [b][color=RED]([/color][/b]+ a b[b][color=RED])[/color][/b] 0.5[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] m1 m2[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
      [b][color=NAVY]([/color][/b]entmod [b][color=MAROON]([/color][/b]subst [b][color=GREEN]([/color][/b]cons 10 mp[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]cons 10 m1[b][color=GREEN])[/color][/b] d1[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
      [b][color=NAVY]([/color][/b]entmod [b][color=MAROON]([/color][/b]subst [b][color=GREEN]([/color][/b]cons 10 mp[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]cons 10 m2[b][color=GREEN])[/color][/b] d2[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
  [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

 

-David

Edited by David Bethel
localized mp
Posted
Nicely done David. :)

 

 

Thanks We should probably both have filtered out PLINEs with bulges either in the first or last segment or closed PLINEs. I'm pretty sure they would give false results in that scenario. -David

Posted
Thanks We should probably both have filtered out PLINEs with bulges either in the first or last segment or closed PLINEs. I'm pretty sure they would give false results in that scenario. -David

Excellent point. The bulge doesn't really bother me, but I did forget to filter out closed plines. Thanks David.

 

Code updated.

JoinTwoLinesAtMidPoint.LSP

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...