- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello!
In my work, I commonly make part files with multiple model states representing different sections of the same assembly that I need to be able to pull into an assembly, but the number of sections varies depending on the assembly. The catch is that in the same part file I may or may not have in-process model states for each of those sections as well. I'm working on making a rule to automatically place the sections into an assembly, but I haven't been able to figure out how to ignore the in-process model states.
Below is what I have so far that already works as long as I don't have any in-process model states. The lines that are commented out are where I was attempting to figure out how to read the names of the model states in the component.
If ThisDoc.Document.DocumentType = kAssemblyDocumentObject
Dim oADoc As AssemblyDocument = ThisDoc.Document
Dim oDef As AssemblyComponentDefinition = oADoc.ComponentDefinition
Dim oPDoc As PartDocument = ThisApplication.Documents.ItemByName("C:\Work\Inventor\TEMP\assembly test\part test.ipt")
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim ModelStateComponent(0 To 4)
If oPDef.ModelStates.Count > 1
For i = 1 To oPDef.ModelStates.Count - 1
' If oPDef.ModelStates.
' ' Do Nothing because the in-process part doesn't need to be added to the assembly
' Else
ModelStateComponent(i-1) = Components.AddWithModelState("Part:" & i, "part test.ipt", "Section " & i, , True)
' End If
Next
Else
Dim componentA = Components.Add("Part:1", "part test.ipt", , True)
End If
Else
MessageBox.Show("This rule should only be run in an assembly document.")
End If
Let me know if I need to explain a little more, or if there are any questions.
Any help would be greatly appreciated!
Solved! Go to Solution.