Hi @madstrolle
Here is a basic example.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Where the setup is something like this:


Resulting in this:


'This rule expects the following:
' an original Path such As: "C:\Temp\Projects\41826\41826_123456.iam"
' a parameter called current_ProjectNumber
' a parameter called new_ProjectNumber, with a value such as 55555
'
'the result would be a new path such as: "C:\Temp\Projects\55555\55555_123456.iam"
Sub Main
Dim oDoc As AssemblyDocument
oDoc = ThisDoc.Document
oNewname = UpdateName(oDoc)
If oDoc.ComponentDefinition.Occurrences.Count > 0 Then
Call TraverseAssembly(oDoc.ComponentDefinition.Occurrences, oNewname)
End If
If Not oNewname = oDoc.FullFileName Then
oDoc.SaveAs(oNewname, False)
End If
InventorVb.DocumentUpdate()
End Sub
Sub TraverseAssembly(Occurrences As ComponentOccurrences, oNewname As String)
On Error Resume Next
Dim oOcc As ComponentOccurrence
Dim oDoc As Document
For Each oOcc In Occurrences
If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
Call TraverseAssembly(oOcc.SubOccurrences, oNewname)
End If
oDoc = oOcc.Definition.Document
oNewname = UpdateName(oDoc)
oDoc.SaveAs(oNewname, False)
oDoc.PropertySets("Design Tracking Properties")("Part Number").Value = IO.Path.GetFileName(oDoc.fullfilename)
Next
End Sub
Function UpdateName(oDoc As Document)
Dim sName As String = oDoc.FullFileName
Dim sPath As String = IO.Path.GetDirectoryName(sName)
Dim sSplitArray = Split(sPath,"\")
Dim sCurPN As String = sSplitArray(sSplitArray.Length - 1)
Dim sNewPN As String = Trim(Parameter("new_ProjectNumber"))
Parameter("current_ProjectNumber") = sNewPN
Dim oNewname As String = Replace(sName, sCurPN, sNewPN)
sFolderPath = IO.Path.GetDirectoryName(oNewname)
If Not System.IO.Directory.Exists(sFolderPath) Then
System.IO.Directory.CreateDirectory(sFolderPath)
End If
Return oNewname
End Function
