kalai Posted September 10, 2011 Share Posted September 10, 2011 Hi, I need to get bounding box (i.e min and max) of the current drawing. My code, (defun bboxdims (/ ent obj minpt maxpt pt1 pt2) (vl-load-com) (if (setq ent (car (entsel))) (progn (vlax-invoke-method (vlax-ename->vla-object ent) 'getboundingbox 'minpt 'maxpt) (setq pt1 (trans (vlax-safearray->list minpt) 0 ent)) (setq pt2 (trans (vlax-safearray->list maxpt) 0 ent)) (list (- (car pt2)(car pt1))(- (cadr pt2)(cadr pt1))) ) ) ) using this i am able to select only single object.But i want all objects in the current drawing to be selected and get bounding box for the drawing. help me Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 10, 2011 Share Posted September 10, 2011 This might be useful ..... (vla-zoomextents (vlax-get-acad-object)) (setq MinP (getvar 'vsmin)) (setq MaxP (getvar 'vsmax)) Tharwat Quote Link to comment Share on other sites More sharing options...
kalai Posted September 10, 2011 Author Share Posted September 10, 2011 thanks Tharwat, it works fine Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 10, 2011 Share Posted September 10, 2011 You're welcome Kalai . Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 10, 2011 Share Posted September 10, 2011 This will return the BoundingBox of a supplied SelectionSet: ([color=BLUE]defun[/color] LM:SSBoundingBox ( ss [color=BLUE]/[/color] i l1 l2 ll ur ) [color=GREEN];; © Lee Mac 2011[/color] ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] i ([color=BLUE]sslength[/color] ss)) ([color=BLUE]vla-getboundingbox[/color] ([color=BLUE]vlax-ename->vla-object[/color] ([color=BLUE]ssname[/color] ss ([color=BLUE]setq[/color] i ([color=BLUE]1-[/color] i)))) 'll 'ur) ([color=BLUE]setq[/color] l1 ([color=BLUE]cons[/color] ([color=BLUE]vlax-safearray->list[/color] ll) l1) l2 ([color=BLUE]cons[/color] ([color=BLUE]vlax-safearray->list[/color] ur) l2) ) ) ([color=BLUE]mapcar[/color] '([color=BLUE]lambda[/color] ( a b ) ([color=BLUE]apply[/color] '[color=BLUE]mapcar[/color] ([color=BLUE]cons[/color] 'a b))) ([color=BLUE]list[/color] [color=BLUE]min[/color] [color=BLUE]max[/color]) ([color=BLUE]list[/color] l1 l2)) ) Here is a function to test it: ([color=BLUE]defun[/color] c:test ( [color=BLUE]/[/color] ss bb ) ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]setq[/color] ss ([color=BLUE]ssget[/color])) ([color=BLUE]setq[/color] bb (LM:SSBoundingBox ss)) ) ([color=BLUE]entmakex[/color] ([color=BLUE]list[/color] ([color=BLUE]cons[/color] 0 [color=MAROON]"LWPOLYLINE"[/color]) ([color=BLUE]cons[/color] 100 [color=MAROON]"AcDbEntity"[/color]) ([color=BLUE]cons[/color] 100 [color=MAROON]"AcDbPolyline"[/color]) ([color=BLUE]cons[/color] 90 4) ([color=BLUE]cons[/color] 70 1) ([color=BLUE]list[/color] 10 ([color=BLUE]caar[/color] bb) ([color=BLUE]cadar[/color] bb)) ([color=BLUE]list[/color] 10 ([color=BLUE]caadr[/color] bb) ([color=BLUE]cadar[/color] bb)) ([color=BLUE]list[/color] 10 ([color=BLUE]caadr[/color] bb) ([color=BLUE]cadadr[/color] bb)) ([color=BLUE]list[/color] 10 ([color=BLUE]caar[/color] bb) ([color=BLUE]cadadr[/color] bb)) ) ) ) ([color=BLUE]princ[/color]) ) ([color=blue]vl-load-com[/color]) Another variation here. Quote Link to comment Share on other sites More sharing options...
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.