<?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: Find vertices of a selected line LISP in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-vertices-of-a-selected-line-lisp/m-p/6964263#M122095</link>
    <description>&lt;P&gt;A command approach would be as follows (An activeX approach would execute much faster):&lt;/P&gt;
&lt;PRE&gt;;;;Michael Puckett
(defun cdrs (key lst / pair rtn)
   (while (setq pair (assoc key lst))
      (setq rtn (cons (cdr pair) rtn)
         lst (cdr (member pair lst))
      )
   )
   (reverse rtn)
)
;;D.C. Broad - Basic demo draw circles at each selected polyline vertex.
(defun c:circlline ( / dia ss e ei)
  (setq dia (getdist "\nCircle diameter: "))
  (princ "\nSelect 2 polylines: ")
  (if (setq ss (ssget '((0 . "lwpolyline"))))
    (progn
      (command "._undo" "_begin")
      (repeat (min 2 (sslength ss))
	(setq e (ssname ss 0))
	(ssdel e ss)
	(setq ei (entget e))
	(mapcar	'(lambda (p)
		   (command "._circle" p "_d" dia)
		 )
		(cdrs 10 ei)
	)
      )
    )
  )
  (command "._undo" "_end")
  (princ)
)&lt;/PRE&gt;</description>
    <pubDate>Wed, 22 Mar 2017 12:49:17 GMT</pubDate>
    <dc:creator>dbroad</dc:creator>
    <dc:date>2017-03-22T12:49:17Z</dc:date>
    <item>
      <title>Find vertices of a selected line LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-vertices-of-a-selected-line-lisp/m-p/6962577#M122091</link>
      <description>&lt;P&gt;I have drawn four parallel lines with LISP and I am trying to make a function where the user can select 2 lines, the program finds the vertices of these lines and draw a circle with center point in each vertex. On the circle that should be drawn I know I can use (command "_circle" radius coordinates) but I do not know how to select the line and get the vertices.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(Defun test ()
(command "_.pline" '(130 200) '(200 200) "")&lt;BR /&gt; (command "_.pline" '(130 150) '(200 150) "")&lt;BR /&gt;(command "_.pline" '(130 100) '(200 100) "")&lt;BR /&gt;(command "_.pline" '(130 50) '(200 50) "") ")&lt;BR /&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2017 20:11:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-vertices-of-a-selected-line-lisp/m-p/6962577#M122091</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-21T20:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: Find vertices of a selected line LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-vertices-of-a-selected-line-lisp/m-p/6962721#M122092</link>
      <description>&lt;P&gt;There are several ways you can do that.&amp;nbsp; Here's one:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(Defun test (/ p1 p2)
  (command&lt;BR /&gt;    "_.pline" (setq p1 '(130 200)) (setq p2 '(200 200)) ""&lt;BR /&gt;    "_.circle" p1 &lt;EM&gt;&lt;FONT color="#00ccff"&gt;YourRadius&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;    "_.circle" p2 &lt;EM&gt;&lt;FONT color="#00ccff"&gt;YourRadius&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_.pline" (setq p1 '(130 150)) (setq p2 '(200 150)) ""&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_.circle" p1 &lt;EM&gt;&lt;FONT color="#00ccff"&gt;YourRadius&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_.circle" p2 &lt;EM&gt;&lt;FONT color="#00ccff"&gt;YourRadius&lt;/FONT&gt;&lt;/EM&gt;  &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_.pline" (setq p1 '(130 100)) (setq p2 '(200 100)) ""&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_.circle" p1 &lt;EM&gt;&lt;FONT color="#00ccff"&gt;YourRadius&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_.circle" p2 &lt;EM&gt;&lt;FONT color="#00ccff"&gt;YourRadius&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_.pline" (setq p1 '(130 50)) (setq p2 '(200 50)) ""&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_.circle" p1 &lt;EM&gt;&lt;FONT color="#00ccff"&gt;YourRadius&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_.circle" p2 &lt;EM&gt;&lt;FONT color="#00ccff"&gt;YourRadius&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;  ); command
); defun&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there some reason&amp;nbsp;they need to be &lt;STRONG&gt;P&lt;/STRONG&gt;lines, or would just &lt;EM&gt;Lines&lt;/EM&gt; do?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That assumes you have no running object snap modes in effect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff6600"&gt;&lt;STRONG&gt;EDIT:&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp; Here's another abbreviated version:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(Defun test (/ p1 p2)&lt;BR /&gt;  (foreach Y '(200 150 100 50)
    (command
      "_.pline" (setq p1 (list 130 Y)) (setq p2 (list 200 Y)) ""
      "_.circle" p1 &lt;EM&gt;&lt;FONT color="#00ccff"&gt;YourRadius&lt;/FONT&gt;&lt;/EM&gt;
      "_.circle" p2 &lt;EM&gt;&lt;FONT color="#00ccff"&gt;YourRadius&lt;/FONT&gt;&lt;/EM&gt;
    ); command&lt;BR /&gt;  ); foreach
); defun&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you really need it done somehow by selecting each (p)line and getting its vertices/endpoints &lt;EM&gt;after&lt;/EM&gt; drawing it, rather than by saving the points &lt;EM&gt;while&lt;/EM&gt; drawing the (p)lines and using those &lt;EM&gt;saved&lt;/EM&gt; points for the Circle centers:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(vl-load-com)&lt;BR /&gt;(Defun test ()
  (foreach Y '(200 150 100 50)
    (command
      "_.pline" (list 130 Y) (list 200 Y) ""
      "_.circle" (vlax-curve-getStartPoint (entlast)) &lt;EM&gt;&lt;FONT color="#00ccff"&gt;YourRadius
&lt;/FONT&gt;&lt;/EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_.circle" (vlax-curve-getEndPoint (entlast)) &lt;EM&gt;&lt;FONT color="#00ccff"&gt;YourRadius&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;    ); command
  ); foreach
); defun&lt;/PRE&gt;
&lt;P&gt;Also, should that be (defun &lt;STRONG&gt;C:&lt;/STRONG&gt;test ... ?&amp;nbsp; If you &lt;EM&gt;add&lt;/EM&gt; the C:, you can type just &lt;STRONG&gt;test&lt;/STRONG&gt; at the Command line; if not, you have to type &lt;STRONG&gt;(test)&lt;/STRONG&gt; &lt;EM&gt;with&lt;/EM&gt; the parentheses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2017 21:10:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-vertices-of-a-selected-line-lisp/m-p/6962721#M122092</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2017-03-21T21:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: Find vertices of a selected line LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-vertices-of-a-selected-line-lisp/m-p/6964047#M122093</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thanks, but the third code you wrote was so I could select the lines, right? Maybe I'm doing something wrong but it did not work here.&amp;nbsp;The four parallel lines only appear.&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class="_Ejb"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Wed, 22 Mar 2017 11:35:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-vertices-of-a-selected-line-lisp/m-p/6964047#M122093</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-22T11:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: Find vertices of a selected line LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-vertices-of-a-selected-line-lisp/m-p/6964246#M122094</link>
      <description>&lt;P&gt;Select a line:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(if (setq en (car (entsel "\nSelect line: ")))
  (setq p1 (cdr (assoc 10 (entget en)))
        p2 (cdr (assoc 11 (entget en))))&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Mar 2017 12:43:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-vertices-of-a-selected-line-lisp/m-p/6964246#M122094</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2017-03-22T12:43:58Z</dc:date>
    </item>
    <item>
      <title>Re: Find vertices of a selected line LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-vertices-of-a-selected-line-lisp/m-p/6964263#M122095</link>
      <description>&lt;P&gt;A command approach would be as follows (An activeX approach would execute much faster):&lt;/P&gt;
&lt;PRE&gt;;;;Michael Puckett
(defun cdrs (key lst / pair rtn)
   (while (setq pair (assoc key lst))
      (setq rtn (cons (cdr pair) rtn)
         lst (cdr (member pair lst))
      )
   )
   (reverse rtn)
)
;;D.C. Broad - Basic demo draw circles at each selected polyline vertex.
(defun c:circlline ( / dia ss e ei)
  (setq dia (getdist "\nCircle diameter: "))
  (princ "\nSelect 2 polylines: ")
  (if (setq ss (ssget '((0 . "lwpolyline"))))
    (progn
      (command "._undo" "_begin")
      (repeat (min 2 (sslength ss))
	(setq e (ssname ss 0))
	(ssdel e ss)
	(setq ei (entget e))
	(mapcar	'(lambda (p)
		   (command "._circle" p "_d" dia)
		 )
		(cdrs 10 ei)
	)
      )
    )
  )
  (command "._undo" "_end")
  (princ)
)&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Mar 2017 12:49:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-vertices-of-a-selected-line-lisp/m-p/6964263#M122095</guid>
      <dc:creator>dbroad</dc:creator>
      <dc:date>2017-03-22T12:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: Find vertices of a selected line LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-vertices-of-a-selected-line-lisp/m-p/6964496#M122096</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks, but the third code you wrote was so I could select the lines, right? Maybe I'm doing something wrong but it did not work here.&amp;nbsp;The four parallel lines only appear.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I did make an error there, in calling for the endpoint of the last entity as the center of the 2nd Circle, since at that point the last entity is the &lt;EM&gt;first&lt;/EM&gt; Circle.&amp;nbsp; It should have been more like this:&lt;/P&gt;
&lt;PRE&gt;(vl-load-com)
(Defun test (/ pl)
  (foreach Y '(200 150 100 50)
    (command
      "_.pline" (list 130 Y) (list 200 Y) ""
      "_.circle" (vlax-curve-getStartPoint &lt;FONT color="#ff0000"&gt;(setq pl&lt;/FONT&gt; (entlast)&lt;FONT color="#ff0000"&gt;)&lt;/FONT&gt;) &lt;EM&gt;&lt;FONT color="#00ccff"&gt;YourRadius&lt;/FONT&gt;&lt;/EM&gt;
      "_.circle" (vlax-curve-getEndPoint &lt;FONT color="#ff0000"&gt;pl&lt;/FONT&gt;) &lt;EM&gt;&lt;FONT color="#00ccff"&gt;YourRadius&lt;/FONT&gt;&lt;/EM&gt;
    ); command
  ); foreach
); defun&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That does work for me, &lt;EM&gt;with&lt;/EM&gt;&amp;nbsp;the &lt;EM&gt;&lt;FONT color="#00ccff"&gt;YourRadius&lt;/FONT&gt;&lt;/EM&gt; replaced with a numerical radius value [that's why&amp;nbsp;I colored/italicized it, to call attention to it&amp;nbsp;-- you need to &lt;EM&gt;do&lt;/EM&gt; something with that to use the code -- it could be an explicit number or a variable holding one].&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I apparently misread something about the original Post, thinking you wanted to expand on your code that draws the lines, to add the Circles at their ends. &amp;nbsp;Maybe I shouldn't have used the word "select" -- I didn't mean &lt;EM&gt;User&lt;/EM&gt; selection, since &lt;EM&gt;the routine draws the lines&lt;/EM&gt;, and they're &lt;EM&gt;not there&lt;/EM&gt; for the User to select when the routine starts.&amp;nbsp; I meant that the &lt;EM&gt;routine&lt;/EM&gt;&amp;nbsp;"selects" the lines&amp;nbsp;&lt;EM&gt;after&lt;/EM&gt; they're drawn, to get&amp;nbsp;the start and end points from them for drawing the Circles, as opposed to [the other routines] putting them in &lt;EM&gt;variables&lt;/EM&gt; in the process of drawing the lines, and getting them from the &lt;EM&gt;variables&lt;/EM&gt;&amp;nbsp;for drawing the Circles, rather than getting them from the lines themselves.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to select already-drawn lines, the &lt;EM&gt;code&lt;/EM&gt; in Post 1 is really irrelevant.&amp;nbsp; You could restrict it to two of them, but there's no need, nor even a need to restrict it to Lines or Polylines.&amp;nbsp; Back later with a generic routine to draw Circles at both ends of any kind of object....&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 14:05:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-vertices-of-a-selected-line-lisp/m-p/6964496#M122096</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2017-03-22T14:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: Find vertices of a selected line LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-vertices-of-a-selected-line-lisp/m-p/6964637#M122097</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt; wrote:&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;....&amp;nbsp; Back later with a generic routine to draw Circles at both ends of any kind of object....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Here's one that does that [lightly tested], on &lt;EM&gt;any&lt;/EM&gt; Line, Polyline, Arc, Circle, Ellipse, Spline or Ray, as long as you continue to pick things:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun C:CatE (/ rad ss ent); = Circle(s) at End(s)
  (initget (if *CatErad* 0 1)); no Enter on first use
  (setq *CatErad*
    (cond
      ( (getdist
          (strcat
            "\nRadius of Circle(s) to draw at End(s)"
            (if *CatErad* (strcat " &amp;lt;" (rtos *CatErad*) "&amp;gt;") "")
            ": "
          ); strcat
        ); getdist
      ); User-input condition
      (*CatErad*); on Enter with prior value
    ); cond
  ); setq
  (while (setq ss (ssget "_+.:S" '((0 . "*LINE,ARC,CIRCLE,ELLIPSE,RAY"))))
    (command "_.circle" "_none" (vlax-curve-getStartPoint (setq ent (ssname ss 0))) *CatErad*)
    (if (not (or (vlax-curve-isClosed ent) (member '(0 . "RAY") (entget ent))))
      (command "_.circle" "_none" (vlax-curve-getEndPoint (setq ent (ssname ss 0))) *CatErad*)
    ); if
  ); while
  (princ)
); defun&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On closed things and Rays, it puts just one, at the start/end point of closed things.&amp;nbsp; It could be made to &lt;EM&gt;disallow&lt;/EM&gt; closed things if preferred, to draw Circles only on &lt;EM&gt;open&lt;/EM&gt; ends.&amp;nbsp;&amp;nbsp;It could be made&amp;nbsp;to either disallow or work differently with MLINEs if you might ever have those [currently it would allow &lt;EM&gt;selection&lt;/EM&gt; of one, but couldn't draw the Circles with this method].&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It ends if you hit Enter/space/ESCape, or pick an inappropriate object type, or just miss, but it could be made to account for the latter two conditions and ask again.&amp;nbsp; It draws the Circles on the current Layer, but could be made to set a&amp;nbsp;built-in Layer, or ask the User, or use the Layer of the selected object.&amp;nbsp; And of course it could have *error* handling added, command-echo suppression, Undo begin/end wrapping, etc.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 14:30:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-vertices-of-a-selected-line-lisp/m-p/6964637#M122097</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2017-03-22T14:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: Find vertices of a selected line LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-vertices-of-a-selected-line-lisp/m-p/6964899#M122098</link>
      <description>&lt;P&gt;Thanks a lot for the help, guys! You guys are amazing and I'm learning a lot in this forum !!&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 15:27:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-vertices-of-a-selected-line-lisp/m-p/6964899#M122098</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-22T15:27:50Z</dc:date>
    </item>
  </channel>
</rss>

