<?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: Calculating distance to intersection from start of the polylines in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/calculating-distance-to-intersection-from-start-of-the-polylines/m-p/10583799#M56329</link>
    <description>&lt;P&gt;Post DWG as well.&lt;/P&gt;
&lt;P&gt;What distance is measured in the second &lt;EM&gt;Distance to intersection&lt;/EM&gt; column?&lt;/P&gt;</description>
    <pubDate>Mon, 30 Aug 2021 06:44:37 GMT</pubDate>
    <dc:creator>ВeekeeCZ</dc:creator>
    <dc:date>2021-08-30T06:44:37Z</dc:date>
    <item>
      <title>Calculating distance to intersection from start of the polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/calculating-distance-to-intersection-from-start-of-the-polylines/m-p/10583723#M56328</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;I have this little problem which believe can be done with LISP program, but I have no idea how to make it.&lt;BR /&gt;&lt;BR /&gt;I would like to calculate distance from start of each of the selected polylines to the point where other polyline intersects.&amp;nbsp; Below is example of situation and part of the needed output to excel. The distance should be measured along the polyline's vertexes not the perpendicular (nearest) distance.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="eemelilamsijarvi_0-1630302314902.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/958760i140DC900639281AB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="eemelilamsijarvi_0-1630302314902.png" alt="eemelilamsijarvi_0-1630302314902.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="eemelilamsijarvi_1-1630302456412.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/958761iFF02991F56451C73/image-size/medium?v=v2&amp;amp;px=400" role="button" title="eemelilamsijarvi_1-1630302456412.png" alt="eemelilamsijarvi_1-1630302456412.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 06:03:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/calculating-distance-to-intersection-from-start-of-the-polylines/m-p/10583723#M56328</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-08-30T06:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating distance to intersection from start of the polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/calculating-distance-to-intersection-from-start-of-the-polylines/m-p/10583799#M56329</link>
      <description>&lt;P&gt;Post DWG as well.&lt;/P&gt;
&lt;P&gt;What distance is measured in the second &lt;EM&gt;Distance to intersection&lt;/EM&gt; column?&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 06:44:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/calculating-distance-to-intersection-from-start-of-the-polylines/m-p/10583799#M56329</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2021-08-30T06:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating distance to intersection from start of the polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/calculating-distance-to-intersection-from-start-of-the-polylines/m-p/10583824#M56330</link>
      <description>&lt;P&gt;Dwg attached below.&lt;BR /&gt;&lt;BR /&gt;The second measurement is (in the first row, for example) the distance from start of the polyline in layer B to polyline in layer A. Other way to put this: I need to know how long A travels when hitting B and how long B travels when hitting A. The measurements are "doubled" in the excel example, but it isn't necessary. I just figured out if LISP program is to measure every possible intersection it will list both A-&amp;gt;B and B-&amp;gt;A.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 06:59:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/calculating-distance-to-intersection-from-start-of-the-polylines/m-p/10583824#M56330</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-08-30T06:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating distance to intersection from start of the polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/calculating-distance-to-intersection-from-start-of-the-polylines/m-p/10583879#M56331</link>
      <description>&lt;P&gt;Two functions intersectwith and getpointatdist. Here is a start.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(defun c:distpt ( / obj1 obj2 intpt1 dist)
(setq obj1 (vlax-ename-&amp;gt;vla-object (car  (entsel "Pick main line/pline"))))
(setq obj2 (vlax-ename-&amp;gt;vla-object (car  (entsel "Pick crossing line/pline"))))
(setq intpt1 (vlax-invoke obj2 'intersectWith obj1 acExtendThisEntity))
(setq dist (vlax-curve-getdistatpoint obj1 intpt1))
(alert (strcat "Distance is " (rtos dist 2 2)))
(princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 07:25:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/calculating-distance-to-intersection-from-start-of-the-polylines/m-p/10583879#M56331</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2021-08-30T07:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating distance to intersection from start of the polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/calculating-distance-to-intersection-from-start-of-the-polylines/m-p/10583925#M56332</link>
      <description>&lt;P&gt;Ok.. this should do the trick.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(vl-load-com)

(defun c:ListPlineInters ( / *error* f LM:intersections s i o1 o2 j l)
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if f (close f))
    (princ))
  
  ;; Intersections  -  Lee Mac
  ;; Returns a list of all points of intersection between two objects
  ;; for the given intersection mode.
  ;; ob1,ob2 - [vla] VLA-Objects
  ;;     mod - [int] acextendoption enum of intersectwith method
  
  (defun LM:intersections ( ob1 ob2 mod / lst rtn )
    (if (and (vlax-method-applicable-p ob1 'intersectwith)
	     (vlax-method-applicable-p ob2 'intersectwith)
	     (setq lst (vlax-invoke ob1 'intersectwith ob2 mod)))
      (repeat (/ (length lst) 3)
	(setq rtn (cons (list (car lst) (cadr lst) (caddr lst)) rtn)
	      lst (cdddr lst))))
    (reverse rtn))
  
  ; -------------------------------------
  
  (if (setq s (ssget '((0 . "LWPOLYLINE,LINE"))))
    (repeat (setq i (sslength s))
      (setq o1 (vlax-ename-&amp;gt;vla-object (ssname s (setq i (1- i)))))
      (repeat (setq j (sslength s))
	(setq o2 (vlax-ename-&amp;gt;vla-object (ssname s (setq j (1- j)))))
	(if (and (not (equal o1 o2))
		 (setq l (LM:intersections o1 o2 acextendnone))
		 (or f
		     (and (setq f (open (strcat (getvar 'DWGPREFIX) "ListPlineInters.csv") "w"))
			  (write-line (write-line "Layer1;Dist1;Layer2;Dist2") f)))
		 )
	  (foreach x l
	    (write-line (write-line (strcat (vla-get-layer o1) ";" (rtos (vlax-curve-getdistatpoint o1 x) 2 1) ";" (vla-get-layer o2) ";" (rtos (vlax-curve-getdistatpoint o2 x) 2 1))) f))))))
  (*error* "end")
  )
&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Aug 2021 07:54:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/calculating-distance-to-intersection-from-start-of-the-polylines/m-p/10583925#M56332</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2021-08-30T07:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating distance to intersection from start of the polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/calculating-distance-to-intersection-from-start-of-the-polylines/m-p/10584125#M56333</link>
      <description>&lt;P&gt;Did some testing and this is exactly what I was looking for. Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 09:37:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/calculating-distance-to-intersection-from-start-of-the-polylines/m-p/10584125#M56333</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-08-30T09:37:47Z</dc:date>
    </item>
  </channel>
</rss>

