- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The API notes that kWeldsComponentDefinitionObject is derived from kPartComponentDefinitionObject. This doesn't make perfect sense since (I think) this is the "Welds" node that shows the beads in the browser for a Weldment Assembly, but the data lives in the assembly document; it is not a unique file. It does seem to count as a "LeafNode" though when traversing the assembly using something like the code found in this post.
Anyway, assuming that it is derived from the kPartComponentDefinition, and that's correct...
When a conditional statement is used to look for only assembly occurrences, these welds make it through.
This came up because I was trying to iterate through an assembly and apply a ModelState to any assembly document, and ModelState cannot be applied to weld components, so it was throwing an error.
I know just enough of OOP to dig myself a nice hole, but not enough to get out sometimes. Is this a bug, or am I thinking of this wrong?
I made the code below to demonstrate what's confusing me. Please note that this routine isn't iterative, so it needs to be run directly on an assembly that has been converted to a weldment
Sub main()
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
'Get Active Document Component Definition
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oDoc.ComponentDefinition
If oAsmCompDef.Type <> kWeldmentComponentDefinitionObject Then
MessageBox.Show("This can only be demonstated on a Weldment document. Please run this program in a Weldment Assembly with the ""Welds"" shown in the Browser " & oAsmCompDef.Type)
Else
For Each oOcc In oAsmCompDef.Occurrences
Dim docFNmae As String
Dim oOccDef As ComponentDefinition
oOccDef = oOcc.Definition
oOccName = oOcc.Name
oOccType = oOccDef.Type
If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
If oOcc.Definition.Type = ObjectTypeEnum.kWeldsComponentDefinitionObject
MessageBox.Show("This occurence, I think, is the ""Welds"" shown in the browser & ComponentDefinition = kWeldsComponenetDefinitionObject. According to the API it is supposed to be derived from the kPartComponentDefinitionObject but is making it through a ComponenetDefinition = kAssemblyComponentDefinition conditional statement." & vbCr & vbCr &" ComponentDefinition.Type: " & oOccType)
End If
End If
Next
End If
End Sub
Solved! Go to Solution.