el_MI Posted October 3, 2011 Posted October 3, 2011 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. Quote
alanjt Posted October 3, 2011 Posted October 3, 2011 Wouldn't it make more sense to move them to the intersecting point, not the midpoint between the two points? Quote
el_MI Posted October 3, 2011 Author Posted October 3, 2011 The polylines in question are often parallel, or near parallel. An intersection, if it exists, could be far from the location intended/preferred. Quote
alanjt Posted October 3, 2011 Posted October 3, 2011 Ahh, right on. Shame they aren't Lines, you could use the old CHANGE command quite easily. Quote
el_MI Posted October 3, 2011 Author Posted October 3, 2011 Thank you very much. I wasn't familiar with that, but will use it when the situation warrants it. Quote
alanjt Posted October 3, 2011 Posted October 3, 2011 (edited) Had a few minutes and thought it'd be a bit of fun... EDIT: http://www.cadtutor.net/forum/showthread.php?63194-Move-endpoints-to-m2p&p=431251&viewfull=1#post431251 Edited October 4, 2011 by alanjt Quote
el_MI Posted October 4, 2011 Author Posted October 4, 2011 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. Quote
David Bethel Posted October 4, 2011 Posted October 4, 2011 (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 October 4, 2011 by David Bethel localized mp Quote
alanjt Posted October 4, 2011 Posted October 4, 2011 (edited) Minor update to account for locked layers and a minor mistake I made. EDIT: http://www.cadtutor.net/forum/showthread.php?63194-Move-endpoints-to-m2p&p=431264&viewfull=1#post431264 Edited October 4, 2011 by alanjt Quote
David Bethel Posted October 4, 2011 Posted October 4, 2011 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 Quote
alanjt Posted October 4, 2011 Posted October 4, 2011 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 Quote
Recommended Posts
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.