ekko Posted March 16, 2022 Posted March 16, 2022 (vl-load-com) (defun c:test (/ obj sel spc tc wnm) (setq spc (vlax-get-property (vla-get-activedocument (vlax-get-acad-object)) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace ) ) ) (setq p1 (getpoint "p1")) (setq p2 (getpoint "p2")) (if (and (setq sel (ssget "c" p1 p2 (list '(0 . "INSERT")))) (setq box (LM:ssboundingbox sel)) ) (progn (setq p4 (ap4 box)) (setq obj (vlax-invoke spc 'addlightweightpolyline (apply 'append p4 ) ) ) (vla-put-closed obj :vlax-true) (vla-put-elevation obj (caddar box)) ) ) (princ) ) (vl-load-com) (princ) ;; Selection Set Bounding Box - Lee Mac ;; returns a list of the lower left and upper right WCS coordinates of a ;; A rectangle encloses all objects in the provided selection set. ;; sel - [sel] returns the selection set of bounding boxes for which (defun LM:ssboundingbox (sel / idx llp ls1 ls2 obj urp) (setq obj (vlax-ename->vla-object (ssname sel 0))) (if (and (vlax-method-applicable-p obj 'getboundingbox) (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list obj 'llp 'urp) ) ) ) ) (setq ls1 (mapcar 'min (vlax-safearray->list llp) (cond (ls1) ((vlax-safearray->list llp)) ) ) ls2 (mapcar 'max (vlax-safearray->list urp) (cond (ls2) ((vlax-safearray->list urp)) ) ) ) ) (if (and ls1 ls2) (list ls1 ls2) ) ) ;; Selection Set Bounding Box - Lee Mac (defun ap4 (box) (mapcar '(lambda (x) (mapcar '(lambda (y) ((eval y) box)) x)) '( (caar cadar) (caadr cadar) (caadr cadadr) (caar cadadr) ) ) ) Hello everyone, I use Lee Mac's bounding box code, it always gets the primitive bounding with a positive angle, unfortunately, after rotating the primitive angle, or the bounding box is positive, which is not what I want , How can I get the minimum bounding box of the selection set, even if its angle is arbitrary, instead of getting a positive bounding box? 20220316.dwg Quote
Recommended Posts
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.