Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
My colleague made a part that renames solids automatically. The rule works great as long as you hard code any exceptions, but it renames any part outside of these exceptions. I modified the rule to only rename parts created by a named feature, which are the only solids I want renamed. It works kind of, it correctly renames the first solid, skips the second solid, and renames all other solids 1 increment short because of the missed solid.
Below is my code:
'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 prefix prefix = "ST_" 'check that this active document is a part file Dim partDoc As PartDocument If ThisApplication.ActiveDocument.DocumentType <> kPartDocumentObject Then MessageBox.Show ("Please open a part document", "iLogic") End If 'define the active document partDoc = ThisApplication.ActiveDocument Dim solid As SurfaceBody Dim i As Integer 'write input back to custom iProperty iProperties.Value("Custom", "Prefix") = prefix i = 1 'rename all solid bodies incrementing suffix For Each solid In partDoc.ComponentDefinition.SurfaceBodies 'look at all the features that make up the body For Each oFeature In solid.AffectedByFeatures 'look at only "ST_ARRAY" feature If oFeature.Name = "ST_ARRAY" solid.Name = prefix + If(i < 10, "0" + CStr(i), CStr(i)) i = i + 1 End If Next Next '[ 'UPDATE InventorVb.DocumentUpdate() '] UPDATE
Solved! Go to Solution.