Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Adding Prefix to Body Name

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Biju.Veedu
1001 Views, 4 Replies

Adding Prefix to Body Name

Hi All, 

Is there any ilOGIC rules avaiable to add prefix to all solid bodies in a multibody part file?  i want to retain the existing solidbody name with new prefix infront of it. thanks.

Labels (3)
4 REPLIES 4
Message 2 of 5
A.Acheson
in reply to: Biju.Veedu

@Biju.Veedu 

 

The below post are all duplicate post requesting the same thing.

https://forums.autodesk.com/t5/inventor-customization/ilogic-rename-solid-bodies-all-to-select/m-p/1...

 

https://forums.autodesk.com/t5/inventor-forum/adding-prefix-to-body-name/m-p/10424069

 

https://forums.autodesk.com/t5/inventor-customization/multi-bodies-auto-rename/m-p/10424080#M125900

 

Firstly please avoid creating duplicate posts this can be very frustrating for users and will dilute the effectiveness of individual post. Secondly  it is better to create one post and link other post that explain your help request. Thirdly posting on solved posts is also not the best practice as user will assume they are solved and will pass over them. 

 

For future post if they involve ilogic please post them here.

https://forums.autodesk.com/t5/inventor-customization/bd-p/120

 

If possible include the code you are working with/attempted and an explanation of the problem. 

The below code is adapted from here on post 20 0f 32

 

withString = InputBox("Prompt", "Title", "Default Entry")
	For Each solid In ThisDoc.Document.ComponentDefinition.SurfaceBodies
		Name = solid.Name
		myparams = Name.Split("-")
		replaceString1 = myparams(0)
		'replaceString2 = myparams(1)
		Name = Name.Replace(replaceString1, withString)
		solid.Name = Name
 	Next

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 5
gcoombridge
in reply to: Biju.Veedu

In a part file you can do this without code for all future solids under document settings

gcoombridge_0-1624847414870.png

Otherwise here is some code:

Dim oDoc As PartDocument = ThisDoc.Document
Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition

Dim oSolid As SurfaceBody
Dim oSolidName As String
Dim oPrefix As String = InputBox("Provide a prefix for each solid:", "Solid Body Prefix","")


'iterate through all solids and rename if default
For Each oSolid In oDef.SurfaceBodies
	oSolidName = oSolid.Name
	oSolid.Name = oPrefix & oSolidName
Next oSolid
Use iLogic Copy? Please consider voting for this long overdue idea (not mine):https://forums.autodesk.com/t5/inventor-ideas/string-replace-for-ilogic-design-copy/idi-p/3821399
Message 4 of 5
Biju.Veedu
in reply to: A.Acheson

Excellent. 

also By changing the code slightly i could use this to rename existing bodies that are in different naming formats.  

for example i used "_" &  "space" to replace.  anyway great. thankyou.

Message 5 of 5
Biju.Veedu
in reply to: A.Acheson

Excellent. thankyou.

this code helped me to rename with a new prefix.

 

here is the code for replacing an existing name that are seperated by "_"  

 

withString = InputBox("Prompt", "Title", "Default Entry")
	For Each solid In ThisDoc.Document.ComponentDefinition.SurfaceBodies
		Name = solid.Name
		myparams = Name.Split("_")
		replaceString1 = myparams(0)
		'replaceString2 = myparams(1)
		Name = Name.Replace(replaceString1, withString)
		solid.Name = Name
 	Next

  

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report