Hi,
I'm writing a simple feature-rename script.
However i just can't figure out how to derive the solid body name from the selected feature.
example:
For Each oExtrude In oDef.Features.ExtrudeFeatures oBody = oDef.SurfaceBodies.Item(1) 'obviously only gives the first solid as name oExtrude.Name = oBody.Name & " - Ext. " & extCount.ToString("00") extCount = extCount + 1 Next
I want to rename all extruded features to: SolidName - " Ext." followed by an increment.
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Hi @Anonymous
Welcome to the forum. Here is one method to do this.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
oDoc = ThisApplication.ActiveDocument oBodies = oDoc.ComponentDefinition.SurfaceBodies 'look at the bodies For Each oBody In oBodies i = 1 'look at all the features that make up the body For Each oFeature In oBody.AffectedByFeatures 'look at only extrude features If oFeature.Type = ObjectTypeEnum.kExtrudeFeatureObject Then 'rename feature using solid name 'and pad the number with zero if under 10 oFeature.Name = oBody.Name _ & " - Ext. " & If(i < 10, "0" + CStr(i), CStr(i)) i = i + 1 End If Next Next
This function work only at first time, if i add a new feature and rerun the rule this doasn't work.
How can i resolve?
See this update.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
oDoc = ThisApplication.ActiveDocument oBodies = oDoc.ComponentDefinition.SurfaceBodies 'look at the bodies For Each oBody In oBodies For k = 1 To 2 i = 1 'look at all the features that make up the body For Each oFeature In oBody.AffectedByFeatures 'look at only extrude features If oFeature.Type = ObjectTypeEnum.kExtrudeFeatureObject Then If k = 1 Then oFeature.Name = "Temp_" & i Else 'rename feature using solid name 'and pad the number with zero if under 10 oFeature.Name = oBody.Name _ & " - Ext. " & If (i < 10, "0" + CStr(i), CStr(i)) End If i = i + 1 End If Next Next Next
Can't find what you're looking for? Ask the community or share your knowledge.