TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Marc'Antonio Alessi on February 12, 2020, 05:10:48 AM

Title: BoundingBox of dynamicblocks "By Layer"
Post by: Marc'Antonio Alessi 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)?
Title: Re: BoundingBox of dynamicblocks "By Layer"
Post by: Lee Mac on February 12, 2020, 08:11:54 AM
This (http://www.theswamp.org/index.php?topic=48405.msg534887#msg534887) 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.
Title: Re: BoundingBox of dynamicblocks "By Layer"
Post by: roy_043 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)?
Title: Re: BoundingBox of dynamicblocks "By Layer"
Post by: CincyJeff 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.
Title: Re: BoundingBox of dynamicblocks "By Layer"
Post by: Marc'Antonio Alessi 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.
Title: Re: BoundingBox of dynamicblocks "By Layer"
Post by: roy_043 on February 12, 2020, 01:26:13 PM
In your example you would need to check the "*U232" block definition.
Title: Re: BoundingBox of dynamicblocks "By Layer"
Post by: Marc'Antonio Alessi 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.  :-)
Title: Re: BoundingBox of dynamicblocks "By Layer"
Post by: Marc'Antonio Alessi 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-)
Title: Re: BoundingBox of dynamicblocks "By Layer"
Post by: Stefan 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)
Title: Re: BoundingBox of dynamicblocks "By Layer"
Post by: Marc'Antonio Alessi 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: