How to run a ilogic Code when BOM is accessed?

How to run a ilogic Code when BOM is accessed?

Anonymous
Not applicable
1,812 Views
16 Replies
Message 1 of 17

How to run a ilogic Code when BOM is accessed?

Anonymous
Not applicable

Is it possible to run a rule whenever bom is accessed?

0 Likes
Accepted solutions (1)
1,813 Views
16 Replies
Replies (16)
Message 2 of 17

sgwilliams
Collaborator
Collaborator

Yes If you use the VBA Editor you can browse the Object Explorer(Press F2 Key) then maximize the Object explorer so you can see the content. Then do a search for "BOM" and what you're looking for should be in the Reference somewhere. It may take you a while to find it but I'm guessing it will be there. This is the only way I know that you can add a custom event trigger as the iLogic Event trigger tool is very limited on events. In other words, you will have to create your own event trigger in the VBA editor.

 

Good Luck!

Work Station : Custom built, Liquid Cooled, Asus Pro WS X570-ACE Motherboard; AMD Ryzen 9 3900X 3.8 GHz 12-Core Processor; ASUS TUF Gaming NVIDIA GeForce RTX 3060 V2 OC Edition Video Card; 32 GB CORSAIR Dominator Platinum DDR4-2132 Memory ; Samsung 850 EVO 1TB SSD Drive.
0 Likes
Message 3 of 17

Anonymous
Not applicable

Hi Williams,

 

Thank you for your reply!!

 

I agree with you that Inventor ilogic was limited to some extent and I have already browsed the object browser before posting the query. However I couldn't get what I need. I guess your suggestion to create own custom event trigger might be so much helpful. In fact I was searching for the same can you help me out how to create custom event trigger.

 

 

Thanks,

SK.

0 Likes
Message 4 of 17

sgwilliams
Collaborator
Collaborator

I'm very limited on experience with iLogic due to its limitations. I will do my best to help you. I need you to answer a few questions 1st

 

  • What version of Inventor are you using?
  • What BOM are you trying to access the Assembly model BOM , the Drawing document BOM or Vault BOM?
  • Are you using the Vault or any other document management software?

This makes a difference.

 

Also, what exactly are you trying to accomplish when accessing the BOM? There may be a different solution to your issue.

Work Station : Custom built, Liquid Cooled, Asus Pro WS X570-ACE Motherboard; AMD Ryzen 9 3900X 3.8 GHz 12-Core Processor; ASUS TUF Gaming NVIDIA GeForce RTX 3060 V2 OC Edition Video Card; 32 GB CORSAIR Dominator Platinum DDR4-2132 Memory ; Samsung 850 EVO 1TB SSD Drive.
0 Likes
Message 5 of 17

Anonymous
Not applicable

Thanks Williams,

 

Here are the answers four your questions.

 

I'm using Inventor 2016.

I'm trying to access Assembly BOM.

I'm not using any data management softwares.

 

Even vba code to creating custom event may be helpful. But I guess that to limited in inventor latest versions. 

0 Likes
Message 6 of 17

Anonymous
Not applicable

My key requirement is to disable the BOM View when certain iProperties fields are missed out.

 

Right now I am running an event trigger to do the same when new document is created and when a document is opened.

 

Instead it will be quite useful if the same macros runs only when BOM is accessed.

 

 

0 Likes
Message 7 of 17

sgwilliams
Collaborator
Collaborator

You could always add some error trapping that would allow you to disable the BOM view depending on the criteria. I will get back with you when I find an answer, be patient as I'm working on this as well as 3 other projects.

Work Station : Custom built, Liquid Cooled, Asus Pro WS X570-ACE Motherboard; AMD Ryzen 9 3900X 3.8 GHz 12-Core Processor; ASUS TUF Gaming NVIDIA GeForce RTX 3060 V2 OC Edition Video Card; 32 GB CORSAIR Dominator Platinum DDR4-2132 Memory ; Samsung 850 EVO 1TB SSD Drive.
0 Likes
Message 8 of 17

GeorgK
Advisor
Advisor

You can use the "Event watcher" to find the event.

 

C:\Users\Public\Documents\Autodesk\Inventor 2016\SDK\DeveloperTools\Tools\EventWatcher\bin\Release\EventWatcher.exe

