<?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: 3-point rectangle: Lee Mac Script in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9829655#M68405</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp; please allow me to show my 2 cent improvement&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Trace rubber band from P1 , and use GETDIST from p2&amp;nbsp; , instead GETREAL , and also set OSMODE to 0 , and retrieve it to original osmode&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:wrec nil (wrec))

(defun wrec (/ p1 p2 ang width p3 p4)
(setq osmode (getvar 'osmode))
 (setvar 'osmode 0) 
  (setq p1 (getpoint "\nFirst point &amp;gt;"))
(setq p2 (getpoint p1 "\nSecond point &amp;gt;"))
(setq ang (- (angle p2 p1) (* pi 0.5)))
(setq width (getdist p2 "\nRectangle width &amp;gt;"))
(setq p3 (polar p2 ang width))
(setq p4 (polar p1 ang width))
(command "pline" p1 p2 p3 p4 "C")
  (setvar 'osmode osmode)
(princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Oct 2020 12:20:31 GMT</pubDate>
    <dc:creator>devitg</dc:creator>
    <dc:date>2020-10-28T12:20:31Z</dc:date>
    <item>
      <title>3-point rectangle: Lee Mac Script</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9828961#M68403</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the Lee Mac script:&amp;nbsp;&lt;A href="http://www.lee-mac.com/3pointrectangle.html" target="_blank" rel="noopener"&gt;http://www.lee-mac.com/3pointrectangle.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can this be modified so that a key value can be entered for the 3rd point? It lets you specify a distance for the 2nd point (length of rectangle) but I also would like it to allow a value for the 3rd point (width of rectangle).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 05:40:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9828961#M68403</guid>
      <dc:creator>nathanwheeler27</dc:creator>
      <dc:date>2020-10-28T05:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: 3-point rectangle: Lee Mac Script</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9829115#M68404</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3182440"&gt;@nathanwheeler27&lt;/a&gt;&amp;nbsp; You should ask Lee Mac to add that option to his code.&lt;/P&gt;&lt;P&gt;There is option to answer third point input using relative coordinate (@) but it don't work for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code to draw rectangle of certain width&amp;nbsp; (that without using grreed and dinamic draw)&amp;nbsp; is simple&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(defun c:wrec nil (wrec))
(defun wrec (/ p1 p2 ang width p3 p4)
(setq p1 (getpoint "\nFirst point &amp;gt;"))
(setq p2 (getpoint "\nSecond point &amp;gt;"))
(setq ang (- (angle p2 p1) (* pi 0.5)))
(setq width (getreal "\nRectangle width &amp;gt;"))
(setq p3 (polar p2 ang width))
(setq p4 (polar p1 ang width))
(command "pline" p1 p2 p3 p4 "C")
(princ)
)&lt;/LI-CODE&gt;&lt;P&gt;Third point is created in counterclockwise direction to line from first to second point with desired width entered. So if width value is positive rectangle is drawn in that direction, if negative in opposite direction. Positive value draws upwards, negative downwards,&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 08:11:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9829115#M68404</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2020-10-28T08:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: 3-point rectangle: Lee Mac Script</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9829655#M68405</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp; please allow me to show my 2 cent improvement&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Trace rubber band from P1 , and use GETDIST from p2&amp;nbsp; , instead GETREAL , and also set OSMODE to 0 , and retrieve it to original osmode&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:wrec nil (wrec))

(defun wrec (/ p1 p2 ang width p3 p4)
(setq osmode (getvar 'osmode))
 (setvar 'osmode 0) 
  (setq p1 (getpoint "\nFirst point &amp;gt;"))
(setq p2 (getpoint p1 "\nSecond point &amp;gt;"))
(setq ang (- (angle p2 p1) (* pi 0.5)))
(setq width (getdist p2 "\nRectangle width &amp;gt;"))
(setq p3 (polar p2 ang width))
(setq p4 (polar p1 ang width))
(command "pline" p1 p2 p3 p4 "C")
  (setvar 'osmode osmode)
(princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 12:20:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9829655#M68405</guid>
      <dc:creator>devitg</dc:creator>
      <dc:date>2020-10-28T12:20:31Z</dc:date>
    </item>
    <item>
      <title>@Re: 3-point rectangle: Lee Mac Script</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9829762#M68406</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/58962"&gt;@devitg&lt;/a&gt;Setting osnap to 0 is good point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Getdist allows us to pick point. For rectangle to pass through that point we would need perpendicular distance from that point to line defined with points p1 and p2. That's why I opted for getreal. Option to pick third point is already included in Lee's code.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 12:56:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9829762#M68406</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2020-10-28T12:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: @Re: 3-point rectangle: Lee Mac Script</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9830218#M68407</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp;,&amp;nbsp; getdist return a value , not a point , GETPOINT return a point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;GETDIST&amp;nbsp; show the rubber band that GETREAL do not.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can type the REAL value with GETDIST&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 15:09:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9830218#M68407</guid>
      <dc:creator>devitg</dc:creator>
      <dc:date>2020-10-28T15:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: @Re: 3-point rectangle: Lee Mac Script</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9830258#M68408</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/58962"&gt;@devitg&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp;,&amp;nbsp; getdist return a value , not a point , GETPOINT return a point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;GETDIST&amp;nbsp; show the rubber band that GETREAL do not.&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can type the REAL value with GETDIST&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Yes, getdist returns a value. User can pick a second point or type in a distance.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 15:23:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9830258#M68408</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2020-10-28T15:23:45Z</dc:date>
    </item>
    <item>
      <title>Re: @Re: 3-point rectangle: Lee Mac Script</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9831030#M68409</link>
      <description>&lt;P&gt;Thank you for that, if I can't get the dynamic (grread) version to work, I might have to use that. But I was really wanting the visual of the rectangle to show.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have a fix for that?&lt;/P&gt;&lt;P&gt;On Lee-Macs script, the 3rd point allows&amp;nbsp;@x,y to be entered. I would think that could be converted to&amp;nbsp;@distance?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 20:28:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9831030#M68409</guid>
      <dc:creator>nathanwheeler27</dc:creator>
      <dc:date>2020-10-28T20:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: @Re: 3-point rectangle: Lee Mac Script</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9831717#M68410</link>
      <description>&lt;P&gt;I'll add dynamic option to this code, but would also like you to contact Lee to add asked option to his code.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2020 07:54:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9831717#M68410</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2020-10-29T07:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: 3-point rectangle: Lee Mac Script</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9832631#M68411</link>
      <description>&lt;P&gt;We have made many such tools since R9, here is a likey form,&lt;/P&gt;&lt;P&gt;if it actually gets attached&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2020 15:27:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9832631#M68411</guid>
      <dc:creator>stevor</dc:creator>
      <dc:date>2020-10-29T15:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: 3-point rectangle: Lee Mac Script</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9832861#M68412</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you, I will contact him.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/100035"&gt;@stevor&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Drawing the rectangle is the easy part here, but using grread to make it dynamic is where I get lost. Lee Macs version has snapping so it is the closest thing I can find at the moment.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2020 16:51:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9832861#M68412</guid>
      <dc:creator>nathanwheeler27</dc:creator>
      <dc:date>2020-10-29T16:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: 3-point rectangle: Lee Mac Script</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9835670#M68413</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3182440"&gt;@nathanwheeler27&lt;/a&gt;&amp;nbsp;&amp;nbsp; Try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:wrec nil (wrec))

(defun wrec ( /  p1 p2 ang width p3 p4 vectorSide rad_to_deg perperdicular_from_point_to_line rv mp pp side di ch number);

(defun vectorSide (v1 v2 p / r *fuzz*)
(setq r (- (* (-(car v2)(car v1))(-(cadr p)(cadr v1)))
           (* (-(cadr v2)(cadr v1))(-(car p)(car v1)))
        )
	*fuzz* 1e-10
)
(cond ((equal r 0.0 *fuzz*) 0) (t (fix (/ (abs r) r))))
)

(defun rad_to_deg (rad)(* 180.0 (/ rad pi)))

(defun perperdicular_from_point_to_line (lin1 lin2 p / x1 y1 x2 y2 x3 y3 k m n ret)
;returns point on a line (line1 line2) as a perpendicular projection from point p
	(mapcar 'set '(x1 x2 x3) (mapcar 'car (list lin1 lin2 p)))
	(mapcar 'set '(y1 y2 y3) (mapcar 'cadr (list lin1 lin2 p)))
	(setq 
		m (-(*(- y2 y1) (- x3 x1))(*(- x2 x1) (- y3 y1)))
		n (+(* (- y2 y1)(- y2 y1))(*(- x2 x1)(- x2 x1)))
	)
	(cond 
		((/= n 0.0) 
			(setq 
				k (/ m n)
				ret (list(- x3 (* k(- y2 y1)))(+ y3 (* k(- x2 x1))))
			)
		)
	)
	ret
)

(setq p1 (getpoint "\nFirst point &amp;gt;"))
(setq p2 (getpoint p1 "\nSecond or vector point&amp;gt;"))
(setq number "")
(grdraw p1 p2 5 0)
(setq width (getreal "\nEnter rectangle width or enter for distance to second point &amp;gt; "))
(if (and width) (setq p2 (polar p1 (angle p1 p2) width)) (setq p2 p2))
(grdraw p1 p2 1 0)
(setq ang (- (angle p2 p1) (* pi 0.5)) off 0)
(prompt "Rectangle height or pick endpoint &amp;gt;")
(while (and (setq rv (grread T)) (= off 0) (or (= 2 (car rv))(= 5 (car rv))))
	(redraw)
	(cond 
		((= 5 (car rv))
			(setq mp (cadr rv))
			(setq pp (perperdicular_from_point_to_line p1 p2 mp))
			(setq side (vectorSide  p1 p2 mp))
			(setq di (* side (distance pp mp)))
			(setq p3 (polar p2 ang di))
			(setq p4 (polar p1 ang di))
			(grdraw p2 p3 1 0)
			(grdraw p3 p4 1 0)
			(grdraw p4 p1 1 0)
			(grdraw p1 p2 1 0)
		)
		((= 2 (car rv))
			(grdraw p1 p2 1 0)
				(if (and (&amp;gt;= (cadr rv) 44)(&amp;lt;= (cadr rv) 57) (/= (cadr rv) 47))
				  (progn
					(setq ch (chr (cadr rv)))
					(setq number (strcat number ch))
					(princ ch)
				  )
				)
				(if (= (cadr rv) 8)
				  (progn
					(princ (chr 8))
					(if (&amp;gt; (strlen number) 1)(setq number (substr number 1 (- (strlen number) 1))))
				  )
				)
				
				(if (or (= 13 (cadr rv))(= 32 (cadr rv)))
						(setq number (vl-string-subst "." "," number) di (atof number) p3 (polar p2 ang di) p4 (polar p1 ang di) off 1)
					
				)
		)
	)
)
(command "pline" p1 p2 p3 p4 "C")
(redraw)
(princ)
)&lt;/LI-CODE&gt;&lt;P&gt;@&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2020 19:35:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9835670#M68413</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2020-10-30T19:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: 3-point rectangle: Lee Mac Script</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9835757#M68414</link>
      <description>&lt;P&gt;Thank you for all that work. I don't have time right now to see if I can work out these things, but these are some changes I need to look into:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;It looks like there are two ways to use this:&lt;OL&gt;&lt;LI&gt;Pick basepoint -&amp;gt; pick a point that sets the angle -&amp;gt; type in the width -&amp;gt; type in the height&lt;/LI&gt;&lt;LI&gt;Pick basepoint -&amp;gt; pick angle and width -&amp;gt; hit enter -&amp;gt; then you can only drag to specify the height&lt;/LI&gt;&lt;LI&gt;I would like to change this so its&amp;nbsp;Pick basepoint -&amp;gt; pick angle and width (one action) -&amp;gt; type in height or drag to specify height.&amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;From what I can tell, it can be a little buggy. For example, a 12x12 box forms a triangle.&lt;/LI&gt;&lt;LI&gt;I don't think it will be that big of a deal, but it would be nice to utilize Lee Macs grread snapping functions so picking a point for the height can snap to other points. That way you don't always have to type the height.&lt;/LI&gt;&lt;LI&gt;Changing it all feet and inches on input. Also not really important.&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Fri, 30 Oct 2020 20:23:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9835757#M68414</guid>
      <dc:creator>nathanwheeler27</dc:creator>
      <dc:date>2020-10-30T20:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: 3-point rectangle: Lee Mac Script</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9839017#M68415</link>
      <description>&lt;P&gt;Lee Mac just updated his script to allow key input for the width and length of the rectangle.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for everyone's help here!&lt;/P&gt;</description>
      <pubDate>Mon, 02 Nov 2020 03:24:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3-point-rectangle-lee-mac-script/m-p/9839017#M68415</guid>
      <dc:creator>nathanwheeler27</dc:creator>
      <dc:date>2020-11-02T03:24:14Z</dc:date>
    </item>
  </channel>
</rss>

