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: 

Solid-Body renaming

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
autodesk0343ART
251 Views, 2 Replies

Solid-Body renaming

Hi,

I need a solid renaming rule that works as follows:
In a multi-body environment, I would like a form window to pop up and in it I would have the option to enter the name of a solid and then after clicking on the solid the name would be assigned to it. On the other hand, after pressing the "esc" button, nothing would happen.

Thanks

2 REPLIES 2
Message 2 of 3

Hi @autodesk0343ART . Please try this iLogic code:

Public Sub Main()
	Dim oInvApp As Inventor.Application = ThisApplication
	Dim oPDoc As PartDocument = TryCast(oInvApp.ActiveDocument, PartDocument)
	If oPDoc Is Nothing Then Exit Sub
	Dim oBodies As SurfaceBodies = oPDoc.ComponentDefinition.SurfaceBodies
	If oBodies.Count = 0 Then Exit Sub
	Do
		Dim oBody As SurfaceBody
		Dim sName As String
		sName = InputBox("Please enter the name of the body.", "Rename body", "Body123")
		If String.IsNullOrEmpty(sName) Then Exit Sub
		oBody = oInvApp.CommandManager.Pick(SelectionFilterEnum.kPartBodyFilter, "Select Body...")
		If oBody Is Nothing Then Exit Sub
		Try
			oBody.Name = sName
		Catch
			MessageBox.Show("Fail rename body.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error)
		End Try
	Loop
End Sub

 

Andrii Humeniuk - Leading design engineer

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

Message 3 of 3

@Andrii_Humeniuk  
Great, exactly what I needed. Thank you very much

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report