Message 9 of 17

sgwilliams
Collaborator
Collaborator

@GeorgK : Thanks George I forgot about that tool very helpful. 

 

@Anonymous : the command for clicking the Bill of Material Button is named "AssemblyBillOfMaterialsCmd"

 

Here is the trigger:

 

'This line is the trigger for the "UserInputEvents.OnActivateCommand" event.
    app.CommandManager.ControlDefinitions.Item("AssemblyBillOfMaterialsCmd").Execute2 True

 

 

You will have to play with the code and debug it to get it to work, this is all I can do for you hope this helps! And thanks George for the tool I totally forgot about that. I spend most of my time with VS Studio 2015 and very rarely use VBA.

Work Station : Custom built, Liquid Cooled, Asus Pro WS X570-ACE Motherboard; AMD Ryzen 9 3900X 3.8 GHz 12-Core Processor; ASUS TUF Gaming NVIDIA GeForce RTX 3060 V2 OC Edition Video Card; 32 GB CORSAIR Dominator Platinum DDR4-2132 Memory ; Samsung 850 EVO 1TB SSD Drive.
Message 10 of 17

Anonymous
Not applicable

I've Just seen this and I think it looks useful! This may or may not be what I'm looking for however could it be implemented so that when new row is added to the revision table ( or accessed/opened/ something like that) some code runs? Or even when a part is added to a drawing or when a specific custom property is changed (The code would run to change something on the drawing and the propertie is copied to the drawing)?

 

I'm pretty new to vba and haven't figured much out about this!

0 Likes
Message 11 of 17

sgwilliams
Collaborator
Collaborator

@Anonymous : All that and more is possible. Coding takes time, determination and a lot of patience. It also takes a person which actually interested in finding answers because part of coding and debugging is trying until its right. There are a lot of free coding video tutorials online to learn from. When I want to learn a new coding language I use a paid service called Lynda.com to get the basics then the rest is learning as you go. The internet is full of free code snippets and you can generally find something close to what you're looking for and then all you have to do is tweak it to work for your application.

I recommend learning the basics of where you want to start. Myself I'm a Visual Basic coder. There are a few different flavors of that code which Include VB6 (old school ), VBA(Visual Basic for Applications, this is what Inventor uses) and then VB.NET (the newest of the visual basic languages). VB6 is no longer supported by Microsoft but any people still use it. VBA is different with each application as far as syntax and rules. VB.NET is constantly being improved and is referred to by Version like I'm currently using Visual Studio .NET Community 2015(a free version) and you can develop pretty much any type of application you want in pretty much whatever language you desire. It's very robust and can be overwhelming at times. Just take your time and learn the rest will work itself out as you go.

 

Good luck!

Work Station : Custom built, Liquid Cooled, Asus Pro WS X570-ACE Motherboard; AMD Ryzen 9 3900X 3.8 GHz 12-Core Processor; ASUS TUF Gaming NVIDIA GeForce RTX 3060 V2 OC Edition Video Card; 32 GB CORSAIR Dominator Platinum DDR4-2132 Memory ; Samsung 850 EVO 1TB SSD Drive.
0 Likes
Message 12 of 17

Anonymous
Not applicable

Sorry for the delayed reply.

 

@GeorgK Thank you for the tool you have mentioned. I never used that tool earlier so I need to look on to it how to use it first.

 

@sgwilliamsRight now I'm using the trigger you have mentioned to enable the BOM once the iProperty field was filled with value. Let me work with the event watcher more and replay the result. I hope that will be give me some solutions.

0 Likes
Message 13 of 17

Anonymous
Not applicable

@sgwilliams Here is the code I am using now it does all what I need but this functions should run when BOM is clicked from Manage tab. Now I've created a event trigger to run this function when a document is opened or new document is created.  Now I've added a new event to run the same macro when iproperties changed. It completely full filled my requirement but adding more event trigger impacting the time consumption.

 

It could be easy if custom event can be created this is where I'm getting struck. How to create the custom event that can run automatically when a criteria was assigned. For example if a hole was created then it should trigger a ilogic or macro to execute.

 

