Jump to content

Bounding box with offset erase


Recommended Posts

Posted

Hi all, i am very new to lisps and would really like to add an offset with distance and erase original to my bounding box lisp. Any help much appreciated! Here is what i have so far, it works really well.

 

(defun C:DBBM (/ ss minpt maxpt eLL eUR LL UR); = Draw Bounding Box, Multiple
  (prompt "\nTo Draw the Bounding Box around Multiple objects,")
  (if (setq ss (ssget))
    (progn ; then
      (repeat (setq n (sslength ss))
        (vla-getboundingbox (vlax-ename->vla-object (ssname ss (setq n (1- n)))) 'minpt 'maxpt)
        (setq
          eLL (vlax-safearray->list minpt)
          eUR (vlax-safearray->list maxpt)
          LL (if LL (mapcar 'min eLL LL) eLL)
          UR (if UR (mapcar 'max eUR UR) eUR)
        ); setq
      ); repeat
      (command "_.rectangle" "_none" LL "_none" UR)
    ); progn
    (prompt "\nNothing selected."); else
  ); if
  (princ)
); defun
(vl-load-com)
(prompt "\nType DBBM to Draw the Bounding Box around Multiple objects.")

 

 

Posted (edited)
;https://www.cadtutor.net/forum/topic/35584-create-layers-with-lisp/
(defun C:DBBM (/ ss minpt maxpt eLL eUR LL UR); = Draw Bounding Box, Multiple
  (prompt "\nTo Draw the Bounding Box around Multiple objects,")
     
     (setvar "cmdecho" 0)
     (setq oldclayer         (getvar "clayer")
           layername                   "test")

     (and (or (tblsearch "LAYER" layername)
              (Layer layername 1 nil nil nil))
     (setvar "clayer" layername)

  (if (setq ss (ssget))
    (progn ; then
      (repeat (setq n (sslength ss))
        (vla-getboundingbox (vlax-ename->vla-object (ssname ss (setq n (1- n)))) 'minpt 'maxpt)
        (setq
          eLL (vlax-safearray->list minpt)
          eUR (vlax-safearray->list maxpt)
          LL (if LL (mapcar 'min eLL LL) eLL)
          UR (if UR (mapcar 'max eUR UR) eUR)
        ); setq
      ); repeat
      (command "_.rectangle" "_none" LL "_none" UR)
      (setq obj (vlax-ename->vla-object (entlast)))
      (vla-offset obj 100); You can add a question and change the value
      (vla-erase obj)
    ); progn
    (prompt "\nNothing selected."); else
  ); if
)
 (setvar "clayer" oldclayer)
 (princ)
); defun
(vl-load-com)
(prompt "\nType DBBM to Draw the Bounding Box around Multiple objects.")

(defun Layer (Nme Col Ltyp LWgt Plt)
 (entmake (list (cons 0 "LAYER")
                (cons 100 "AcDbSymbolTableRecord")
                (cons 100 "AcDbLayerTableRecord")
                (cons 2  Nme)
                (cons 70 0)
                (cons 62 Col)
                ;(cons 6 Ltyp)
                ;(cons 290 Plt)
                ;(cons 370 LWgt)
)))

Is this the lisp you are talking about?

Edited by Scoutr4
Layer added
Posted
15 hours ago, Scoutr4 said:
(defun C:DBBM (/ ss minpt maxpt eLL eUR LL UR); = Draw Bounding Box, Multiple
  (prompt "\nTo Draw the Bounding Box around Multiple objects,")
  (if (setq ss (ssget))
    (progn ; then
      (repeat (setq n (sslength ss))
        (vla-getboundingbox (vlax-ename->vla-object (ssname ss (setq n (1- n)))) 'minpt 'maxpt)
        (setq
          eLL (vlax-safearray->list minpt)
          eUR (vlax-safearray->list maxpt)
          LL (if LL (mapcar 'min eLL LL) eLL)
          UR (if UR (mapcar 'max eUR UR) eUR)
        ); setq
      ); repeat
      (command "_.rectangle" "_none" LL "_none" UR)
      (setq obj (vlax-ename->vla-object (entlast)))
      (vla-offset obj 100); You can add a question and change the value
      (vla-erase obj)
    ); progn
    (prompt "\nNothing selected."); else
  ); if
  (princ)
); defun
(vl-load-com)
(prompt "\nType DBBM to Draw the Bounding Box around Multiple objects.")

Is this the lisp you are talking about?

 

 

Yes that is absolutely what i'm talking about! Thanks Scoutr4. Is it easy to add in, assign a specific layer to this?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...