Open BOM on the right tab

TONELLAL
Collaborator
Collaborator

Open BOM on the right tab

TONELLAL
Collaborator
Collaborator

Hello,

I can open the BOM dialog box with 

ThisApplication.CommandManager.ControlDefinitions.item("AssemblyBillOfMaterialsCmd").Execute

I can PartsOnly with 

oBOM.PartsOnlyViewEnabled = True

...but is it possible to open the BOM dialog box on the PartsOnly tab ? 

0 Likes
Reply
Accepted solutions (2)
1,082 Views
8 Replies
Replies (8)

WCrihfield
Mentor
Mentor

There's also the 'AssemblyOpenBOMEditorCmd', but that doesn't open it directly to that tab either.

It's generally not a recommended as a first course of action, but I think you would have to manipulate it with 'SendKeys' type commands to have it navigate to the Tab you want after its open.

Or use other additional commands.

I don't think there is a pre-defined way to do this in a single step though.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

TONELLAL
Collaborator
Collaborator

It seems Sendkeys doesn't function on the BOM dialog box, I cannot navigate from the keyboard... 

 

"Or use other additional commands"

This is what I'm looking for ^^

 

"I don't think there is a pre-defined way to do this in a single step though."

I'm afraid you are right...

0 Likes

DRoam
Mentor
Mentor

I asked the same question about a year ago and got no answer: Open BOM to specific View tab using iLogic/VBA. I don't think it's possible. The API only has access to the BOM, not the BOM editor, so it can't really do anything to interact with the BOM editor window itself.

 

You could vote for this idea to try and remedy that: More API Control over the BOM.

Curtis_Waguespack
Consultant
Consultant

Hi Everyone,

 

I think it might be possible, but I've never figured out what is needed.

 

When we use this code, it opens the BOM editor with the "cursor" where the highlight is, same as clicking the Bill Of Materials button on the ribbon.image.png

 

Imports System.Windows.Forms

Dim oCommandMgr As CommandManager 
oCommandMgr = ThisApplication.CommandManager 
oControlDef = oCommandMgr.ControlDefinitions.Item("AssemblyBillOfMaterialsCmd")
Call oControlDef.Execute2(False)

 

 

 

This versions sends CTLR + TAB, which when done manually advances to the structured tab of the BOM editor, but for some reason when done with this example code it sets the "cursor" to the Done button.

 

image.png

 

Imports System.Windows.Forms

Dim oCommandMgr As CommandManager 
oCommandMgr = ThisApplication.CommandManager 
oControlDef = oCommandMgr.ControlDefinitions.Item("AssemblyBillOfMaterialsCmd")
Call oControlDef.Execute2(False)

SendKeys.SendWait("^{TAB}") 

 

 

We can see it in action, but using this to get and then push the Done button:

Imports System.Windows.Forms

Dim oCommandMgr As CommandManager 
oCommandMgr = ThisApplication.CommandManager 
oControlDef = oCommandMgr.ControlDefinitions.Item("AssemblyBillOfMaterialsCmd")
Call oControlDef.Execute2(False)

SendKeys.SendWait("^{TAB}") 
SendKeys.SendWait("{ENTER}") 

Now if you're thinking this is all leading somewhere good, you'll be disappointed... because the trial and error method hasn't turned anything up for me in the past when I've messed with this...

 

... but maybe @MjDeck  can shed some light on this for us?

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

EESignature

0 Likes

Curtis_Waguespack
Consultant
Consultant

 

 

Another quick example of this:

 

image.png

Imports System.Windows.Forms

Dim oCommandMgr As CommandManager 
oCommandMgr = ThisApplication.CommandManager 
oControlDef = oCommandMgr.ControlDefinitions.Item("AssemblyBillOfMaterialsCmd")
Call oControlDef.Execute2(False)

SendKeys.SendWait("{RIGHT 5}") 
SendKeys.SendWait("Hello World!!!")
SendKeys.SendWait("{Enter}") 

EESignature

0 Likes

MjDeck
Autodesk
Autodesk
Accepted solution

Here's a rule to do it. It uses the Windows API and UIAutomation. It could probably be improved, but it's working for me so far. I tested it on Inventor 2020.

At the top of the rule, this line specifies which tab to open:

OpenBOMEditor("Parts Only")

That can be changed to "Structured" or "Model Data". On a non-English system, you would probably have to change it to a localized name.


Mike Deck
Software Developer
Autodesk, Inc.

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @MjDeck ,

 

Thanks for the quick reply on this, and of course the solution!

 

I just wanted to add this in case it tripped anyone else up.

 

When I tested your example originally it didn't work, because the Parts Only tab was not enabled, with that in mind this small edit to the main sub resolves the case when the BOMview is not enabled ahead of tiem.

 

Thanks again!

 

 

Sub Main()


    Dim oDoc As AssemblyDocument
    oDoc = ThisApplication.ActiveDocument

    ' Set a reference to the BOM
    Dim oBOM As BOM
    oBOM = oDoc.ComponentDefinition.BOM    
	
    ' Make sure the BOMview is enabled.
    'oBOM.StructuredViewEnabled = True	
	'OpenBOMEditor("Structured")

    ' Make sure the BOMview is enabled.
    oBOM.PartsOnlyViewEnabled = True	
	OpenBOMEditor("Parts Only")
	
End Sub

 

 

EESignature

Maxim-CADman77
Advisor
Advisor

Dear @MjDeck 
Could you please comment on what I'm missing in attempt to get to the BOM tab of the Document Settings dialog here ?

0 Likes