Only the part name of component

Only the part name of component

adam_liska9KKD3
Participant Participant
777 Views
7 Replies
Message 1 of 8

Only the part name of component

adam_liska9KKD3
Participant
Participant

Hi guys,

I have been searching the forum for hours, but I couldn´t get my head around it as it was always just a part of complicated task. 😓 I have to ask for help, but it should be simple...

 

I have an assembly with 2 components (BX.01.ipt and BX.02.ipt). The assembly and components will be copied and renamed for each new project (BX.01.A.ipt and BX.02.A.ipt). Nothing else will be added or removed from the assembly.

 

All I need is to create a variable with current name of the component (with or without extension, doesn´t matter). 

 

for example:

x="first component name"

y="second component name"

 

I have to copy/paste the current part name into the iLogic form now and I would like to skip this step.

 

Thanks

 

0 Likes
Accepted solutions (1)
778 Views
7 Replies
Replies (7)
Message 2 of 8

Andrii_Humeniuk
Advisor
Advisor

Hi @adam_liska9KKD3 . You can distinguish and identify your components using its unique name "InternalName". An example code to find out the InternalName is below:

Dim oDoc As Document = ThisApplication.ActiveDocument
MessageBox.Show(oDoc.InternalName, oDoc.DisplayName)

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

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

EESignature

0 Likes
Message 3 of 8

adam_liska9KKD3
Participant
Participant

Hi @Andrii_Humeniuk  , thanks for the reply. OK, now I can identify the internal numbers of the two components. Is it possible to use them in the assembly iLogic rule? If I understand correctly, internal names remain the same even after copying the entire project, right?

 

All I really need is just the name of the component used in the assembly (with or without extension), I thought it will be the easiest thing 😄

0 Likes
Message 4 of 8

Andrii_Humeniuk
Advisor
Advisor

InternalName is a unique name that is set for the document when it is created and does not change when it is copied. This seems to be the best method to get a component that can completely change its name.
If your component only partially changes the name, you can get it using the "Name.Contains" method. Take a look at the example:

Dim sName As String = "BX.01"
Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
For Each oOcc As ComponentOccurrence In oDoc.ComponentDefinition.Occurrences
	If oOcc.Name.Contains(sName) Then MessageBox.Show(oOcc.Definition.Document.InternalName, oOcc.Name)
Next

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

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

EESignature

0 Likes
Message 5 of 8

adam_liska9KKD3
Participant
Participant

@Andrii_Humeniuk great work, we are almost there.  Now x=BX-FS.01:1 , is it possible to remove ":1" and get x=BX-FS.01 ?

 

Dim sName As String = ".01"
Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
For Each oOcc As ComponentOccurrence In oDoc.ComponentDefinition.Occurrences
	If oOcc.Name.Contains(sName) Then x = oOcc.Name
		MessageBox.Show(x, oOcc.Name)
Next

 

0 Likes
Message 6 of 8

Andrii_Humeniuk
Advisor
Advisor
Accepted solution

You can implement this with the following code: yourString.Substring(0, yourString.IndexOf(":")).

Execution example:

Dim sName As String = ".01"
Dim shortName As String
Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
For Each oOcc As ComponentOccurrence In oDoc.ComponentDefinition.Occurrences
	If oOcc.Name.Contains(sName) Then
		shortName = oOcc.Name.Substring(0, oOcc.Name.IndexOf(":"))
		MessageBox.Show(shortName, oOcc.Name)
	End if
Next

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

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

EESignature

Message 7 of 8

adam_liska9KKD3
Participant
Participant

@Andrii_Humeniuk Awesome, thank you so much! 🤜🤛

Message 8 of 8

SevInventor
Advocate
Advocate

How can i change the internal Name of an ipt file? Our PLM System recognizes the wrong Material of a content center part because it was created from the wrong family table.

0 Likes