ilogic code to rename selected assembly browser nodes

ilogic code to rename selected assembly browser nodes

Slothian
Contributor Contributor
2,292 Views
4 Replies
Message 1 of 5

ilogic code to rename selected assembly browser nodes

Slothian
Contributor
Contributor

I'm looking for a method that will enable me to select several files/nodes in the assembly browser and rename them to the default part number.

These assemblies generally have some stabilised nodes for ilogic code execution, therefore using the inbuilt "rename browser nodes" wipes out the stabalised parts and defeats its use.

 

Any help would be greatly appreciated.

 

Steve

0 Likes
Accepted solutions (1)
2,293 Views
4 Replies
Replies (4)
Message 2 of 5

MechMachineMan
Advisor
Advisor

Go find admapi_18_.....chm in your inventor file or just open up the Programming Help through inventor.

 

From there, search for SelectionFilterEnum. One of the options is similiar to kAssemblyBroswerNodes.

 

Use the Pick method through the command manager to select a browser node based off of that feature.

 

The returned object will be the broswer node component.

 

From there you can simply rename it by going into the occurrence and pulling the part number.

 

 

Good luck.


--------------------------------------
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 3 of 5

Slothian
Contributor
Contributor

Thanks MechMachineMan, that got me started and I have put together some code that basically works. Still relearning the programming skills that have been long forgotten.

 

My code allows me to select an enity or node and rename it by resetting it to nothing which pulls in the original name. It then prompts if another node needs renaming. Ideally, I would prefer that instead of a single selection, that multiple nodes could be picked and added to an array/list, and then that array list is renamed.

 

I am struggling to see how to add picked items to an array though. I have also had no luck in returning the selected nodes part number, which i would prefer to use to rename the nodes. Just reseting the name gives mixed results on the test assemblies I am trying this on, returning the original node names form the copied assembly/parts

 

Heres my code as it stands

' set a reference to the assembly component definintion.
' This assumes an assembly document is open.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

MessageBox.Show("Select Browser Nodes to be Renamed", "Select Nodes")

'setup some variables
Dim entity
Dim msgresponse = vbYes

While msgresponse = vbYes
entity = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter,"Select Component:")
entity.Name = "" 'reset name to nothing, which pulls in the original name

msgresponse = MessageBox.Show("Would you like to add another node item to be renamed?", "Add another node?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
End While

 Steve

 

0 Likes
Message 4 of 5

MechMachineMan
Advisor
Advisor
Accepted solution

You have to access the occurence definition document.

 

ie;

 

oOcc = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter,"Select Component:")

oOcc.Name = oOcc.Definition.Document.ComponentDefinition.Document.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value

 

 

As for multiple select, just search for vb.net array help anywhere.

 

Or you  might also be able to use the Document.SelectSet.SelectMultiple method to select multiple.


--------------------------------------
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 5 of 5

Slothian
Contributor
Contributor

Thanks, that got it.

Didn't get the array working, but what I have solves my problem and is workable.

0 Likes