How to find subassembly's position?

How to find subassembly's position?

Anonymous
Not applicable
520 Views
2 Replies
Message 1 of 3

How to find subassembly's position?

Anonymous
Not applicable

Is there a way to find a position (transform or coordinates) of a subassembly (nested assembly?) into a parent assembly?

 

For example, I need to figure out where ChildAssembly:1 and ChildAssembly:2 placed into the RootAssembly.

RootAssembly
    ChildAssembly:1
        OneMoreAssembly
            Part1
            Part2
    ChildAssembly:2
        OneMoreAssembly
            Part1
            Part2

 

0 Likes
Accepted solutions (2)
521 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Accepted solution

I'm not sure if you have a specific point you're looking for on your subassys, but I just used the Origin. I don't know if you're looking for something more but this will give the coordinates of the origin of the specified subassembly

 

Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim oDef As ComponentDefinition = oDoc.ComponentDefinition
Dim oPart As ComponentOccurrence = oDef.Occurrences.ItemByName("Assembly2:1") 'AssemblyName Here
Dim oCenter As WorkPoint = oPart.Definition.WorkPoints.Item(1)

Dim oX,oY,oZ As Double
Dim oCenterProxy As WorkPoint

oPart.CreateGeometryProxy(oCenter,oCenterProxy)

'Divide by 2.54 to convert cm to in
oX = Round(oCenterProxy.Point.X/2.54, 3)
oY = Round(oCenterProxy.Point.Y/2.54, 3)
oZ = Round(oCenterProxy.Point.Z/2.54, 3)

MsgBox(oX & " : " & oY & " : " & oZ)

  

0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

Also, there is a Transform for which one can get data:

 

 

AssemblyDocument assembly;
foreach (ComponentOccurrence compOccurence in assembly.ComponentDefinition.Occurrences)
{
    if (compOccurence.DefinitionDocumentType == DocumentTypeEnum.kAssemblyDocumentObject)
    {
        double[] transform = new double[4 * 4];
        compOccurence.Transformation.GetMatrixData(ref transform);
    }
}

 

 

 

0 Likes