Hi @swalton
Many avenues to take, my personal one with what you describe is to filter the occurrences based on your criteria and customize the iproperties as you need. This rule identifies the runs and renames them. You can comment in or out out this as you need. I turned it off for now but you can see the structure needed. Any help needed just ask.
Sub Main()
Dim asmDef As AssemblyComponentDefinition = ThisApplication.ActiveDocument.ComponentDefinition
For Each occ As ComponentOccurrence In asmDef.Occurrences.AllReferencedOccurrences(asmDef)
Dim occDoc As Document = occ.Definition.Document
Dim bIsRunDocument As Boolean = occDoc.DocumentInterests.HasInterest("Piping Runs Environment")
If bIsRunDocument = False Then Continue For
'Logger.Info(occDoc.FullFileName)
RenameRun (occDoc)
Next
End Sub
'Rename the T&P Runs when passing in the Main Tube and Pipe Run Assembly Document
Private Sub RenameRun (occDoc)
'[ create list of runs
Dim asmDef As AssemblyComponentDefinition = occDoc.ComponentDefinition
Dim runList As New List(Of String)
Dim runOccs As New List(Of ComponentOccurrence)
For Each occ As ComponentOccurrence In asmDef.Occurrences.AllReferencedOccurrences(asmDef)
occDoc = occ.Definition.Document
Dim bIsRunDocument As Boolean = occDoc.DocumentInterests.HasInterest("Piping Run Environment")
If bIsRunDocument = False Then Continue For
'If occ.Name = "Assembly Fittings" Or occ.Name.Contains("STD")Then Continue For
runOccs.Add(occ)
runList.Add(occ.Name)
Next
runList.Sort
d0 = InputListBox("Prompt", runList, d0, Title := "Title", ListName := "List")
For Each occ As ComponentOccurrence In runOccs
occDoc = occ.Definition.Document
'[Renaming occurrences
' Dim index As Integer = occ.Name.LastIndexOf(":")
' If Not index = -1 Then
' multiSpoolName = Left(occ.Name, index)
' Else
' multiSpoolName = occ.Name
' End If
']
Dim oDTP As PropertySet = occDoc.PropertySets.Item("Design Tracking Properties")
Dim oSP As PropertySet = occDoc.PropertySets.Item("Inventor Document Summary Information")
' oDTP.Item("Part Number").Value = multiSpoolName
' oDTP.Item("Description").Value = multiSpoolName
' oSP.Item("Category").Value = "SPOOL"
Dim multiOccs As ComponentOccurrencesEnumerator = asmDef.Occurrences.AllReferencedOccurrences(occ.Definition.Document)
If multiOccs.Count > 1 Then
For Each occ1 In multiOccs
'If occ1.Name.Contains("SP") Or occ1.Name.Contains("VP")Then Continue For
If Not occ1 Is multiOccs.Item(1) Then
'Logger.Info(occ.Name)
If occ1.Name.Contains("Run") Then
occ1.Name = multiOccs.Item(1).Name & ":" & multiOccs.Count
End If
End If
Next
Else
'[Renaming occurrences
' If occ.Name.Contains("Run") Then
' occ.Name = Replace(occ.Name,"Run ","SP")
' End If
']
End If
'runList.Add(occNewName)
Next
End Sub
If this solved a problem, please click (accept) as solution.
Or if this helped you, please, click (like)
Regards
Alan