@Curtis_Waguespack I want to rename the multibody without to lost the link with the name I put the ruler. I'm using this ruler to rename the bodies with part number although I lost the link to the parameter I logic. I make a video to show this missed.
Sub Main()
'Counts for the number of components in an assembly
Dim counter As Integer = 0
Dim InstNum As String
'Grab the Assembly Document
Dim oDoc As AssemblyDocument
oDoc = ThisDoc.Document
Dim ThisPath As String = oDoc.FullFileName
'Grab the Active Assembly Component Definition
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
' Get the model browser
Dim oPane As BrowserPane
oPane = oDoc.BrowserPanes.Item("Model")
Dim AssySubtype As String
AssySubtype = "Assembly"
' Grab the occurrence of the object
Dim oOcc As ComponentOccurrence
For Each oOcc In oDoc.ComponentDefinition.Occurrences
InstNum=":" & counter
'Grab Document from Occurrence
Dim oOccDoc As Document
oOccDoc = oOcc.Definition.Document
'get design properties set'
Dim invDesignInfo As PropertySet
invDesignInfo = oOccDoc.PropertySets.Item("Design Tracking Properties")
' Get the part number property.
Dim invPartNumberProperty As Inventor.Property
invPartNumberProperty = invDesignInfo.Item("Description")
'Get reference information for the path for the purpose of checking for whether the component is a standard Content Center part
Dim PathProperty As String = "ReferencePath"
Dim oPath As String = oOccDoc.FullFileName
'Create a property that can be referenced later for the purpose of maintaining links in other iLogic commands
Dim customPropSet As PropertySet
customPropSet = oOccDoc.PropertySets.Item("Inventor User Defined Properties")
Dim PropertyName As String = "ReferenceBrowserName"
Dim NodeName() As String
NodeName=oOcc.Name.Split( {":"c},StringSplitOptions.None)
'InstNum=":" & NodeName(1)
'Checks to see if the component is a standard content center part
If InStr(oPath,"Content Center Files") = 0 Then
'Checks to see if the component is actually the parent level assembly. This is necessary when the active assembly is a weldment
If InStr(oPath, ThisPath) = 0 Then
'Test to see if the property, "ReferencePath" has already been created
Try
custompath = customPropSet.Item(PathProperty)
'If it hasn't been created, do so
Catch
customPropSet.Add(oPath, PathProperty)
End Try
' Get the browser node that corresponds to the new item
Dim oSubAssyNode As BrowserNode
oSubAssyNode = oPane.GetBrowserNodeFromObject(oOcc)
'Take the current name of the component and separate it from the ":XX" instance number
Dim CurrentNode() As String
CurrentNode=oOcc.Name.Split( {":"c},StringSplitOptions.None)
'Determine whether the browser node should be renamed
If String.Compare(CurrentNode(0),(invPartNumberProperty.Value), True) = 0 Then
'If everything is consistent, then do nothing
Else
Try
prop = customPropSet.Item(PropertyName)
Catch
customPropSet.Add(NodeName(0), PropertyName)
End Try
'Set The name
oSubAssyNode.NativeObject.Name = (invPartNumberProperty.Value) & InstNum
End If
Else
End If
Else
End If
'advance the instance number by 1
counter = counter + 1
Next
End Sub