<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: lisp to draw line between the nearest vertex of 2 polylines in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12305765#M23061</link>
    <description>&lt;P&gt;that's perfect! Many thanks! I'll try to improve it, using it, step by step when and if necessary; but the first tests&amp;nbsp;were very satisfactory!&amp;nbsp;I will surelly keep you updated on future developments&lt;/P&gt;</description>
    <pubDate>Sat, 14 Oct 2023 07:35:18 GMT</pubDate>
    <dc:creator>almora92</dc:creator>
    <dc:date>2023-10-14T07:35:18Z</dc:date>
    <item>
      <title>lisp to draw line between the nearest vertex of 2 polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12302458#M23051</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;i'm ne&lt;SPAN&gt;w&amp;nbsp;with autolisp,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;i have a lot of couples of poly/3Dpoly&amp;nbsp;with the same vertex number (generally a poly/3dpoly is the horizontal an vertical offset of another poly/3dpoly): i need to draw all the lines that join all the vertex of the first polyline&amp;nbsp;with the nearest vertex of the other polyline.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Do you think it could be possible? do you have any tips for me?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;thanks a lot in advance&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2023 20:31:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12302458#M23051</guid>
      <dc:creator>almora92</dc:creator>
      <dc:date>2023-10-12T20:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: lisp to draw line between the nearest vertex of 2 polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12302487#M23052</link>
      <description>&lt;P&gt;It sounds quite possible, assuming the 2 Polylines in question are drawn in the same direction.&amp;nbsp; The likely approach would involve&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt; (vlax-curve-getPointAtParam)&lt;/FONT&gt; &lt;/STRONG&gt;&lt;/FONT&gt;functions [the vertices are at whole-number parameter values] with the same parameter value applied to both Polylines.&amp;nbsp; If they might possibly be drawn in opposite directions, that could be accounted for by a REVERSE command applied to one of them, or by counting the parameter values in opposite directions.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2023 20:44:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12302487#M23052</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2023-10-12T20:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: lisp to draw line between the nearest vertex of 2 polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12302752#M23053</link>
      <description>&lt;P&gt;Post a sample&amp;nbsp; dwg with a before and after.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2023 23:36:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12302752#M23053</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2023-10-12T23:36:10Z</dc:date>
    </item>
    <item>
      <title>Re: lisp to draw line between the nearest vertex of 2 polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12302856#M23054</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1750459"&gt;@almora92&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I started a challenge a while back to solve for the shortest distance between 2 polylines (which I think I won).&amp;nbsp; If you can find that, then maybe you can alter it to find the shortest distance between 2 vertices.&amp;nbsp; It may be that the&amp;nbsp;@closer function is the trick.&lt;/P&gt;
&lt;P&gt;If you (or @hak_vz) can't find it, I'll look into my bag of tricks.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2023 00:54:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12302856#M23054</guid>
      <dc:creator>john.uhden</dc:creator>
      <dc:date>2023-10-13T00:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: lisp to draw line between the nearest vertex of 2 polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12303239#M23055</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="before" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1278801i952DE851C97A9163/image-size/large?v=v2&amp;amp;px=999" role="button" title="before.jpg" alt="before" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;before&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="after" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1278802i275270FF94B711E6/image-size/large?v=v2&amp;amp;px=999" role="button" title="after.jpg" alt="after" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;after&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2023 06:27:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12303239#M23055</guid>
      <dc:creator>almora92</dc:creator>
      <dc:date>2023-10-13T06:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: lisp to draw line between the nearest vertex of 2 polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12303262#M23056</link>
      <description>&lt;P&gt;that's a simple example of what i need to do with multiple of these polylines. 'til now, in case of many polylines,&amp;nbsp; i solved the problem with excel, determining, for every vertex of a polyline, the nearest vertices of another polyline...but, obviously, it's a time-wasting and not so smart procedure;&amp;nbsp;&lt;SPAN class=""&gt;therefore I decided to try to program a lisp that would perform this task.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;my idea for the first step is that of a lisp that does this by selecting, one by one, the pairs of polylines on which to perform this operation. And then, if necessary, improve the lisp to do everything automatically by selecting all the n polylines in the drawing together&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2023 06:42:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12303262#M23056</guid>
      <dc:creator>almora92</dc:creator>
      <dc:date>2023-10-13T06:42:51Z</dc:date>
    </item>
    <item>
      <title>Re: lisp to draw line between the nearest vertex of 2 polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12304806#M23057</link>
      <description>&lt;P&gt;Are these pairs created in such a way that you can count on their &lt;EM&gt;start/end vertices aiming in the same direction&lt;/EM&gt; from their centers, so that if you go from the start of one to the start of the other, then from the second vertex of one to the second of the other, etc., you don't get this kind of thing?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Kent1Cooper_0-1697218433967.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1279100i28F669F6A18DE4A2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Kent1Cooper_0-1697218433967.png" alt="Kent1Cooper_0-1697218433967.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;If not, some kind of figuring would need to be done to determine which vertices to connect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT:&amp;nbsp; And come to think of it, even when the start points align, do they always &lt;EM&gt;progress in the same direction&lt;/EM&gt;, so you don't get this kind of thing?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Kent1Cooper_0-1697220839244.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1279116i0817A9888BBAC90A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Kent1Cooper_0-1697220839244.png" alt="Kent1Cooper_0-1697220839244.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2023 18:14:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12304806#M23057</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2023-10-13T18:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: lisp to draw line between the nearest vertex of 2 polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12305087#M23058</link>
      <description>&lt;P&gt;yes, can say that the polylines are always drawn in the same direction, so the green lines must be drawn between the i-vertex of polyline 1&amp;nbsp; and i-vertex of polyline 2&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2023 19:48:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12305087#M23058</guid>
      <dc:creator>almora92</dc:creator>
      <dc:date>2023-10-13T19:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: lisp to draw line between the nearest vertex of 2 polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12305180#M23059</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1750459"&gt;@almora92&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Wait a second.&amp;nbsp; You stated to the &lt;U&gt;nearest&lt;/U&gt; vertex of the "other" polyline.&amp;nbsp; And unless one is offset from the other without being moved, then you stand a decent chance of getting different results depending on which you pick first.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2023 20:46:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12305180#M23059</guid>
      <dc:creator>john.uhden</dc:creator>
      <dc:date>2023-10-13T20:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: lisp to draw line between the nearest vertex of 2 polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12305542#M23060</link>
      <description>&lt;P&gt;This is very rough and expects the 2 objects to be 3dplines. Really need some true samples to test properly. You need to be in a 3d view so can pick 2 objects. Like others expects that the plines go in same direction. Very much a 1st go.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SeaHaven_0-1697250832314.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1279217iB03E5347D1CEE932/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SeaHaven_0-1697250832314.png" alt="SeaHaven_0-1697250832314.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;; join 2 3dplines verticaly by vertices
