WorkPoint position in global coordinate system

WorkPoint position in global coordinate system

johan.bengtson
Explorer Explorer
637 Views
0 Replies
Message 1 of 1

WorkPoint position in global coordinate system

johan.bengtson
Explorer
Explorer

I want to the get the position of the Center Point of a part in the global coordinate system of the document.


If I use the measure tool in the user interface and measure from Origin Center Point of the document to the Center Point of the part I get the coordinates I would like to get using Inventor API.

 

I have a WorkPoint which is the Center Point of a part.
The part is placed in an assembly which also has a Center Point. The assembly is offset from it´s parent.

 

If I use the following code I get the coordinates of the Center Point relative to the assembly it is included in,
but I would also like it to consider the offset of the parent assembly of the part.

 

Or could I get the coordinates of the placement of the assembly somehow?

 

Public Function GetCenterPointProxy(name As String) As WorkPointProxy
    Dim invApp As Inventor.Application
    Set invApp = ThisApplication
    Dim invDocs As Documents
    Set invDocs = invApp.Documents
    Dim invDocument As Document
    For Each invDocument In invDocs
        If invDocument.DocumentType = kAssemblyDocumentObject Then
            Dim oAsmDoc As AssemblyDocument
            Set oAsmDoc = invDocument
            Dim oAsmCompDef As AssemblyComponentDefinition
            Set oAsmCompDef = oAsmDoc.ComponentDefinition
            Dim oCompOccur As ComponentOccurrence
            Dim oUCS As UserCoordinateSystem
            
            For Each oCompOccur In oAsmCompDef.Occurrences
                If oCompOccur.DefinitionDocumentType = kPartDocumentObject Then
                    If oCompOccur.Suppressed = False Then
                        Dim oPartCompDef As PartComponentDefinition
                        Set oPartCompDef = oCompOccur.Definition
                        If oCompOccur.name = name Then
                            For Each oWP In oPartCompDef.WorkPoints
                                If oWP.name = "Center Point" Then
                                    Dim oWorkPointProxy As WorkPointProxy
                                    Call oCompOccur.CreateGeometryProxy(oWP, oWorkPointProxy)
                                    Set GetCenterPointProxy = oWorkPointProxy
                                End If
                            Next
                        End If
                    End If
                End If
            Next
        End If
    Next
End Function

 

0 Likes
638 Views
0 Replies
Replies (0)