
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am hoping somebody can help me with this VBA sub.
I want to look through a large assembly model and pick out the parts based upon their node names (got that far)
Then I want to extract the X , Y , Z values of that parts origin (or center point as it's labeled in the feature tree)
so I can use them in a string:
Public Sub TP_POINTS1()
Dim qty As Integer
qty = 1
' Get the active assembly.
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument
' Get the assembly component definition.
Dim oAsmDef As AssemblyComponentDefinition
Set oAsmDef = oAsmDoc.ComponentDefinition
' Get all of the leaf occurrences of the assembly.
Dim oLeafOccs As ComponentOccurrencesEnumerator
Set oLeafOccs = oAsmDef.Occurrences.AllLeafOccurrences
' Iterate through the occurrences and print the name.
Dim oOcc As ComponentOccurrence
For Each oOcc In oLeafOccs
'select only the parts that have the correct name
Dim oName As String
Dim strOrig As String
Dim leftstring As String
strOrig = oOcc.name
leftstring = Left(strOrig, InStr(strOrig, ":"))
oName = Right(leftstring, 5)
If oName = "(TP):" Then
'==============================
'==============================
qty = qty + 1
End If
Next
End Sub
Solved! Go to Solution.