Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic - obtain solid body name using selected feature

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
1507 Views, 3 Replies

iLogic - obtain solid body name using selected feature

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.

3 REPLIES 3
Message 2 of 4
Curtis_Waguespack
in reply to: Anonymous

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

 

Message 3 of 4

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?

Message 4 of 4

Hi @ldellaversano 

 

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.

Post to forums  

Autodesk Design & Make Report