Set the offset of components to zero and ground them

<?xml encoding=”UTF-8″>By Adam Nagy

When you are inside an assembly then you can right-click on any of the components in the model tree and inside the iProperties dialog you can set their offset:

OccurrenceProperties
In the API you get/set that information through the Transformation matrix of the Occurrence. That has the component’s position and alignment.

If you simply want to set all the offsets to zero and orient them the same way as the assembly then you just have to use an identity matrix (default of CreateMatrix()) as their Transformation

This is what the code could look like in iLogic:

Dim doc As AssemblyDocument
doc = ThisApplication.ActiveDocument
Dim tr As TransientGeometry
tr = ThisApplication.TransientGeometry
Dim occ As ComponentOccurrence
For Each occ In doc.ComponentDefinition.Occurrences
' If it's suppressed we cannot do
' anything with it
If Not occ.Suppressed Then
Call occ.SetTransformWithoutConstraints( _
tr.CreateMatrix())
occ.Grounded = True
End If
Next

Comments

One response to “Set the offset of components to zero and ground them”

  1. krishna Avatar
    krishna

    to get the same values back could you please share the code

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading