Changing the "Default" occurrence Name on Browser

Changing the "Default" occurrence Name on Browser

cencinaNB2ET
Advocate Advocate
3,010 Views
12 Replies
Message 1 of 13

Changing the "Default" occurrence Name on Browser

cencinaNB2ET
Advocate
Advocate

Hi All,

 

I was able to change the name of occurrences on the browser but once i pressed default on the UI ( rename browser nodes) the deafult alwasy comes back to the old occurrences Number ( :9..:10)

How can i change the name and keep it as default?

 

 

I tried iterating thorough Occurrences..

 

SyntaxEditor Code Snippet

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
i=0
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
'MessageBox.Show( oOccurrence.Definition.Document.DisplayName, "")
If Left( oOccurrence.Definition.Document.DisplayName,10 ) = "Nut Safety" Then
i=i+1
'MessageBox.Show( oOccurrence.Definition.Document.DisplayName, "")'MessageBox.Show( oOccurrence.Name & vbCr & CStr(i), "")
oOccurrence.Name = "Nut Safety:"+ CStr(i)
End If
Next

Also by getting browser Node Object again under Occurrences..

 

SyntaxEditor Code Snippet

Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
Dim oPane As BrowserPane
oPane = oDoc.BrowserPanes.Item("Model")
Dim oOcc As ComponentOccurrence
i = 0
For Each oOcc In oDoc.ComponentDefinition.Occurrences
Dim oNode As BrowserNode
oNode = oPane.GetBrowserNodeFromObject(oOcc)
If Left(oNode.NativeObject.Name,9 ) = "LAG Screw" Then
i = i + 1
MessageBox.Show( oNode.NativeObject.Name, "")
'oNode.NativeObject.Name = ""
oNode.NativeObject.Name =  "LAG Screw" + ":" + CStr(i)
End If
Next

 But none actually set the names to default...

 

 

Capture22.PNGCapture23.PNGCapture24.PNG

0 Likes
3,011 Views
12 Replies
Replies (12)
Message 2 of 13

NachoShaw
Advisor
Advisor
Hi

First, it's not really good practice to change the occurrence name at assembly level, it serves no other purpose except for your visual need. It doesn't make any change to the actual occurrence.

To make the change and retain it, you need to change it at part level. You could either open the part with apprentice or just open it non visible, change the relevant iproperty to what you need, save it and close it. I wouldn't necessarily loop the assembly though as this would change the same part multiple times depending on occurrence counts. You could hook into the BOM to it.

Loops in loops isn't always a great idea. For example:

100 occurrences in a loop each performing an inner loop of 10 objects is 1000 loops etc

If you look in the api help guide, there are some good assembly loop examples.


Hope that helps

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 3 of 13

cencinaNB2ET
Advocate
Advocate

I dont mean changing the filename, i mean changing the sequence on the browser.

 

from Part1:5 , Part1:6 

 

to 

 

Part1:1, Part1:2

 

 

and keep this sequence as default, meaning if i press default on rename browser names it doesn't change back to Part1:5 , Part1:6 

0 Likes
Message 4 of 13

NachoShaw
Advisor
Advisor

Hi

 

Renaming the browser node as anything wont remain (AFAIK), maybe I'm wrong. The Name of the browser node in the assembly tree is dependent of the occurrence and its position in the assembly. Renaming it merely does exactly that for that instance. If you need it to remain, have you tried adjusting the position of the occurrence in the browser node as that will stay?

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 5 of 13

cencinaNB2ET
Advocate
Advocate

I thought that was the case.

But i think the Sequence is stabilising from the construction moment, meaning..

If you place a part and the delete it or something, the browser will identify that part as Part1:2 ( 2nd occurrence).

This is what Im trying to change... But it seem you cant.? even selecting default names and not changing back.

 

Capture55.PNG

 

You can see that after pressing default the LAG screw parts and other just default to these particular occurrences number.

running my rule brings them back to where I want.. 

 

 

Capture56.PNG

 

But if the default is pressed again..it will return to that random sequence... I dont want.

 

 

 

 

0 Likes
Message 6 of 13

cencinaNB2ET
Advocate
Advocate

I also noticed that when you access Doc.DisplayName of assembly you also cant change that default name.!!

 

deleting the doc.Displayname (browser name ) or making it an empty string will reset to its filename ( its Supposed to!)

but that doesn't work in this case either. 

 

 

So This default name is getting sotred somehwere or its being referenced to the assembly where is was copied from.

But i cant find where it gets stored. since its still linking back to its parent assembly from which i cloned it from.

 

 

So I need to find how to change the default doccument.displayname and Occurrences.name 

 

0 Likes
Message 7 of 13

cencinaNB2ET
Advocate
Advocate

Never Mind I think it was something at the part level... for the Doc Display linking to the default name.

You just had to make the empty string on the part level so it updates through to the assembly...

 

But the Occurrences default question still stands.

 

 

 

0 Likes
Message 8 of 13

MechMachineMan
Advisor
Advisor

The occurrence default name likely comes from the INTERNAL storage of the file within the assembly; ie - the order in which the files were added to the assembly.

 

It doesn't really make sense to be able to "reset" the default name of the occurrence when it is meant to change often anyways. Just run a macro to rename the browser nodes or use the tool to rename them whenever it's needed. It's a transient thing.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 9 of 13

cencinaNB2ET
Advocate
Advocate

I know but These models are used to be replaced by a whole bunch of other things, so its not transient.

If i remake the model would take longer than finding a code that stabilises the occurrences sequence.

 

These model wont be changed in terms of addition of components but are systematically called and iterations are made for its components that need to have the right occurrence sequence.

 

Maybe there is a way to reference this but no one has needed it yet?

 

 

0 Likes
Message 10 of 13

MechMachineMan
Advisor
Advisor

Are you using them in an iLogic rule or something?

 

Why can't you just avoid resetting them to default?


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 11 of 13

cencinaNB2ET
Advocate
Advocate

Yes I Have a dozen rules interconnected and I don't want to count occurrences every time Im referencing a files browser.

 

So having them bulletproof to defaulting to having the actual number of occurrences means that it will always work.

 

I dont know why Something so simple cant be found in the API, SDK?

 

 

 

 

0 Likes
Message 12 of 13

MechMachineMan
Advisor
Advisor

Can you outline the process you are taking that's causing the frustration? It seems pretty obvious what you want and what inventor wants doesn't coincide, so the next best thing is tailoring a solution using more advanced API that will work for you. I don't understand the need to repetitively use the "default" command.

 

 

 

I did some testing to verify, and yes, if you manually rename that node, it will keep that name until you rename it manually - even if you replace the component. So that means that any 1 browser node can work flawless in your rules as long as that "component" is referred to as it's renamed name for as long as the code applies to it.

 

 

What I'm guessing you might be doing is using patterns or adding components and then trying to get each component that matches the name (ie; all Lag Screws) by using the occurrence number. Where this goes wrong is with the system you are trying to use.

 

An alternative solution change all lag screws would be:

- Grab the renamed/source object from the browser; ie; Component("LagScrew")

- Grab the COMPONENT definition of the previous component.

- Iterate through the COMPONENT DEFINITIONS in the assembly and perform actions based on that.

 

See?

 

"I don't want to change ALL of the lag screws"

- K, put the ones you do in a folder, then modify the rule to only apply to that folder... or something similar.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 13 of 13

cencinaNB2ET
Advocate
Advocate

Yes I wanted to avoid the iteration through component definition etc...

 

But it seems it the only way...

 

I want to have complete control over the browser names, when you create placing assemblies into assemblies by code sometimes the browser goes automatically to that default.

 

I have rules inside each assembly preventing this for now.

If i can rename all sub assemblies browser names so i can reference them appropriately then I would be in complete control, but this default issue stops that.

 

I clone a lot of assemblies and place them inside others and clone them as design need to be completely automated.

 

For now these rules are defaulting ( making it equal to empty string "") then reading through comparing other parameters and finally renaming it (:1,:2,:3....etc)

 

As Long as I know I cant access this property that's fine. 

I already have a workaround.

 

 

On second thought it must be linked to the other option in UI, like renaming by filenames, Ill see if i can find that on the Blog and go from there.

 

Thanks Anyway...

 

0 Likes