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: 

Changing part occurrance name to part number as default

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
kelNGJTJ
2077 Views, 6 Replies

Changing part occurrance name to part number as default

kelNGJTJ
Explorer
Explorer

Hello 

I have a problem regarding the part occurrance name. 
At our office we have a lot of parts with existing names, (defined by 3rd party subcontractors) wich need to be changed to the part numbers we use. 
We use vault and when checking in assemblies and parts the automatic renaming funcion in vault does its job. 

However, when checking out the parts and assemblies from vault, the occurance name (in the model tree) does not update to the part number (which is the intention). We have tried using the Inventor feature "Rename Browser Nodes" and selecting "New Name: Part number". But when we try saving the assembly (With updated occurrance names) the part occurrance names gets reset to the name defined by 3rd party subcontractor. 

A way to fix this problem is by individually opening every part and resetting occurrance name (editing occurrance name, deleting the name, and pressing enter), however this is a very time consuming way of fixing the issue at several thousand parts in assembly. 

 

The problem is illustrated by the following screenshots.

kelNGJTJ_1-1603883059169.pngkelNGJTJ_2-1603883113183.pngkelNGJTJ_3-1603883154643.png

kelNGJTJ_4-1603883212663.png

kelNGJTJ_5-1603883243671.png


Is there a way to automate this process using Ilogic rules?
Is there any other way to fix the issue using some of the features in Inventor? 

 

Thanks in advance 

0 Likes

Changing part occurrance name to part number as default

Hello 

I have a problem regarding the part occurrance name. 
At our office we have a lot of parts with existing names, (defined by 3rd party subcontractors) wich need to be changed to the part numbers we use. 
We use vault and when checking in assemblies and parts the automatic renaming funcion in vault does its job. 

However, when checking out the parts and assemblies from vault, the occurance name (in the model tree) does not update to the part number (which is the intention). We have tried using the Inventor feature "Rename Browser Nodes" and selecting "New Name: Part number". But when we try saving the assembly (With updated occurrance names) the part occurrance names gets reset to the name defined by 3rd party subcontractor. 

A way to fix this problem is by individually opening every part and resetting occurrance name (editing occurrance name, deleting the name, and pressing enter), however this is a very time consuming way of fixing the issue at several thousand parts in assembly. 

 

The problem is illustrated by the following screenshots.

kelNGJTJ_1-1603883059169.pngkelNGJTJ_2-1603883113183.pngkelNGJTJ_3-1603883154643.png

kelNGJTJ_4-1603883212663.png

kelNGJTJ_5-1603883243671.png


Is there a way to automate this process using Ilogic rules?
Is there any other way to fix the issue using some of the features in Inventor? 

 

Thanks in advance 

Labels (6)
6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: kelNGJTJ

Anonymous
Not applicable
Accepted solution

I wrote some code that will get you close to what you are looking for. It was written to "normalize" nodes for building iLogic configurators:

 

I've tweaked that code to change the node names to part numbers, one drawback of this version of code, is that it renames all of the instances numerically, see image below:

@ClintBrown3D Autodesk Inventor 09.png

Part numbers are correctly displayed though.

 

'Code by @ClintBrown3D originally posted here: --> https://clintbrown.co.uk/ilogic-normalise-browser-nodes---with-code
'This iLogic utility "normalises" the first instance of a browser node in an assembly

oDoc = ThisDoc.Document
oNamer = "Normalise Browser Nodes"
Dim UNDO As Transaction 
UNDO = ThisApplication.TransactionManager.StartTransaction(oDoc, oNamer)
'The rule is placed in an "undo wrapper" to it faster to undo the changes to multiple browser node changes
'https://clintbrown.co.uk/2019/03/03/undo/
'----------------------------------------------------------------------------------------------------------------------
Dim doc = ThisDoc.Document : If doc.DocumentType = kAssemblyDocumentObject Then 'Check we are in an IAM
Else : Return :End If

Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
Dim oCompOcc As Inventor.ComponentOccurrence

OccCounter = 0
For Each oCompOcc In oDef.Occurrences
GetOccName = oCompOcc.Name
OccCounter = OccCounter + 1
SubOccCount = 0

Try
	'Top Level Occurrences
NewName = (GetOccName)
NewName = iProperties.Value(GetOccName, "Project", "Part Number")
oCompOcc.Name = NewName & ":" & OccCounter

'Sub level Occurrences
   For Each oSubOcc As ComponentOccurrence In oCompOcc.SubOccurrences
	   SubOccCount = SubOccCount + 1
	   SubNewName = iProperties.Value(GetOccName, "Project", "Part Number")
   oSubOcc.Name = SubNewName & ":" & SubOccCount
   Next
   
Catch : End Try : Next
'-------------------------------------------------------------------------------------------------------------------------
UNDO.End

  Hope this points you in the right direction. Maybe someone else can tweak this to fix the instance numbering.

I wrote some code that will get you close to what you are looking for. It was written to "normalize" nodes for building iLogic configurators:

 

