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.
Solved! Go to Solution.
Solved by gcoombridge. Go to Solution.
Solved by A.Acheson. Go to Solution.
The below post are all duplicate post requesting the same thing.
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
In a part file you can do this without code for all future solids under document settings
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
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.
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.