<?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: Get Rectangle Center Point in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10221623#M61740</link>
    <description>This is really good, Thanks! But I want to be able to draw it MAX (to the sides of rectangle) MIN (any size smaller)!</description>
    <pubDate>Thu, 08 Apr 2021 12:26:03 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-04-08T12:26:03Z</dc:date>
    <item>
      <title>Get Rectangle Center Point</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10221503#M61735</link>
      <description>&lt;P&gt;Hello, I need a function which "finds the center point of a rectangle" and also, store distance from center to width in a variable and distance from center to length in another variable.&amp;nbsp; Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 11:42:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10221503#M61735</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-08T11:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: Get Rectangle Center Point</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10221516#M61736</link>
      <description>&lt;P&gt;A rectangle from a polyline? Or lines? Better post a dwg example.&lt;/P&gt;
&lt;P&gt;And which would be the width and which length? Just general w&amp;lt;l?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 11:49:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10221516#M61736</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2021-04-08T11:49:10Z</dc:date>
    </item>
    <item>
      <title>Re: Get Rectangle Center Point</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10221562#M61737</link>
      <description>&lt;P&gt;A Polyline rectangle. Any width and length.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to draw a circle with its center as rectangle center with below function. But circle radius shouldn't go outside rectangle. So I want to use distances from sides to limit radius size (if that's the right approach)!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun C:DRWCRC ()

  	(initget 1)
	(setq c (getpoint "\nChoose Center:"))
	(initget 7)
	(setq rad (getdist c "\nRadius Size:"))
	
	(command "circle" c rad)
 
        (princ)

)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 12:04:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10221562#M61737</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-08T12:04:16Z</dc:date>
    </item>
    <item>
      <title>Re: Get Rectangle Center Point</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10221593#M61738</link>
      <description>&lt;P&gt;Sure. Your func is not bad.. but this one is a bit better -&amp;nbsp;less dependent on environment settings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(vl-load-com)

