Suppose you have a nested BlockReference tree, to compute the cumulative transformation that will be applied to the leaf of the tree you need to multiply in cascade the transformation of each BlockReference.

The transformation of a BlockReference is given by the BlockReference.Transformation multiplied by the inverse translation of its Block.BasePoint.

The code below demonstrates how to compute the cumulative transformation of a tree of BlockReference.

Each node of the tree, meaning each block, contains just another BlockReference except for the leaf which contains the actual entity.

private Transformation GetTransformation(BlockReference br) { Block b = singleViewportLayout1.Blocks[br.BlockName]; Transformation innerTransf; if (b.Entities[0] is BlockReference) // Get the transformation of the subtree innerTransf = GetTransformation((BlockReference)b.Entities[0]); else { innerTransf = new Identity(); // I arrived at the leaf } // return the cumulative transformation return br.Transformation * new Translation(-b.BasePoint.X, -b.BasePoint.Y, -b.BasePoint.Z) * innerTransf; }

## Comments

Please sign in to leave a comment.