iLogic Rename Solid Bodies - all to select

iLogic Rename Solid Bodies - all to select

kresh.bell
Collaborator Collaborator
3,137 Views
14 Replies
Message 1 of 15

iLogic Rename Solid Bodies - all to select

kresh.bell
Collaborator
Collaborator

Hi,

I use this iLogic to rename solid bodies. It works great. I do not know how to edit iLogic, so please help. Can this iLogic be edited so that just renaming select solid bodies, not all solid bodies?

 

'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 part number to the Prefix iProperty if it is empty
If iProperties.Value("Custom", "Prefix") = "" Then
iProperties.Value("Custom", "Prefix") = iProperties.Value("Project", "Part Number") & "_"
Else
End If

'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

'get input from user
prefix = InputBox("Enter a prefix for the solid body names", "iLogic", iProperties.Value("Custom", "Prefix"))

'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
solid.Name = prefix + Iif(i < 10, "0" + CStr(i), CStr(i))
i = i + 1
Next

Kresh

0 Likes
Accepted solutions (1)
3,138 Views
14 Replies
Replies (14)
Message 2 of 15

bradeneuropeArthur
Mentor
Mentor

Hi,

 

Try this:

 

Public Sub main()

Dim a As Application
 a = ThisApplication
Dim b As PartDocument b = a.ActiveDocument Dim c As SurfaceBody Dim d As SurfaceBodies Dim e As SelectSet e = b.SelectSet If e.Count = 0 Then MsgBox "select something" Else Dim i As Integer 'get input from user Dim prefix As String prefix = InputBox("Enter a prefix for the solid body names", "iLogic", iProperties.Value("Custom", "Prefix")) 'write input back to custom iProperty 'iProperties.Value("Custom", "Prefix") = prefix i = 1 'rename all solid bodies incrementing suffix For Each c In e c.Name = prefix + IIf(i < 10, "0" + CStr(i), CStr(i)) i = i + 1 Next 'e.Name = "" End If End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 15

kresh.bell
Collaborator
Collaborator

085643.jpg

0 Likes
Message 4 of 15

bradeneuropeArthur
Mentor
Mentor

I-logic is different the vba and vb.net...

 

MsgBox ("select something")

 I have developed it in vba….

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 5 of 15

kresh.bell
Collaborator
Collaborator

Sorry but I do not understand, what do I have to do to make no mistake?

0 Likes
Message 6 of 15

bradeneuropeArthur
Mentor
Mentor

re-copy and paste...

 

Public Sub Main()

Dim a As Application
a = ThisApplication Dim b As PartDocument b = a.ActiveDocument Dim c As SurfaceBody Dim d As SurfaceBodies Dim E As SelectSet E = b.SelectSet If e.Count = 0 Then MsgBox ("select something") Else Dim i As Integer 'get input from user Dim prefix As String prefix = InputBox("Enter a prefix for the solid body names", "iLogic", iProperties.Value("Custom", "Prefix")) 'write input back to custom iProperty 'iProperties.Value("Custom", "Prefix") = prefix i = 1 'rename all solid bodies incrementing suffix For Each c In e c.Name = prefix + IIf(i < 10, "0" + CStr(i), CStr(i)) i = i + 1 Next End If End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 7 of 15

kresh.bell
Collaborator
Collaborator

101327.jpg

0 Likes
Message 8 of 15

bradeneuropeArthur
Mentor
Mentor

the custom property is missing.

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 9 of 15

bradeneuropeArthur
Mentor
Mentor

Are you a little familiar with I-logic?

Since the question is not only what you asked.

You need to have a review for your complete copied code, isn't it?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 10 of 15

bradeneuropeArthur
Mentor
Mentor
Accepted solution
Public Sub Main()


Dim a As Application
 a = ThisApplication
 

Dim b As PartDocument
 b = a.ActiveDocument
 
 Try
	 
 Dim p As Inventor.Property = b.PropertySets.Item(4).Add("", "Prefix")
 
 Catch
	 
 End Try
	 

Dim c As SurfaceBody
Dim d As SurfaceBodies

Dim E As SelectSet
E = b.SelectSet

If e.Count = 0 Then
MsgBox ("select something")

Else

Dim i As Integer

'get input from user
Dim prefix As String

prefix = InputBox("Enter a prefix for the solid body names", "iLogic", iProperties.Value("Custom", "Prefix"))

'write input back to custom iProperty
'iProperties.Value("Custom", "Prefix") = prefix
i = 1
'rename all solid bodies incrementing suffix
For Each c In e


c.Name = prefix + IIf(i < 10, "0" + CStr(i), CStr(i))
i = i + 1
Next
'e.Name = ""
End If

End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 11 of 15

kresh.bell
Collaborator
Collaborator

Thanks a lot, now it's ok, it works.

 

Is it a big problem to add from the old iLogic this section:

 

'write the part number to the Prefix iProperty if it is empty
If iProperties.Value ("Custom", "Prefix") = "" Then
iProperties.Value ("Custom", "Prefix") = iProperties.Value ("Project", "Part Number") & "_"
else
End If

0 Likes
Message 12 of 15

bradeneuropeArthur
Mentor
Mentor

Your thanks are appreciated.


! Fo
r administrative reasons, please mark a "Solution as solved" when the issue is solved !

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 13 of 15

Biju.Veedu
Contributor
Contributor

Is here any ilogic to rename all solidbodies with a prefix on it? need want retain existing "body name" and want to add prefix to it.

for Example

" xxxxx_Solidbody 01"

" xxxxx_Solidbody 02"

" xxxxx_Solidbody 03"

thanks in advance.

0 Likes
Message 14 of 15

rclement
Collaborator
Collaborator

i see all these ilogic to rename solidbodies.i would like to see what the parameters look like if some one could take a snippit.

im sorry im really new to ilogic and i dont know what parameters need to be change

maybe theres a ilogic for dummies book

0 Likes
Message 15 of 15

Curtis_Waguespack
Consultant
Consultant
0 Likes