(defun c:CircleInscribed ( / s e p d r)

  (if (setq s (ssget '((0 . "LWPOLYLINE"))))
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i))))
      (setq p (mapcar '/ (mapcar '+ (vlax-curve-getpointat&lt;STRONG&gt;param&lt;/STRONG&gt; e 0) (vlax-curve-getpointatparam e 2)) '(2 2)))
      (setq r (min (setq d (vlax-curve-getdistatparam e 1)) (- (vlax-curve-getdistatparam e 2) d)))
      (entmakex (list (cons 0 "CIRCLE") (cons 10 p) (cons 40 (/ r 2))))))
  (princ)
  )
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your rectangle is from 4 vertices (if else the routine fails), then &lt;STRONG&gt;param&lt;/STRONG&gt;eter 0 is the first one, and +1 next one.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 12:17:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10221593#M61738</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2021-04-08T12:17:13Z</dc:date>
    </item>
    <item>
      <title>Re: Get Rectangle Center Point</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10221603#M61739</link>
      <description>&lt;P&gt;If you can count on always selecting an actually rectangular Polyline, and want the largest internal Circle drawn, something like this? [untested]:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;(vl-load-com)&lt;FONT color="#00CCFF"&gt;; in case needed&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;(defun C:&lt;STRONG&gt;CMR&lt;/STRONG&gt; &lt;FONT color="#00CCFF"&gt;; = Circle at Midpoint of Rectangle&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; (/ rec)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; (setq&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; rec (car (entsel "\nRectangle to draw Circle in the middle of: "))&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; dim1 (/ (distance (vlax-curve-getStartPoint rec) (vlax-curve-getPointAtParam rec 1)) 2)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; dim2 (/ (distance (vlax-curve-getPointAtParam rec 1) (vlax-curve-getPointAtParam rec 2)) 2)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; )&lt;FONT color="#999999"&gt;; setq&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; (command "_.circle"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; "_non"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; (mapcar '/&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; (mapcar '+&amp;nbsp;(vlax-curve-getStartPoint rec) (vlax-curve-getPointAtParam rec 2))&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; '(2 2 2)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; ); mapcar /&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; (min dim1 dim2)&lt;FONT color="#00CCFF"&gt;; radius&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; )&lt;FONT color="#999999"&gt;; command&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; (princ)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;)&lt;FONT color="#999999"&gt;; defun&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That leaves the distances you want in the 'dim1' and 'dim2' variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It could be made to verify that you selected a Polyline, that it's closed and with 4 vertices, and even check &lt;EM&gt;whether it's rectangular&lt;/EM&gt; (I have code for that if you want).&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 12:24:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10221603#M61739</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2021-04-08T12:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: Get Rectangle Center Point</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10221623#M61740</link>
      <description>This is really good, Thanks! But I want to be able to draw it MAX (to the sides of rectangle) MIN (any size smaller)!</description>
      <pubDate>Thu, 08 Apr 2021 12:26:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10221623#M61740</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-08T12:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: Get Rectangle Center Point</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10221626#M61741</link>
      <description>Thanks! Same here, I want to be able to draw it MAX (to the sides of rectangle) MIN (any size smaller)!</description>
      <pubDate>Thu, 08 Apr 2021 12:26:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10221626#M61741</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-08T12:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: Get Rectangle Center Point</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10221668#M61742</link>
      <description>&lt;P&gt;One routine for min and second for max?&lt;/P&gt;
&lt;P&gt;... if yes, then find a MIN function and change it to MAX. As simple as that.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 12:41:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10221668#M61742</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2021-04-08T12:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: Get Rectangle Center Point</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10222838#M61743</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;.... I want to be able to draw it MAX (to the sides of rectangle) MIN (any size smaller)!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This should [untested] offer the MAXimum size that fits within the rectangle as the default, and accept any other size input from the User:&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;(vl-load-com); in case needed
(defun C:CMR ; = Circle at Midpoint of Rectangle
  (/ rec rad)
  (setq
    rec (car (entsel "\nRectangle to draw Circle in the middle of: "))
    dim1 (/ (distance (vlax-curve-getStartPoint rec) (vlax-curve-getPointAtParam rec 1)) 2)
    dim2 (/ (distance (vlax-curve-getPointAtParam rec 1) (vlax-curve-getPointAtParam rec 2)) 2)
  ); setq
  (initget 6); no zero, no negative
  (setq rad
    (cond
      ( (getdist
          (strcat
            "\nRadius of Circle &amp;lt;max. "
            (rtos (min dim1 dim2)); in current Units mode/precision
            "&amp;gt;: "
          ); strcat
        ); getdist
      ); User-input condition
      ((min dim1 dim2)); default on User Enter
    ); cond
  ); setq
  (command "_.circle"
    "_non"
    (mapcar '/
      (mapcar '+ (vlax-curve-getStartPoint rec) (vlax-curve-getPointAtParam rec 2))
      '(2 2 2)
    ); mapcar /
    rad ; radius
  ); command
  (princ)
); defun&lt;/LI-CODE&gt;
&lt;P&gt;It could be made to reject sizes &lt;EM&gt;larger&lt;/EM&gt; than what fits in the rectangle, if that's needed.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 18:14:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10222838#M61743</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2021-04-08T18:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: Get Rectangle Center Point</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10223026#M61744</link>
      <description>&lt;P&gt;This is Perfect. Toast! &lt;span class="lia-unicode-emoji" title=":clinking_beer_mugs:"&gt;🍻&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 19:24:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10223026#M61744</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-08T19:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: Get Rectangle Center Point</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10223044#M61745</link>
      <description>&lt;LI-CODE lang="general"&gt;(defun circle_in_rect ( min_max / *error* adoc take take2 e eo eco coords a b c d1 d2 m p q)
	(defun *error* ( msg )
			(if (not (member msg '("Function cancelled" "quit / exit abort")))
				(princ (strcat "\nError: " msg))
			)
			(setvar 'cmdecho 1)
			(princ)
		)
	(defun take (amount lst / ret) (repeat amount (setq ret (cons (car lst) (take (1- amount) (cdr lst))))))
	(defun take2 (lst) (take 2 lst))
	(setq adoc (vla-get-activedocument (vlax-get-acad-object)))
	(vla-endundomark adoc)
	(vla-startundomark adoc) 
	(setvar 'cmdecho 0)
		(while (setq e (car(entsel "\nSelect rectangle &amp;gt;")))
			(setq eo (vlax-ename-&amp;gt;vla-object e) co(vlax-get eo 'Coordinates))
			(while co (setq coords (cons (take2 co) coords) co (cddr co)))
				(setq
					a (car coords) 
					b (cadr coords)
					c (caddr coords)
					p (mapcar '*(mapcar '+ a b) '(0.5 0.5))
					q (mapcar '*(mapcar '+ b c) '(0.5 0.5))
					m (mapcar '*(mapcar '+ a c) '(0.5 0.5))
					d1 (distance m p)
					d2 (distance m q)
				)
				(if(eq min_max "&amp;lt;")
					(command "_.circle" "_non" m (car(vl-sort (list d1 d2) '&amp;lt;)))
					(command "_.circle" "_non" m (car(vl-sort (list d1 d2) '&amp;gt;)))
				)
		)
	(vla-endundomark adoc)
	(setvar 'cmdecho 1)
	(princ)
)

(defun c:min_circle_in_rect nil (circle_in_rect "&amp;lt;"))
(defun c:max_circle_in_rect nil (circle_in_rect "&amp;gt;"))
(defun min_circle_in_rect nil (circle_in_rect "&amp;lt;"))
(defun max_circle_in_rect nil (circle_in_rect "&amp;gt;"))&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 08 Apr 2021 19:32:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10223044#M61745</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2021-04-08T19:32:06Z</dc:date>
    </item>
    <item>
      <title>Re: Get Rectangle Center Point</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10223617#M61746</link>
      <description>&lt;P&gt;Nice idea 4 options, for me add a overall (defun c:cinr then use a cond on pick. Need multi radio buttons.lsp. The button picked can be saved so next run just click OK.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="screenshot372.png" style="width: 203px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/904121iBEF1D15F9BE6D518/image-size/large?v=v2&amp;amp;px=999" role="button" title="screenshot372.png" alt="screenshot372.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Apr 2021 00:17:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-rectangle-center-point/m-p/10223617#M61746</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2021-04-09T00:17:35Z</dc:date>
    </item>
  </channel>
</rss>