Sub testing()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
Dim oCtrlDef As ControlDefinition
Dim oCtrlDefs As Double
Dim oAsm As RibbonTabs
Dim oAsmP As RibbonPanels
Dim oAsmC As Object
Set oAsm = ThisApplication.UserInterfaceManager.Ribbons.Item("Assembly").RibbonTabs
Set oAsmP = oAsm.Item("id_TabAssemble").RibbonPanels
Set oAsmC = oAsmP.Item("id_PanelA_AssembleManage").CommandControls.Item("AssemblyBillofMaterialsCmd")
Dim oText As String
oText = oDoc.PropertySets("Summary Information").Item("Author").value
oText = Len(Trim(oText))
If oText = 0 Then

oAsmP.Item("id_PanelA_AssembleManage").Visible = True
oDoc.ComponentDefinition.BOM.PartsOnlyViewEnabled = False
oDoc.ComponentDefinition.BOM.StructuredViewEnabled = False
oAsmC.ControlDefinition.Enabled = False

Else
oAsmP.Item("id_PanelA_AssembleManage").Visible = True
oAsmC.ControlDefinition.Enabled = True
Set oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyBillOfMaterialsCmd")

oAsmC.ControlDefinition.Enabled = True
oCtrlDef.Execute2
End If

End Sub
0 Likes
Message 14 of 17

sgwilliams
Collaborator
Collaborator
Accepted solution

@Anonymous : I'm glad to hear that the trigger worked for you, that's great news. The code for the Hole Creation on a part model is command "PartDMHoleCmd" and for an assembly, it is "PartHoleClassicCmd". Or like this :

 

 

'this line is the command trigger to create a hole in a part model
ThisApplication.CommandManager.ControlDefinitions.Item("PartDMHoleCmd")

'this line is the command trigger to create a hole in an assembly model
ThisApplication.CommandManager.ControlDefinitions.Item("PartHoleClassicCmd")

 To find these commands is pretty simple. The instruction on how to use the event watcher tool is as follows:

 

 

  1. open a windows file explorer window  and go to C:\Users\Public\Documents\Autodesk\Inventor 2016\SDK\DeveloperTools\Tools\EventWatcher\bin\Release\ 
  2. then right click on the "EventWatcher.exe" and then select pin to start or pin to taskbar, whatever your preference is. This will make it easy to access.
  3. run the "EventWatcher.exe" and you should see a window

watch the Screencast video to see how to use the EventWatcher to find the command codes.

 

 

 
 
 
Keep us posted on your progress this is very interesting. Hope it helps!
Work Station : Custom built, Liquid Cooled, Asus Pro WS X570-ACE Motherboard; AMD Ryzen 9 3900X 3.8 GHz 12-Core Processor; ASUS TUF Gaming NVIDIA GeForce RTX 3060 V2 OC Edition Video Card; 32 GB CORSAIR Dominator Platinum DDR4-2132 Memory ; Samsung 850 EVO 1TB SSD Drive.
0 Likes
Message 15 of 17

Anonymous
Not applicable

Could you possibly send me any links with some examples of creating trigger in this way to point me in the right direction? I can only really find stuff about normal iLogic event triggers which I get and the only other thing I've found really is this http://beinginventive.typepad.com/being-inventive/2012/02/injecting-ilogic-code-and-ilogic-event-tri... which I don't really want to use. I've spent many hours figuring out the basics of VBA but I might need a little extra help with this - Thank you

0 Likes
Message 16 of 17

Anonymous
Not applicable

@sgwilliams Thank you so much for the screen cast that was really helpful for me.

0 Likes
Message 17 of 17

sgwilliams
Collaborator
Collaborator

@Anonymous : If you start  a new post I'll do my best to help.

 

@Anonymous : You're very welcome!

Work Station : Custom built, Liquid Cooled, Asus Pro WS X570-ACE Motherboard; AMD Ryzen 9 3900X 3.8 GHz 12-Core Processor; ASUS TUF Gaming NVIDIA GeForce RTX 3060 V2 OC Edition Video Card; 32 GB CORSAIR Dominator Platinum DDR4-2132 Memory ; Samsung 850 EVO 1TB SSD Drive.
0 Likes