<?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: Enclose object inside rectangular envelope, draw vertical and horizontal lines from midpoint to midpoint then insert block at the center in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10230112#M61585</link>
    <description>&lt;P&gt;Its not a hard task provided outside rectang is a pline. You can get the Vertice pts so you can then work out all the other points. Rather than post full solution this is the snippets needed. The only way to learn is have a go.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(setq plent (entsel "\nPick rectang"))
(if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))))

(setq pt1 (nth 0 co-ord) pt2 (nth 1 co-ord) pt3 (nth 2 co-ord) pt4 (nth 3 co-ord))

(setq mpt1 (mapcar '* (mapcar '+ pt1 pt2) '(0.5 0.5)))

Then just draw plines etc using mpt1 mpt2..... 

Same for Circle work out a midpt 
&lt;/LI-CODE&gt;&lt;P&gt;Write down all the steps as you do it manually and just convert them to lisp steps.&lt;/P&gt;</description>
    <pubDate>Mon, 12 Apr 2021 03:48:48 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-04-12T03:48:48Z</dc:date>
    <item>
      <title>Enclose object inside rectangular envelope, draw vertical and horizontal lines from midpoint to midpoint then insert block at the center</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10230043#M61584</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looking for a lisp routine to enclose an object on a rectangle then draw vertical and horizontal lines that will serve as centerlines for the rectangle and finally insert a block on the center of the rectangle.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've attached a sample image for reference.&lt;/P&gt;&lt;P&gt;The yellow box is the envelope, the magenta lines are the centerlines and the circle on the center is the inserted block.&lt;/P&gt;&lt;P&gt;The hatched polygon is the sample object.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 02:47:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10230043#M61584</guid>
      <dc:creator>Julius_Ceazar</dc:creator>
      <dc:date>2021-04-12T02:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: Enclose object inside rectangular envelope, draw vertical and horizontal lines from midpoint to midpoint then insert block at the center</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10230112#M61585</link>
      <description>&lt;P&gt;Its not a hard task provided outside rectang is a pline. You can get the Vertice pts so you can then work out all the other points. Rather than post full solution this is the snippets needed. The only way to learn is have a go.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(setq plent (entsel "\nPick rectang"))
(if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))))

(setq pt1 (nth 0 co-ord) pt2 (nth 1 co-ord) pt3 (nth 2 co-ord) pt4 (nth 3 co-ord))

