Calling VBA from iLogic speed

Calling VBA from iLogic speed

Anonymous
Not applicable
2,193 Views
5 Replies
Message 1 of 6

Calling VBA from iLogic speed

Anonymous
Not applicable

I have a one line iLogic rule:

 

InventorVb.RunMacro("CVDMacros", "ProductionMacros", "OnSavePart")

that just calls a VBA macro that checks that the part number and description are not too long for our MRP system.

 

This takes about 10seconds to run, even if I make the VBA macro just assign a temporary variable and nothing else.  Is there anything  I can do to make calling a VBA macro from iLogic faster?

0 Likes
Accepted solutions (1)
2,194 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
If you watch the bottom left hand corner of screen each time you run your rule, you will notice inventor loading VBA, in the option menu you can tell inventor to load VBA @ startup but it makes no difference. I have converted all of my macro's to iLogic or to a standalone VB.Net programme, upto 10 times faster
0 Likes
Message 3 of 6

Anonymous
Not applicable

Is there an easy way to both make sure that all the engineers here have an iLogic rule and update it seperately template files?

 

The thing I like about my current setup is that if next week I want to change the code that triggers on save I can just edit the .ivb macro file, and all the parts made between then and now will automatically get the changes.  I'd be happy to rewrite everything as an iLogic rule, but I don't know how to get that updating effect with iLogic.

0 Likes
Message 4 of 6

Vladimir.Ananyev
Alumni
Alumni
Accepted solution

You may consider to use external iLogic rules that are stored in the text files on server.  In this case you don't have to involve VBA environment that should improve overall performance.   Another option is to call external functions from DLL directly from iLogic rules triggered by events.


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 5 of 6

ekinsb
Alumni
Alumni

I didn't test this but here is an educated guess.

 

I assume you're running 64-bit Inventor.  VBA was only available as a 32-bit application and to allow it to work with 64-bit Inventor is being run in a seperate external process.  If you were running 32-bit Inventor then the performance will probably be ok.  Also, Microsoft has recently made 64-bit VBA available and this is what's used for Inventor 2014, so I'm guessing that the performance will be ok with Inventor 2014.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 6 of 6

Anonymous
Not applicable

An external iLogic rule is probably the correct fix to my problem, but it turns out that just taking the VBA file and re-arranging things so that the macros triggered on save where in their own small module made everything fast enough that it's no longer a problem.  This did  break everyone's keyboard/ribbon shortcuts to the macros, is there a reasonable way to change which module a particular macro is in without breaking keyboard shortcuts?

 

I think the issue was that Inventor was loading/maybe compiling the entire project file every time the trigger ran, which takes however many seconds.  What would be ideal in some future version would be a way to get it to only do that once on startup, similar to the "Load VBA on Startup" option in the general tab of the application options, which seems to work only for VBA things that aren't called from iLogic.

 

Ben Coburn

0 Likes