OK @eucci. Then something relatively simple like the following iLogic rule example should work OK for you. It gets the current document, checks if it is either a part or assembly, and if neither, it will exit the rule. Then it calls a small, custom Sub routine to run on the current document...in case it is a part. Then, it will iterate through all the documents being referenced within the current document...in case it is an assembly, and call that routine to run on each of them. The routine will only attempt to do something to the document if it is a part, and only if it has at least 1 body in it. Then it will get that part's Part Number value, and try to set that as the first body's name. Then it updates the current document.
Sub Main
Dim oDoc As Inventor.Document = ThisDoc.Document
If (Not TypeOf oDoc Is PartDocument) And (Not TypeOf oDoc Is AssemblyDocument) Then Return
RenameFirstBodyToPartNumber(oDoc)
For Each oRefDoc As Inventor.Document In oDoc.AllReferencedDocuments
RenameFirstBodyToPartNumber(oRefDoc)
Next
oDoc.Update2(True)
End Sub
Sub RenameFirstBodyToPartNumber(oDoc As Inventor.Document)
If Not TypeOf oDoc Is PartDocument Then Return
Dim oPDoc As PartDocument = oDoc
Dim oBodies As SurfaceBodies = oPDoc.ComponentDefinition.SurfaceBodies
If oBodies.Count = 0 Then Return
Dim sPN As String = oPDoc.PropertySets.Item(3).Item(2).Value 'Part Number
Try : oBodies.Item(1).Name = sPN : Catch : End Try
End Sub
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield

(Not an Autodesk Employee)