; By AlanH Oct 2023

(defun c:wow ( / co-ords2xy obj pt1 pt2 x xyz)

; convert now to xyz
(defun co-ords2xy (xyz / i xy)
(setq co-ordsxy '())
(if (= xyz 2)
(progn
(setq I 0)
(repeat (/ (length co-ords) 2)
(setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) ))
(setq co-ordsxy (cons xy co-ordsxy))
(setq I (+ I 2))
)
)
)
(if (= xyz 3)
(progn
(setq I 0)
(repeat (/ (length co-ords) 3)
(setq xy (list (nth i co-ords)(nth (+ I 1) co-ords)(nth (+ I 2) co-ords) ))
(setq co-ordsxy (cons xy co-ordsxy))
(setq I (+ I 3))
)
)
)
(princ)
)


(setvar 'osnapz 0)
(setq obj (vlax-ename-&amp;gt;vla-object (car  (entsel "\nPick object 1 "))))
(setq co-ords (vlax-get obj 'coordinates))
(cond
  (( = (vla-get-objectname obj) "AcDb2dPolyline")(co-ords2xy 2))
  (( = (vla-get-objectname obj) "AcDb3dPolyline")(co-ords2xy 3))
)
(setq co-ords1 co-ordsxy)
(setq obj (vlax-ename-&amp;gt;vla-object (car  (entsel "\nPick object 2 "))))
(setq co-ords (vlax-get obj 'coordinates))
(cond 
  (( = (vla-get-objectname obj) "AcDb2dPolyline")(co-ords2xy 2))
  (( = (vla-get-objectname obj) "AcDb3dPolyline")(co-ords2xy 3))
)
(setq co-ords2 co-ordsxy)
(setq x 0)
(repeat (length co-ords1)
(setq pt1 (nth x co-ords1) pt2 (nth x co-ords2))
(command "line"  pt1 pt2 "")
(setq x (1+ x))
)
(princ)
)
(c:wow)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Oct 2023 02:36:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12305542#M23060</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2023-10-14T02:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: lisp to draw line between the nearest vertex of 2 polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12305765#M23061</link>
      <description>&lt;P&gt;that's perfect! Many thanks! I'll try to improve it, using it, step by step when and if necessary; but the first tests&amp;nbsp;were very satisfactory!&amp;nbsp;I will surelly keep you updated on future developments&lt;/P&gt;</description>
      <pubDate>Sat, 14 Oct 2023 07:35:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12305765#M23061</guid>
      <dc:creator>almora92</dc:creator>
      <dc:date>2023-10-14T07:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: lisp to draw line between the nearest vertex of 2 polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12306477#M23062</link>
      <description>&lt;P&gt;direction of polylines doesn't matter. elevation adds as z coordinate to lw and 2d plines.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;;*************************************************************************************************************************************************************************

(defun get_vertices (ename / vertices_list index elevation object)
  (setq index -1
	elevation (cdr (assoc 38 (entget ename)))
	object (vlax-ename-&amp;gt;vla-object ename) 
  )
  (repeat (if (minusp (vlax-get object 'closed)) (fix (vlax-curve-getendparam ename)) (1+ (fix (vlax-curve-getendparam ename))))
    (setq vertices_list (append vertices_list (list (vlax-safearray-&amp;gt;list (vlax-variant-value (vla-get-coordinate object (setq index (1+ index))))))))
  )
  (if elevation (mapcar '(lambda (vertex) (append vertex (list elevation))) vertices_list) vertices_list)
)

;*************************************************************************************************************************************************************************

(defun c:closest_vertices_lines (/ vertices_list_1 vertices_list_2)
	(setq vertices_list_1 (get_vertices (car (entsel "\nPolyline 1: ")))
	      vertices_list_2 (get_vertices (car (entsel "\nPolyline 2: ")))
	)
	(mapcar '(lambda (test_vertex)
			(vla-addline (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
		       		     (vlax-3d-point (nth (car (vl-sort-i (mapcar '(lambda (vertex) (distance test_vertex vertex))
										  vertices_list_2
									 )
								         '&amp;lt;
							      )
							 )
							 vertices_list_2
						    )
				     )
	  	                     (vlax-3d-point test_vertex)
			)
		   )
		  vertices_list_1
	)
  	(princ)
)

;*************************************************************************************************************************************************************************&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Oct 2023 20:43:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-line-between-the-nearest-vertex-of-2-polylines/m-p/12306477#M23062</guid>
      <dc:creator>komondormrex</dc:creator>
      <dc:date>2023-10-14T20:43:37Z</dc:date>
    </item>
  </channel>
</rss>

