- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a workpoint in a component file that is some unknown levels down in an assembly. I want to get the location of this workpoint relative to the top level assembly. What is the best way to get the coordinates?
Currently I am traversing the assembly and creating a proxy object, but this seems to only give me the correct coordinates down a couple of levels.
My understanding is that a proxy object should get the entire path of the component all the way down the assembly structure, as stated here:
"...A proxy is a reference to an object that exists outside the top-level component, and the proxy defines the full path from the top-level down to the object. The path is made up of a list of occurrences, and the final item in the path is the object itself. ..." quote from here:
So it seems that because I am creating the proxy at the subassembly, at the the level in which I find it as I traverse the components, the proxy does not contain the full path and therefor doesn't report the correct coordinates.
Thanks in advance.
Curtis
See attached example files ( Inv 2022)
Here the point's coordinates are at 2.222, 1.866, 4.444 in the assembly as shown by the sketch dims
Public Sub Main()
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
Dim oAsmDef As AssemblyComponentDefinition
oAsmDef = oAsmDoc.ComponentDefinition
Dim oOccs As ComponentOccurrences = oAsmDoc.ComponentDefinition.Occurrences
Call TraverseAssembly(oAsmDef, oOccs)
End Sub
Function TraverseAssembly(oAsmDef As AssemblyComponentDefinition, oOccs As ComponentOccurrences)
Dim oWPProxy As WorkPointProxy 'Proxy
Dim oOcc As ComponentOccurrence
For Each oOcc In oOccs
Dim oWP As WorkPoint
For Each oWP In oOcc.Definition.WorkPoints
If Not UCase(oWP.Name).Contains("TEST") Then Continue For
Call oOcc.CreateGeometryProxy(oWP, oWPProxy)
Dim xCoord, yCoord, zCoord As Double
xCoord = oWPProxy.Point.X
yCoord = oWPProxy.Point.Y
zCoord = oWPProxy.Point.Z
oLine = "X: " & Round(xCoord, 3) & vbLf & "Y: " & Round(yCoord, 3) & vbLf & "Z: " & Round(zCoord, 3)
Logger.Info(oLine)
MsgBox(oLine, , oWP.Name )
Next
If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
'step into subassembly
oSubOccs = oOcc.Definition.Document.ComponentDefinition.Occurrences
Call TraverseAssembly(oAsmDef, oSubOccs)
End If
Next
End Function
Solved! Go to Solution.