Monday, January 1, 2018
iLogic to Rename All Solid Bodies
iLogic to Rename All Solid Bodies
Issue:
Youve created a multi-body solid model with the intent to use the Make Components tool to write out each solid as a new part file. This works fine, but you find yourself wishing there was an easier way to tag each solid with a new name based on a prefix and a series number. For instance, youd like to name each solid in a part file called 45-723 as such: 45-723_01, 45-723_02, 45-723_03, etc.
Issue:
You can use this iLogic rule to quickly rename the solid bodies for you. In this rule we first look for a custom iProperty named "Prefix" and create it if it is not present. Then we write the part number to the custom iProperty if it is found to be empty. Then the rule uses the value of the custom iProperty named "Prefix" in an input box to query the user for the prefix:
Thanks to Barbara Han for the original code I used for this rule.
------- start of ilogic ------
check for custom iProperty and add it if not found
Dim prefix As String = "Prefix"
customPropertySet = ThisDoc.Document.PropertySets.Item _
("Inventor User Defined Properties")
Try
prop= customPropertySet.Item(prefix)
Catch
Assume error means not found
customPropertySet.Add("", prefix)
End Try
write the part number to the Prefix iProperty if it is empty
if iProperties.Value("Custom", "Prefix") = "" Then
iProperties.Value("Custom", "Prefix") = iProperties.Value("Project", "Part Number") & "_"
else
end if
check that this active document is a part file
Dim partDoc As PartDocument
link download