I've tweaked that code to change the node names to part numbers, one drawback of this version of code, is that it renames all of the instances numerically, see image below:

@ClintBrown3D Autodesk Inventor 09.png

Part numbers are correctly displayed though.

 

'Code by @ClintBrown3D originally posted here: --> https://clintbrown.co.uk/ilogic-normalise-browser-nodes---with-code
'This iLogic utility "normalises" the first instance of a browser node in an assembly

oDoc = ThisDoc.Document
oNamer = "Normalise Browser Nodes"
Dim UNDO As Transaction 
UNDO = ThisApplication.TransactionManager.StartTransaction(oDoc, oNamer)
'The rule is placed in an "undo wrapper" to it faster to undo the changes to multiple browser node changes
'https://clintbrown.co.uk/2019/03/03/undo/
'----------------------------------------------------------------------------------------------------------------------
Dim doc = ThisDoc.Document : If doc.DocumentType = kAssemblyDocumentObject Then 'Check we are in an IAM
Else : Return :End If

Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
Dim oCompOcc As Inventor.ComponentOccurrence

OccCounter = 0
For Each oCompOcc In oDef.Occurrences
GetOccName = oCompOcc.Name
OccCounter = OccCounter + 1
SubOccCount = 0

Try
	'Top Level Occurrences
NewName = (GetOccName)
NewName = iProperties.Value(GetOccName, "Project", "Part Number")
oCompOcc.Name = NewName & ":" & OccCounter

'Sub level Occurrences
   For Each oSubOcc As ComponentOccurrence In oCompOcc.SubOccurrences
	   SubOccCount = SubOccCount + 1
	   SubNewName = iProperties.Value(GetOccName, "Project", "Part Number")
   oSubOcc.Name = SubNewName & ":" & SubOccCount
   Next
   
Catch : End Try : Next
'-------------------------------------------------------------------------------------------------------------------------
UNDO.End

  Hope this points you in the right direction. Maybe someone else can tweak this to fix the instance numbering.

Message 3 of 7
kelNGJTJ
in reply to: Anonymous

kelNGJTJ
Explorer
Explorer

Thank you very much for the response and rule. And thank you for your time. 

When executing the rule the part occurrance name changes as intended. But i still run into the same issue (the part occurrance name resets to default) when saving the document. 

Im completely new to Ilogic and i only understand the basics of it. 
Could my issue be resolved by executing the rule differently? 

 

0 Likes

Thank you very much for the response and rule. And thank you for your time. 

When executing the rule the part occurrance name changes as intended. But i still run into the same issue (the part occurrance name resets to default) when saving the document. 

Im completely new to Ilogic and i only understand the basics of it. 
Could my issue be resolved by executing the rule differently? 

 

Message 4 of 7
Anonymous
in reply to: kelNGJTJ

Anonymous
Not applicable

I've tested this on my end, the names should stay "as set" by the rule after a save.

 

Have a look at the Event triggers:

@ClintBrown3D Autodesk Inventor 11.png

Make sure that nothing is currently running "Before Save" or "After Save".

 

You could try putting this rule into "Before Save", that way, it will update the nodes while the file is being saved. It's best practice not to run anything that changes the file "After Save", as this could dirty the file.

I've tested this on my end, the names should stay "as set" by the rule after a save.

 

Have a look at the Event triggers:

@ClintBrown3D Autodesk Inventor 11.png

Make sure that nothing is currently running "Before Save" or "After Save".

 

You could try putting this rule into "Before Save", that way, it will update the nodes while the file is being saved. It's best practice not to run anything that changes the file "After Save", as this could dirty the file.

Message 5 of 7
kelNGJTJ
in reply to: Anonymous

kelNGJTJ
Explorer
Explorer

It works like a charm.

Thank you so much. You have been a tremendous help. 

0 Likes

It works like a charm.

Thank you so much. You have been a tremendous help. 

Message 6 of 7
aronmatheus
in reply to: Anonymous

aronmatheus
Advocate
Advocate

Hi, @Anonymous  congratulations on your code! Is there a code can I utilize to change the name in my ilogic because with your code I lose the reference to the last names I put?

0 Likes

Hi, @Anonymous  congratulations on your code! Is there a code can I utilize to change the name in my ilogic because with your code I lose the reference to the last names I put?

Message 7 of 7

Support_Charlies3DT
Contributor
Contributor

@kelNGJTJ 

 

Hello, after reading your question i think we have a solution for you in the form of an app. We are launching a Numbering app this week. I was wondering if you would be interested in testing it? The app is capable of renaming a lot of properties, numbering parts and assemblies and many more things. 

 

You can send me a PM if interested!

0 Likes

@kelNGJTJ 

 

Hello, after reading your question i think we have a solution for you in the form of an app. We are launching a Numbering app this week. I was wondering if you would be interested in testing it? The app is capable of renaming a lot of properties, numbering parts and assemblies and many more things. 

 

You can send me a PM if interested!

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

Post to forums  

Autodesk Design & Make Report