If you like to use multi-volume bodies as control models for assemblies, you can save yourself the trouble of naming the files when exporting to an assembly when you need to distinguish the bodies, e.g. number them. Manually overwriting names/numbers would be inconvenient. Use the following iLogic rule (macro) to automate such 'renaming by numbering'.
The solids will be named (renamed) according to the specified prefix followed by a numeric series.
'------- start of iLogic ------
'original idea: B.Han
'check that this active document is a part file
Dim partDoc As PartDocument
If ThisApplication.ActiveDocument.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then
MessageBox.Show("Please open a Part document", "iLogic")
Return
End If
'define the active document
partDoc = ThisApplication.ActiveDocument
'check for custom iProperty and add it if not found
Dim prefixPropertyName As String = "Prefix"
Dim customPropertySet = partDoc.PropertySets.Item("Inventor User Defined Properties")
Dim prefixProperty As Inventor.Property
Try
prefixProperty = customPropertySet.Item(prefixPropertyName)
Catch
' Assume error means not found
prefixProperty = customPropertySet.Add("", prefixPropertyName)
End Try
'write the part number to the Prefix iProperty if it is empty
If String.IsNullOrEmpty(prefixProperty.Value.ToString()) Then
prefixProperty.Value = iProperties.Value("Project", "Part Number") & "_"
End If
'get input from user
Dim bodyPrefix = InputBox("Enter a prefix for the solid body names", "iLogic", prefixProperty.Value.ToString())
'write input back to custom iProperty
prefixProperty.Value = bodyPrefix
'rename all solid bodies incrementing suffix
Dim i As Integer = 1
For Each solid As SurfaceBody In partDoc.ComponentDefinition.SurfaceBodies
solid.Name = String.Format("{0}{1:00}", bodyPrefix, i)
i += 1
Next
'------- End Of iLogic ------
Submited by: M.Depta, thanks