Author Topic: BoundingBox of dynamicblocks "By Layer"  (Read 2707 times)

0 Members and 1 Guest are viewing this topic.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
BoundingBox of dynamicblocks "By Layer"
« on: February 12, 2020, 05:10:48 AM »
In my case all the blocks are not scaled > scale xyz = 1

I need to calculate the BoundingBox of dynamicblocks (INSERT) excluding certain layers, currently I am able to calculate the BoundingBox processing the information of the block definition (non-dynamic BLOCK) and excluding certain entities or layers and transforming the two points obtained for each inserted block (INSERT) with Matrix Transformation functions (thanks to Lee Mac, gile, Nesterovsky, Wilson, etc.).

This method does not work with dynamic blocks, very simple example:

- Dynamic block with two parameters: length and height
- rectangle on layer A (yellow)
- rectangle on layer B (red)

Question: how to calculate the BoundingBox considering only the entities on layer B (red)?

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: BoundingBox of dynamicblocks "By Layer"
« Reply #1 on: February 12, 2020, 08:11:54 AM »
This should hopefully perform successfully with dynamic blocks - currently the function omits Text & Attributes when calculating the bounding box, but you could easily add additional filters to exclude/include specific objects based on their properties.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: BoundingBox of dynamicblocks "By Layer"
« Reply #2 on: February 12, 2020, 08:35:34 AM »
@Marc'Antonio Alessi:
Are you looking at the correct block definition (the 'normal' name def, not the effective name def)?

CincyJeff

  • Newt
  • Posts: 89
Re: BoundingBox of dynamicblocks "By Layer"
« Reply #3 on: February 12, 2020, 12:15:54 PM »
Look for BlockRef->VisStatesL, try searching just using VisStatesL. It returns a list of entities with each visibility state. You can then extract the entities you want for the bounding box. This works for individual references.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: BoundingBox of dynamicblocks "By Layer"
« Reply #4 on: February 12, 2020, 12:23:30 PM »
@Lee: Now surely I will watch your tip

@Roy: unfortunately I don't know well the topic dynamic blocks, these are some properties of the inserted block about EffectiveName and Name
(I have to calculate the BBox with the measures of the inserted block):

;   EffectiveName (RO) = "Foo"
;   HasAttributes (RO) = -1
;   HasExtensionDictionary (RO) = -1
;   InsUnitsFactor (RO) = 1.0
;   IsDynamicBlock (RO) = -1
...
;   Name = "*U232"
...
;   XEffectiveScaleFactor = 1.0
;   XScaleFactor = 1.0
;   YEffectiveScaleFactor = 1.0
;   YScaleFactor = 1.0
;   ZEffectiveScaleFactor = 1.0
;   ZScaleFactor = 1.0


@CincyJeff: I will have to learn more about DBlocks and VisStatesL

Thanks to all.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: BoundingBox of dynamicblocks "By Layer"
« Reply #5 on: February 12, 2020, 01:26:13 PM »
In your example you would need to check the "*U232" block definition.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: BoundingBox of dynamicblocks "By Layer"
« Reply #6 on: February 12, 2020, 03:24:38 PM »
In your example you would need to check the "*U232" block definition.
Ok tomorrow I will try, thanks again.  :-)

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: BoundingBox of dynamicblocks "By Layer"
« Reply #7 on: February 12, 2020, 03:50:01 PM »
In your example you would need to check the "*U232" block definition.
I have not resisted to try, even if here in Italy it is a little late... everything seems ok for the blocks with linear parameter  :-) :-) :-),
for the visibility parameters it is not correct but for the moment I think it will be enough for me.
Good night.  8-)

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: BoundingBox of dynamicblocks "By Layer"
« Reply #8 on: February 12, 2020, 04:47:28 PM »
I have not resisted to try, even if here in Italy it is a little late... everything seems ok for the blocks with linear parameter  :-) :-) :-),
for the visibility parameters it is not correct but for the moment I think it will be enough for me.
Good night.  8-)
If you have multiple visibility states, you have to filter out the invisible objects.
The objects from other vis_states are just turned invisible when you switch between states.
When you step inside block definition, simple chek
Code - Auto/Visual Lisp: [Select]
  1. (eq (vla-get-visible <obj>) :vlax-true)

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: BoundingBox of dynamicblocks "By Layer"
« Reply #9 on: February 13, 2020, 04:41:14 AM »
I have not resisted to try, even if here in Italy it is a little late... everything seems ok for the blocks with linear parameter  :-) :-) :-),
for the visibility parameters it is not correct but for the moment I think it will be enough for me.
Good night.  8-)
If you have multiple visibility states, you have to filter out the invisible objects.
The objects from other vis_states are just turned invisible when you switch between states.
When you step inside block definition, simple chek
Code - Auto/Visual Lisp: [Select]
  1. (eq (vla-get-visible <obj>) :vlax-true)
ok it seems like a simple solution i will try immediately, thanks.  :-)
Edit: tested > all is OK > grazie mille anche a Lee Mac.  :wink: