<?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: Creating polyline with a right angle in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-polyline-with-a-right-angle/m-p/9153354#M81642</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4267914"&gt;@Browning_Zed&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;.... in the first lisp version, polyline is not drawn at points primitives having different z-coordinates.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That raises the question in my mind -- do you &lt;EM&gt;want&lt;/EM&gt;&amp;nbsp; it to follow different Z coordinates?&amp;nbsp; If so, you can't do it with a PLINE command, but would need 3DPOLY, and then what would the concept of a right angle &lt;EM&gt;mean?&lt;/EM&gt;&amp;nbsp; What &lt;EM&gt;looks&lt;/EM&gt;&amp;nbsp; like a right angle from the point of view of the current viewing direction?&amp;nbsp; It won't always be one in absolute terms.&amp;nbsp; And it couldn't use simple (polar) functions, whose results are projected onto the current construction plane, though it could presumably use them to get &lt;EM&gt;some&lt;/EM&gt;&amp;nbsp; of the coordinates of a next point.&lt;/P&gt;</description>
    <pubDate>Mon, 18 Nov 2019 18:39:43 GMT</pubDate>
    <dc:creator>Kent1Cooper</dc:creator>
    <dc:date>2019-11-18T18:39:43Z</dc:date>
    <item>
      <title>Creating polyline with a right angle</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-polyline-with-a-right-angle/m-p/9152866#M81636</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Is there a lisp with which can draw a polyline with a right angle snapping to existing primitives? About the same as it was done in Lee Mac's 3-Point Rectangle program, but instead of a rectangle, a polyline should be built. As an example: there are several points. The first segment of the polyline is drawn relative to any two points. All other segments of the polyline will be built relative to the first segment at an angle of 90 or 180 degrees, while the direction of drawing can be set using snapping to other primitives. Like as shown in the video.&lt;/P&gt;&lt;P&gt;&lt;div class="video-embed-center video-embed"&gt;&lt;iframe class="embedly-embed" src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F-ZOq5tB6QKQ%3Ffeature%3Doembed&amp;amp;display_name=YouTube&amp;amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D-ZOq5tB6QKQ&amp;amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F-ZOq5tB6QKQ%2Fhqdefault.jpg&amp;amp;type=text%2Fhtml&amp;amp;schema=youtube" width="336" height="189" scrolling="no" title="Right angle polyline" frameborder="0" allow="autoplay; fullscreen; encrypted-media; picture-in-picture;" allowfullscreen="true"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 15:26:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-polyline-with-a-right-angle/m-p/9152866#M81636</guid>
      <dc:creator>Browning_Zed</dc:creator>
      <dc:date>2019-11-18T15:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Creating polyline with a right angle</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-polyline-with-a-right-angle/m-p/9153130#M81637</link>
      <description>&lt;P&gt;What video &lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 16:57:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-polyline-with-a-right-angle/m-p/9153130#M81637</guid>
      <dc:creator>dlanorh</dc:creator>
      <dc:date>2019-11-18T16:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: Creating polyline with a right angle</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-polyline-with-a-right-angle/m-p/9153237#M81638</link>
      <description>&lt;P&gt;Is this the functionality, you are looking for.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;(defun c:test ( / p0 p1 ang lastSeg ptList nextPt)

(if (and (setq p0 (getpoint "\nPick first point")) (setq p1 (getpoint "\nPick second point")))
(progn

(setq ang (angle p0 p1))
(setq lastSeg (list p0 p1))
(setq ptList lastSeg)

(while (setq nextPt (getpoint "\nPick next point"))

(setq nextPt (inters (cadr lastSeg) (polar (cadr lastSeg) (- ang (/ pi 2)) 100)
		     nextPt (polar nextPt ang 100) nil))

(setq ptList (append ptList (list nextPt)))
(setq lastSeg (append (cdr lastSeg) (list nextPt)))
(setq ang (apply 'angle lastSeg))
);while

(entmake (append (list (cons 0 "LWPOLYLINE")
		       (cons 100 "AcDbEntity")
		       (cons 100 "AcDbPolyline")
		       (cons 90 (length ptList))
		       (cons 70 0))
		 (mapcar (function (lambda (p) (cons 10 p))) ptList)))
))

(princ)
);defun&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Nov 2019 17:37:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-polyline-with-a-right-angle/m-p/9153237#M81638</guid>
      <dc:creator>doaiena</dc:creator>
      <dc:date>2019-11-18T17:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: Creating polyline with a right angle</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-polyline-with-a-right-angle/m-p/9153270#M81639</link>
      <description>&lt;P&gt;Thanks, this is what I need. Is it possible that a line is displayed during the drawing process?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 17:54:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-polyline-with-a-right-angle/m-p/9153270#M81639</guid>
      <dc:creator>Browning_Zed</dc:creator>
      <dc:date>2019-11-18T17:54:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating polyline with a right angle</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-polyline-with-a-right-angle/m-p/9153296#M81640</link>
      <description>&lt;P&gt;Something like this?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;(defun c:test ( / p0 p1 ang lastSeg ptList nextPt)

(if (and (setq p0 (getpoint "\nPick first point")) (setq p1 (getpoint p0 "\nPick second point")))
(progn

(command "pline" p0 p1)
(setq ang (angle p0 p1))
(setq lastSeg (list p0 p1))

(while (setq nextPt (getpoint "\nPick next point"))

(setq nextPt (inters (cadr lastSeg) (polar (cadr lastSeg) (- ang (/ pi 2)) 100)
		     nextPt (polar nextPt ang 100) nil))
(command nextPt)
(setq lastSeg (append (cdr lastSeg) (list nextPt)))
(setq ang (apply 'angle lastSeg))
);while

(command)
))

(princ "Done!")
(princ)
);defun&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Nov 2019 18:08:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-polyline-with-a-right-angle/m-p/9153296#M81640</guid>
      <dc:creator>doaiena</dc:creator>
      <dc:date>2019-11-18T18:08:42Z</dc:date>
    </item>
    <item>
      <title>Re: Creating polyline with a right angle</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-polyline-with-a-right-angle/m-p/9153327#M81641</link>
      <description>&lt;P&gt;Yes, lines like this. But in the last lisp version, such a line appears only when drawing the first segment, and then disappears. I need such lines to be displayed along the entire path of the polyline. Also in the first lisp version, polyline is not drawn at points primitives having different z-coordinates.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 18:27:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-polyline-with-a-right-angle/m-p/9153327#M81641</guid>
      <dc:creator>Browning_Zed</dc:creator>
      <dc:date>2019-11-18T18:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: Creating polyline with a right angle</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-polyline-with-a-right-angle/m-p/9153354#M81642</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4267914"&gt;@Browning_Zed&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;.... in the first lisp version, polyline is not drawn at points primitives having different z-coordinates.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That raises the question in my mind -- do you &lt;EM&gt;want&lt;/EM&gt;&amp;nbsp; it to follow different Z coordinates?&amp;nbsp; If so, you can't do it with a PLINE command, but would need 3DPOLY, and then what would the concept of a right angle &lt;EM&gt;mean?&lt;/EM&gt;&amp;nbsp; What &lt;EM&gt;looks&lt;/EM&gt;&amp;nbsp; like a right angle from the point of view of the current viewing direction?&amp;nbsp; It won't always be one in absolute terms.&amp;nbsp; And it couldn't use simple (polar) functions, whose results are projected onto the current construction plane, though it could presumably use them to get &lt;EM&gt;some&lt;/EM&gt;&amp;nbsp; of the coordinates of a next point.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 18:39:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-polyline-with-a-right-angle/m-p/9153354#M81642</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2019-11-18T18:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating polyline with a right angle</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-polyline-with-a-right-angle/m-p/9153371#M81643</link>
      <description>&lt;P&gt;Follow the Z coordinates is not necessary. It is enough that the polyline was placed at zero Z coordinate.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 18:48:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-polyline-with-a-right-angle/m-p/9153371#M81643</guid>
      <dc:creator>Browning_Zed</dc:creator>
      <dc:date>2019-11-18T18:48:27Z</dc:date>
    </item>
    <item>
      <title>Re: Creating polyline with a right angle</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-polyline-with-a-right-angle/m-p/9153430#M81644</link>
      <description>&lt;P&gt;Try out this one&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;(defun c:test ( / p0 p1 osm ang lastSeg ptList nextPt)

(if (and (setq p0 (getpoint "\nPick first point")) (setq p1 (getpoint p0 "\nPick second point")))
(progn

(setq osm (getvar "osmode"))
(setq ang (angle (setq p0 (list (car p0) (cadr p0) 0.0)) (setq p1 (list (car p1) (cadr p1) 0.0))))
(setq lastSeg (list p0 p1))
(command "pline" p0 p1)

(while (setq nextPt (getpoint (cadr lastSeg) "\nPick next point"))

(setq nextPt (list (car nextPt) (cadr nextPt) 0.0))
(setq nextPt (inters (cadr lastSeg) (polar (cadr lastSeg) (- ang (/ pi 2)) 100)
		     nextPt (polar nextPt ang 100) nil))

(setvar "osmode" 0)
(command nextPt)
(setvar "osmode" osm)
(setq lastSeg (append (cdr lastSeg) (list nextPt)))
(setq ang (apply 'angle lastSeg))
);while

(command)
))

(princ "Done!")
(princ)
);defun&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Nov 2019 19:10:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-polyline-with-a-right-angle/m-p/9153430#M81644</guid>
      <dc:creator>doaiena</dc:creator>
      <dc:date>2019-11-18T19:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: Creating polyline with a right angle</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-polyline-with-a-right-angle/m-p/9153466#M81645</link>
      <description>&lt;P&gt;Thank you so much! This is what I needed.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 19:29:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-polyline-with-a-right-angle/m-p/9153466#M81645</guid>
      <dc:creator>Browning_Zed</dc:creator>
      <dc:date>2019-11-18T19:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: Creating polyline with a right angle</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-polyline-with-a-right-angle/m-p/9153535#M81646</link>
      <description>&lt;P&gt;Another way [lightly tested]:&lt;/P&gt;
&lt;PRE&gt;(defun C:&lt;FONT color="#000000"&gt;&lt;STRONG&gt;PLOD&lt;/STRONG&gt;&lt;/FONT&gt; ; = &lt;FONT color="#000000"&gt;&lt;STRONG&gt;P&lt;/STRONG&gt;&lt;/FONT&gt;oly&lt;FONT color="#000000"&gt;&lt;STRONG&gt;L&lt;/STRONG&gt;&lt;/FONT&gt;ine at &lt;FONT color="#000000"&gt;&lt;STRONG&gt;O&lt;/STRONG&gt;&lt;/FONT&gt;rthogonal &lt;FONT color="#000000"&gt;&lt;STRONG&gt;D&lt;/STRONG&gt;&lt;/FONT&gt;irections [relative to 1st segment]
  (/ svn svv pl pt1 pt2)
  (setq
    svn '(orthomode ucsfollow peditaccept osnapz); System Variable Names
    svv (mapcar 'getvar svn); System Variable Values
  ); setq
  (mapcar 'setvar svn '(0 0 1 1))
    ; turn off Ortho &amp;amp; UCS following, accept Lines in Pedit, force to Z=0
  (command
    "_.pline" pause pause ""
    "_.ucs" "_object" "_last"
    "_.ortho" "_on" ; for rubber-band lines &amp;amp; Change command
  ); command
  (setq pl (entlast))
  (while
    (setq pt2
      (getpoint
        (setq pt1 (trans (vlax-curve-getEndPoint pl) 0 1))
        "\nNext reference point: "
      ); getpoint
    ); setq
    (command
      "_.line" "_none" pt1 "_none" pt2 "" ; needs to be Line for next command:
      "_.change" "_last" "" pt2 ; make it orthogonal in current UCS
      "_.pedit" pl "_join" "_last" "" ""
    ); command
  ); while
  (command "_.ucs" "_previous")
  (mapcar 'setvar svn svv); reset
  (princ)
); defun&lt;/PRE&gt;
&lt;P&gt;A couple of differences from&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1166654"&gt;@doaiena&lt;/a&gt;&amp;nbsp;'s latest:&lt;/P&gt;
&lt;P&gt;The "rubber-banding" when asking for a next point [after the 1st segment]&amp;nbsp;&lt;EM&gt;is always orthogonal&lt;/EM&gt;&amp;nbsp;;&lt;/P&gt;
&lt;P&gt;If the next point is more in the direction of a continuation of the previous direction than perpendicular to that, it uses the continuation direction [I'm not sure whether your intent was always for each segment to be &lt;EM&gt;perpendicular&lt;/EM&gt;&amp;nbsp; to the previous one, regardless of geometric relationship, or simply to be &lt;EM&gt;orthogonal&lt;/EM&gt;&amp;nbsp; relative to it].&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[It could use the addition of *error* handling to ensure that the System Variables get reset, and maybe some other typical enhancements.]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 19:58:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-polyline-with-a-right-angle/m-p/9153535#M81646</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2019-11-18T19:58:39Z</dc:date>
    </item>
  </channel>
</rss>

