Jump to content

Bounding box of dynamic block ignoring other visibility states?


Hopeless Turtle

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 

 

image.png.92c62d0f6cfe10b6077325e689e728fb.png

 

 

Link to comment
Share on other sites

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 by BIGAL
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by BIGAL
Link to comment
Share on other sites

  • 1 year later...

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.

Link to comment
Share on other sites

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. 

layout1.png.9d03ab6cd7fbd5b4a128c15fbe0c31bf.png

 

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.

 

image.png.82ed84f489ae2516903398d8d37e2c95.png

Edited by BIGAL
Link to comment
Share on other sites

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")
   )

 

Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
Share on other sites

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...