Object snap on BlockReference entity

To make object snap work on BlockReference entities you need first to call:

model1.Entities.SetCurrent(myBlockReference);

then to transform the resulting snap points using the following transformation:

Transformation t = myBlockReference.AccumulatedParentsTransforms; 
Point3D p2 = t * p1; 
Was this article helpful?
2 out of 2 found this helpful
Have more questions? Submit a request

Comments

4 comments
  • Hello Alberto.

     

    I have i think exact this problem. I would like to select Face,Edge,Vertex with VisiblePyPickDynamic on a Assambly STEP. The STEP File contains 2 or more parts.

     

    Can you give me please an Example.

     

    Thank you 

    0
    Comment actions Permalink
  • Please check the "Edit Assembly" command of the AssemblyDemo source code sample. Using this command you'll be able to navigate the assembly tree and possibly to activate selection on the desired item.

    0
    Comment actions Permalink
  • Another, more fast, approach here is to work on BlockReference 4x4 transformation matrix. Applying the inverse of the matrix you can bring back object coordinates in the Block definition space and perform snapping without the need of the expensive SetCurrent() call.

    0
    Comment actions Permalink

  • It is convenient, for those drawings full of nested blockreferences,  to use the overloaded GetCrossingEntities() method (available from build 12.0.472) to avoid the SetCurrent() method to speed up the snapping. We integrated this new approach within our DrafingDemo sample code. 

    0
    Comment actions Permalink

Please sign in to leave a comment.