(setq mpt1 (mapcar '* (mapcar '+ pt1 pt2) '(0.5 0.5)))

Then just draw plines etc using mpt1 mpt2..... 

Same for Circle work out a midpt 
&lt;/LI-CODE&gt;&lt;P&gt;Write down all the steps as you do it manually and just convert them to lisp steps.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 03:48:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10230112#M61585</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-12T03:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: Enclose object inside rectangular envelope, draw vertical and horizontal lines from midpoint to midpoint then insert block at the center</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10230187#M61586</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3203640"&gt;@Julius_Ceazar&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm looking for a lisp routine to enclose an object&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;One object and NOT multiple objects?&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="lisp"&gt;(defun c:demo ( / LWPoly _midOf obj  data pts)
(defun LWPoly (lst cls)
  (entmakex
    (append (list (cons 0 "LWPOLYLINE")
		  (cons 100 "AcDbEntity")
		  (cons 100 "AcDbPolyline")
		  (cons 90 (length lst))
		  (cons 70 cls)
	    )
	    (mapcar (function (lambda (p) (cons 10 p))) lst)
    )
  )
)
(defun _midOf (p1 p2)
       (mapcar '(lambda (a b) (/ (+ a b) 2.)) p1 p2)
  )

  
  (if (setq obj (car (entsel "\nSelect object to enclose")))
    (progn
      (vla-getboundingbox (vlax-ename-&amp;gt;vla-object obj) 'll 'ur)
      (setq data (mapcar 'vlax-safearray-&amp;gt;list (list ll ur)))
      (setq pts (list (Car data)
			 (list (Caadr data)(cadar data) 0.0)
			 (Cadr data)
			 (list (caar data) (cadadr data) 0.0)
			 )
	    )
      (LWPoly pts 1)
      (LWPoly (list (_midOf (car pts)(cadr pts))
		    (_midOf (cadddr pts)(caddr pts))) 0)
      (LWPoly (list (_midOf (car pts)(cadddr pts))
		    (_midOf (cadr pts)(caddr pts))) 0)
      (vlax-invoke (vlax-get
                           (vla-get-ActiveLayout
                                               (vla-get-activedocument
                                                     (vlax-get-acad-object)))
                                         'Block)
                                   'InsertBlock
                                   (_midOf (car pts)(caddr pts))
                                   "YourBlockname"
                                   1 1 1 0)
      )
    )
  (princ)
  )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;FONT size="3"&gt;HTH&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 04:39:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10230187#M61586</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2021-04-12T04:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: Enclose object inside rectangular envelope, draw vertical and horizontal lines from midpoint to midpoint then insert block at the center</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10231031#M61587</link>
      <description>&lt;P&gt;&lt;FONT color="#000000"&gt;(vl-load-com)&lt;FONT color="#99CCFF"&gt;; if needed&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;(defun C:&lt;/FONT&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#008080"&gt;WHATEVER&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;FONT color="#000000"&gt; (/ minpt maxpt LL UR midpt)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; (vla-getboundingbox&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; (vlax-ename-&amp;gt;vla-object (car (entsel "\nSelect object: ")))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; 'minpt 'maxpt&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; )&lt;FONT color="#999999"&gt;; ...ename-&amp;gt;obj...&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; (setq&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; LL (vlax-safearray-&amp;gt;list minpt)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; UR (vlax-safearray-&amp;gt;list maxpt)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; midpt (mapcar '/ (mapcar '+ LL UR) '(2 2 2))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; )&lt;FONT color="#999999"&gt;; setq&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; (command&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; "_.layer" "_set" "&lt;STRONG&gt;&lt;FONT color="#008080"&gt;&lt;EM&gt;YourOuterRectangleLayer&lt;/EM&gt;&lt;/FONT&gt;&lt;/STRONG&gt;" ""&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; "_.rectang" "_non" LL "_none" UR&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; "_.layer" "_set" "&lt;STRONG&gt;&lt;EM&gt;&lt;FONT color="#008080"&gt;YourCrosshairsLayer&lt;/FONT&gt;&lt;/EM&gt;&lt;/STRONG&gt;" ""&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; "_.line" "_non" (list (car LL) (cadr midpt)) "_non" (list (car UR) (cadr midpt)) ""&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; "_.line" "_non" (list (car midpt) (cadr LL)) "_non" (list (car midpt) (cadr UR)) ""&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; "_.layer" "_set" "&lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#008080"&gt;YourBlockLayer&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;" ""&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; "_.insert" "&lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#008080"&gt;YourBlockName&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;" "_non" midpt "" "" ""&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; )&lt;FONT color="#999999"&gt;; command&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&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;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;STRONG&gt;Edit&lt;/STRONG&gt;&lt;/FONT&gt; all the &lt;STRONG&gt;&lt;EM&gt;&lt;FONT color="#008080"&gt;bold teal italic&lt;/FONT&gt;&lt;/EM&gt;&lt;/STRONG&gt; things appropriately.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It assumes:&lt;/P&gt;
&lt;P&gt;1)&amp;nbsp; the Layers and the Block definition exist in the drawing;&lt;/P&gt;
&lt;P&gt;2)&amp;nbsp; the Block is one with a wipeout to hide the crossing of the crosshairs behind it, so it can draw just the two Lines.&lt;/P&gt;
&lt;P&gt;3)&amp;nbsp; scale factors of 1 and rotation of 0 are appropriate for the Block Insertion.&lt;/P&gt;
&lt;P&gt;But if those things can't be assumed, they can be accounted for with some additional code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It takes selection of a &lt;EM&gt;single&lt;/EM&gt; object, but can easily be adjusted to do the same around the collective extents of &lt;EM&gt;multiple&lt;/EM&gt; objects [I have another routine with the code to do that].&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It works [in minimal testing] &lt;EM&gt;whether or not&lt;/EM&gt; the number in your image is an Attribute in the Block.&amp;nbsp; If it is, the routine leaves you at the point of giving it a value for the Attribute, before the Block appears.&amp;nbsp; If not, the placing of the number as Text can be added.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 11:50:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10231031#M61587</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2021-04-12T11:50:56Z</dc:date>
    </item>
    <item>
      <title>Re: Enclose object inside rectangular envelope, draw vertical and horizontal lines from midpoint to midpoint then insert block at the center</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10231164#M61588</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;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;....&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; (vla-getboundingbox&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; (vlax-ename-&amp;gt;vla-object (car (entsel "\nSelect object: ")))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; 'minpt 'maxpt&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; )&lt;FONT color="#999999"&gt;; ...ename-&amp;gt;obj...&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;...&lt;/FONT&gt;&lt;SPAN style="font-family: inherit;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No difference in the operation, but to be more correctly commented on, that much should be:&lt;/P&gt;
&lt;P&gt;....&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; (vla-getboundingbox&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; (vlax-ename-&amp;gt;vla-object (car (entsel "\nSelect object: ")))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; 'minpt 'maxpt&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; )&lt;FONT color="#999999"&gt;; ...boundingbox...&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;FONT color="#999999"&gt;....&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 12:39:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10231164#M61588</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2021-04-12T12:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: Enclose object inside rectangular envelope, draw vertical and horizontal lines from midpoint to midpoint then insert block at the center</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10233089#M61589</link>
      <description>&lt;P&gt;Thank you. I'm still on the process of learning lisp language.&lt;/P&gt;&lt;P&gt;Will definitely try your advice.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 02:50:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10233089#M61589</guid>
      <dc:creator>Julius_Ceazar</dc:creator>
      <dc:date>2021-04-13T02:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: Enclose object inside rectangular envelope, draw vertical and horizontal lines from midpoint to midpoint then insert block at the center</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10233095#M61590</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/564264"&gt;@pbejse&lt;/a&gt;&amp;nbsp;. It worked.&lt;/P&gt;&lt;P&gt;Is there a huge difference if I want to select multiple objects and put them in one envelope?&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 02:53:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10233095#M61590</guid>
      <dc:creator>Julius_Ceazar</dc:creator>
      <dc:date>2021-04-13T02:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: Enclose object inside rectangular envelope, draw vertical and horizontal lines from midpoint to midpoint then insert block at the center</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10233162#M61591</link>
      <description>&lt;P&gt;Thank you so much&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;. It worked.&lt;/P&gt;&lt;P&gt;If I want to select multiple objects and enclose them on an envelope, is it also possible with this method too?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 03:42:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10233162#M61591</guid>
      <dc:creator>Julius_Ceazar</dc:creator>
      <dc:date>2021-04-13T03:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: Enclose object inside rectangular envelope, draw vertical and horizontal lines from midpoint to midpoint then insert block at the center</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10233241#M61592</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3203640"&gt;@Julius_Ceazar&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/564264"&gt;@pbejse&lt;/a&gt;&amp;nbsp;. It worked.&lt;/P&gt;
&lt;P&gt;Is there a &lt;FONT color="#0000FF"&gt;huge difference &lt;/FONT&gt;if I want to select multiple objects and put them in one envelope?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT size="3" color="#0000FF"&gt;Not at all&lt;/FONT&gt;&lt;/P&gt;
&lt;LI-CODE lang="lisp"&gt;(defun c:Enveloped ( / LWPoly _midOf obj data pts Xc Yc)
(defun LWPoly (lst lay cls)
  (entmakex
    (append (list (cons 0 "LWPOLYLINE")
		  (cons 100 "AcDbEntity")
		  (cons 100 "AcDbPolyline")
		  (cons 90 (length lst))
		  (cons 8 lay)
		  (cons 70 cls)
	    )
	    (mapcar (function (lambda (p) (cons 10 p))) lst)
    )
  )
)
(defun _midOf (p1 p2)
       (mapcar '(lambda (a b) (/ (+ a b) 2.)) p1 p2)
  )

(prompt "\nSelect objects to enclosed")
(if (and
      (tblsearch "BLOCK" "YourBlockname");&amp;lt;-- make sure to change this to your block name
      (setq ss (ssget))
      )
    (progn
      (repeat (setq i (sslength ss))
	(setq e (vlax-ename-&amp;gt;vla-object (ssname ss (setq i (1- i)))))
	(and (vlax-method-applicable-p  e 'Getboundingbox)
      		 (not (vla-GetboundingBox e 'll 'ur))
		 (Setq Xc (cons (vlax-safearray-&amp;gt;list ll) Xc))
		 (Setq Yc (cons (vlax-safearray-&amp;gt;list ur) Yc))
	)
      )
      (setq data (list (apply 'mapcar (Cons 'min  Xc))
		       (apply 'mapcar (Cons 'max  Yc))))
      
      (setq pts (list (Car data)
			 (list (Caadr data)(cadar data) 0.0)
			 (Cadr data)
			 (list (caar data) (cadadr data) 0.0)
			 )
	    )
;;	makes sure to change  "RectangleLayer" and "LineLayer" 	;;
;; 		to your standard layer name      		;;
      (LWPoly pts "RectangleLayer" 1)	
      (LWPoly (list (_midOf (car pts)(cadr pts))
		    (_midOf (cadddr pts)(caddr pts))) "LineLayer" 0) 
      (LWPoly (list (_midOf (car pts)(cadddr pts))
		    (_midOf (cadr pts)(caddr pts))) "LineLayer" 0) 
      
      (vlax-invoke (vlax-get
                           (vla-get-ActiveLayout
                                               (vla-get-activedocument
                                                     (vlax-get-acad-object)))
                                         'Block)
                                   'InsertBlock
                                   (_midOf (car pts)(caddr pts))
                                   "YourBlockname"
                                   1 1 1 0)
      )
    )
  (princ)
  )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;FONT size="3"&gt;HTH&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 04:45:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10233241#M61592</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2021-04-13T04:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: Enclose object inside rectangular envelope, draw vertical and horizontal lines from midpoint to midpoint then insert block at the center</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10233555#M61593</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/564264"&gt;@pbejse&lt;/a&gt;. Worked perfectly with multiple objects.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Julius_Ceazar_0-1618299385705.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/905648i48E78048FD4E2AD8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Julius_Ceazar_0-1618299385705.png" alt="Julius_Ceazar_0-1618299385705.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 07:37:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10233555#M61593</guid>
      <dc:creator>Julius_Ceazar</dc:creator>
      <dc:date>2021-04-13T07:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: Enclose object inside rectangular envelope, draw vertical and horizontal lines from midpoint to midpoint then insert block at the center</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10233615#M61594</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3203640"&gt;@Julius_Ceazar&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/564264"&gt;@pbejse&lt;/a&gt;. Worked perfectly with multiple objects.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT size="3"&gt;Good for you, glad it helps.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;And you are welcome.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 08:08:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10233615#M61594</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2021-04-13T08:08:04Z</dc:date>
    </item>
    <item>
      <title>Re: Enclose object inside rectangular envelope, draw vertical and horizontal lines from midpoint to midpoint then insert block at the center</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10233967#M61595</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3203640"&gt;@Julius_Ceazar&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you so much&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;. It worked.&lt;/P&gt;
&lt;P&gt;If I want to select multiple objects and enclose them on an envelope, is it also possible with this method too?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;(vl-load-com); if needed
(defun C:WHATEVER (/ ss n minpt maxpt eLL eUR LL UR midpt)
  (prompt "\nTo Draw the Box around Multiple objects with Crosshairs &amp;amp; Block,")
  (if (setq ss (ssget))
    (progn ; then
      (repeat (setq n (sslength ss))
        (vla-getboundingbox (vlax-ename-&amp;gt;vla-object (ssname ss (setq n (1- n)))) 'minpt 'maxpt)
        (setq
          eLL (vlax-safearray-&amp;gt;list minpt)
          eUR (vlax-safearray-&amp;gt;list maxpt)
          LL (if LL (mapcar 'min eLL LL) eLL)
          UR (if UR (mapcar 'max eUR UR) eUR)
        ); setq
      ); repeat
      (setq midpt (mapcar '/ (mapcar '+ LL UR) '(2 2 2)))
      (command
        "_.layer" "_set" "YourOuterRectangleLayer" ""
        "_.rectang" "_non" LL "_none" UR
        "_.layer" "_set" "YourCrosshairsLayer" ""
        "_.line" "_non" (list (car LL) (cadr midpt)) "_non" (list (car UR) (cadr midpt)) ""
        "_.line" "_non" (list (car midpt) (cadr LL)) "_non" (list (car midpt) (cadr UR)) ""
        "_.layer" "_set" "YourBlockLayer" ""
        "_.insert" "YourBlockName" "_non" midpt "" "" ""
      ); command
    ); progn
  ); if
  (princ)
); defun&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit the Layer and Block names as before.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 11:02:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10233967#M61595</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2021-04-13T11:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Enclose object inside rectangular envelope, draw vertical and horizontal lines from midpoint to midpoint then insert block at the center</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10234000#M61596</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;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;LI-CODE lang="general"&gt;...
      (repeat (setq n (sslength ss))
        (vla-getboundingbox (vlax-ename-&amp;gt;vla-object (ssname ss (setq n (1- n)))) 'minpt 'maxpt)
        (setq
          eLL (vlax-safearray-&amp;gt;list minpt)
          eUR (vlax-safearray-&amp;gt;list maxpt)
          LL (if LL (mapcar 'min eLL LL) eLL)
          UR (if UR (mapcar 'max eUR UR) eUR)
        ); setq
      ); repeat
     ...&lt;/LI-CODE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Thats brilliant&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&amp;nbsp;.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 11:14:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10234000#M61596</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2021-04-13T11:14:08Z</dc:date>
    </item>
    <item>
      <title>Re: Enclose object inside rectangular envelope, draw vertical and horizontal lines from midpoint to midpoint then insert block at the center</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10239608#M61597</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;&amp;nbsp;. This solution also works.&lt;/P&gt;&lt;P&gt;Only proves that it's possible to have multiple solution to a single problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 03:41:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/enclose-object-inside-rectangular-envelope-draw-vertical-and/m-p/10239608#M61597</guid>
      <dc:creator>Julius_Ceazar</dc:creator>
      <dc:date>2021-04-15T03:41:28Z</dc:date>
    </item>
  </channel>
</rss>

