@J-Camper @Anonymous
Hello,
I managed to make this code:
Sub Main
If ThisApplication.ActiveDocumentType <> kAssemblyDocumentObject Then MessageBox.Show("This rule is designed to only work in assembly documents.", "Wrong Document Type") : Exit Sub
Dim parentDoc As AssemblyDocument = ThisApplication.ActiveDocument
'Do anything unique to main assembly
Call AssemblyRunner(parentDoc)
End Sub
Sub AssemblyRunner(aDoc As AssemblyDocument)
'Do things to the assembly file if any
'MessageBox.Show(aDoc.DisplayName, "Assembly:")
'Start Looping
For Each oOcc As ComponentOccurrence In aDoc.ComponentDefinition.Occurrences
If oOcc.DefinitionDocumentType = kAssemblyDocumentObject
Dim GetOccName As String = oOcc.Name
If GetOccName.Contains(":") Then
Dim words As String() = GetOccName.Split(":")
oEerst = words(0)
oTweede = words(1)
'Dim CurFileName As String
'get the selected item document occurrence name
doc = oOcc.Definition.Document
'get the path and file name of the selected item
CurFileName = doc.FullFileName
'defines backslash as the subdirectory separator
Dim strCharSep As String = System.IO.Path.DirectorySeparatorChar
'find the postion of the last backslash in the path
FNamePos = InStrRev(CurFileName, "\", -1)
'get the file name with the file extension
Name = Right(CurFileName, Len(CurFileName) - FNamePos)
'get the file name (without extension)
ShortName = Left(Name, Len(Name) - 4)
'get the path of the folder containing the file
Folder_Location = Left(CurFileName, Len(CurFileName) - Len(Name))
oOcc.Name = ShortName & ":" & words(1)
End If
Call AssemblyRunner(oOcc.Definition.Document)
Else If oOcc.DefinitionDocumentType = kPartDocumentObject
Dim GetOccName As String = oOcc.Name
If GetOccName.Contains(":") Then
Dim words As String() = GetOccName.Split(":")
oEerst = words(0)
oTweede = words(1)
'Dim CurFileName As String
'get the selected item document occurrence name
doc = oOcc.Definition.Document
'get the path and file name of the selected item
CurFileName = doc.FullFileName
'defines backslash as the subdirectory separator
Dim strCharSep As String = System.IO.Path.DirectorySeparatorChar
'find the postion of the last backslash in the path
FNamePos = InStrRev(CurFileName, "\", -1)
'get the file name with the file extension
Name = Right(CurFileName, Len(CurFileName) - FNamePos)
'get the file name (without extension)
ShortName = Left(Name, Len(Name) - 4)
'get the path of the folder containing the file
Folder_Location = Left(CurFileName, Len(CurFileName) - Len(Name))
oOcc.Name = ShortName & ":" & words(1)
End If
'Call PartRunner(oOcc.Definition.Document, aDoc)
End If
Next
End Sub
But the thing is that when i have a suppressed part it gives me an error. Is it possible to tell the ilogic that when it has a supressed part it also has to change the name?