Hopeless Turtle Posted February 24, 2023 Share Posted February 24, 2023 I'm trying to find the bounding box of a dynamic block, however this block has multiple visibility states that all seem included in the bounding box provided by vla-getboundingbox. Is there a way to find the bounding box of only the visible geometry? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 25, 2023 Share Posted February 25, 2023 Explain more what your doing, why do you need the bounding box ? Quote Link to comment Share on other sites More sharing options...
Hopeless Turtle Posted February 27, 2023 Author Share Posted February 27, 2023 I'm working with a dynamic block of a rectangular shelf (essentially), it's using visibility states to change direction to face NESW. The point of rotation for this block is the midpoint of one of the long sides. For instance, if you changed the direction from N to S, it would mirror over the bottom line. I realize this is a poor method to rotate a dynamic block but I'm trying to accommodate old designs without too much fuss. The goal is to count the floor anchors which happen on each short side. These shelves are generally attached to one another so I can't just count the number of blocks as the short sides are shared in the middle of each pair. There are usually several lines of shelves, so I need to detect these chains and count accordingly. I have all of that code working assuming the bounding box changed with the visibility state, but I discovered this unfortunate fact while troubleshooting the issue. Quote Link to comment Share on other sites More sharing options...
devitg Posted February 27, 2023 Share Posted February 27, 2023 1 hour ago, Hopeless Turtle said: I'm working with a dynamic block of a rectangular shelf (essentially), it's using visibility states to change direction to face NESW. The point of rotation for this block is the midpoint of one of the long sides. For instance, if you changed the direction from N to S, it would mirror over the bottom line. I realize this is a poor method to rotate a dynamic block but I'm trying to accommodate old designs without too much fuss. The goal is to count the floor anchors which happen on each short side. These shelves are generally attached to one another so I can't just count the number of blocks as the short sides are shared in the middle of each pair. There are usually several lines of shelves, so I need to detect these chains and count accordingly. I have all of that code working assuming the bounding box changed with the visibility state, but I discovered this unfortunate fact while troubleshooting the issue. @Hopeless Turtle, please upload your dwg with such shelf block reference I did a test on a blkref with visibility and made a polyline [red] to it's bounding box , it include only the geometrical ents Quote Link to comment Share on other sites More sharing options...
Hopeless Turtle Posted February 27, 2023 Author Share Posted February 27, 2023 I've had a program draw the bounding box in red and the desired box in green. Note how the desired box only includes visible geometry. Bounding Box Problem.dwg Quote Link to comment Share on other sites More sharing options...
devitg Posted February 27, 2023 Share Posted February 27, 2023 3 hours ago, Hopeless Turtle said: I've had a program draw the bounding box in red and the desired box in green. Note how the desired box only includes visible geometry. Bounding Box Problem.dwg 49.36 kB · 0 downloads @Hopeless Turtle, would you, please, Upload the program used to get the green box? Quote Link to comment Share on other sites More sharing options...
Hopeless Turtle Posted February 27, 2023 Author Share Posted February 27, 2023 I drew that myself as the desired output. In case it was unclear what I meant by visible geometry. Quote Link to comment Share on other sites More sharing options...
devitg Posted February 27, 2023 Share Posted February 27, 2023 50 minutes ago, Hopeless Turtle said: I drew that myself as the desired output. In case it was unclear what I meant by visible geometry. @Hopeless Turtle, Ok , understood. As I can see , the boundingbox , return the red one . Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 27, 2023 Share Posted February 27, 2023 (edited) You can get a dyn block then retrieve its current visibility state and any other property. So don't need to make a bounding box. This can be used in conjunction with a SSGET. ; big thanks to Lee mac ;; Get Dynamic Block Visibility State - Lee Mac ;; Returns the value of the Visibility Parameter of a Dynamic Block (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; Returns: [str] Value of Visibility Parameter, else nil (defun LM:getvisibilitystate ( blk / vis ) (if (setq vis (LM:getvisibilityparametername blk)) (LM:getdynpropvalue blk vis) ) ) ;; Get Visibility Parameter Name - Lee Mac ;; Returns the name of the Visibility Parameter of a Dynamic Block (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; Returns: [str] Name of Visibility Parameter, else nil (defun LM:getvisibilityparametername ( blk / vis ) (if (and (vlax-property-available-p blk 'effectivename) (setq blk (vla-item (vla-get-blocks (vla-get-document blk)) (vla-get-effectivename blk) ) ) (= :vlax-true (vla-get-isdynamicblock blk)) (= :vlax-true (vla-get-hasextensiondictionary blk)) (setq vis (vl-some '(lambda ( pair ) (if (and (= 360 (car pair)) (= "BLOCKVISIBILITYPARAMETER" (cdr (assoc 0 (entget (cdr pair))))) ) (cdr pair) ) ) (dictsearch (vlax-vla-object->ename (vla-getextensiondictionary blk)) "ACAD_ENHANCEDBLOCK" ) ) ) ) (cdr (assoc 301 (entget vis))) ) ) ;; Get Dynamic Block Property Value - Lee Mac ;; Returns the value of a Dynamic Block property (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; prp - [str] Dynamic Block property name (case-insensitive) (defun LM:getdynpropvalue ( blk prp ) (setq prp (strcase prp)) (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'value))) (vlax-invoke blk 'getdynamicblockproperties) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; starts here (defun c:wow ( / ) (LM:getvisibilitystate (vlax-ename->vla-object (car (entsel "\pick dynamic block ")))) ) Edited February 27, 2023 by BIGAL Quote Link to comment Share on other sites More sharing options...
Hopeless Turtle Posted February 28, 2023 Author Share Posted February 28, 2023 I appreciate the attempts, but I don't think there's a clear understanding. I'm not trying to find the visibility state, I want to draw a bounding box around the visible geometry. It doesn't seem to be possible with obvious methods. At this point I've moved on to alternative methods to accomplish my goals, but this might be worth exploring in the future. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 28, 2023 Share Posted February 28, 2023 (edited) As you made the dynamic block, and the 4 visibilty states you know the size of a bounding box that would match each state, so when you select a dynamic block you can get its "effective" name and visibilty state so could then do a look of both of those and get the bounding box size, obviously scale may be involved. Without going into it you know the insertion point so can work out the new 4 corners. (("east" 100 50) ("south" 50 100)........... How many blocks by effective name are involved 1, 2, 3 or heaps ? Edited February 28, 2023 by BIGAL Quote Link to comment Share on other sites More sharing options...
rcb007 Posted March 18 Share Posted March 18 BigAl, would you elaborate on how you would setup the calcs of the four corners? I am messing with the as well, When I apply the boundary box to it, it shows the whole extents of what is in the dynamic block. The block I have, is a basic retangle to repersent the viewport of each scale. (if the block is set at a 20 scale, then the boundary box applies to the max 100 scale) The insertion point is not the center of the dynamic block. Thanks for the guidance. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 18 Share Posted March 18 Try my block reference bounding box function, posted here. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 19 Share Posted March 19 (edited) So you have this, when i generate the rectangs I know there size len& wid and importantly scale this is stored in the dwg. The rectang is the size of the Mview. So layouts are then made. You can add, delete, move or rotate the rectangs, just not change size, but different sizes can be made, but just not all in one go. Re dynamic block can just change the size of a 1x1 rectang to suit the sheet size and at scale update say Distance 1 & Distance 2, hidden behind this dcl is all the values required, use Lee's dynamic block lisps to update. Then just copy copy. Edited March 19 by BIGAL Quote Link to comment Share on other sites More sharing options...
rcb007 Posted March 20 Share Posted March 20 Thanks Guys. BigAl, that is an interesting approach. Lee, thank you for referencing the the GetBlockLimits. It was what I was looking for. I added this to it, and everything seems to work. (progn (setq o (vlax-ename->vla-object (entlast))) (vlax-invoke-method o 'GetBoundingBox 'a 'b) (setq a (vlax-safearray->list a) b (vlax-safearray->list b) ) (vl-cmdf "_.zoom" a b "_.zoom" "scale" "1/10xp") ) Quote Link to comment Share on other sites More sharing options...
JET-X_99 Posted April 2 Share Posted April 2 I have this block. It has attribute text in it. I use a field to reference info to fill in the necessary mk. Numbers for parts. As you can see the mk#'s have varying lengths. What i'd like to happen is for the block to stretch or shrink depending on the length of the attributed text without having to manually stretch it or do anything other than change the text that is contained within it. Much like LEE MAC'S ASSOCIATIVE TEXTBOX program that works beautifully! HELP.dwg 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.