Clicking macros / VBA editor makes file dirty !?

Clicking macros / VBA editor makes file dirty !?

-niels-
Mentor Mentor
989 Views
8 Replies
Message 1 of 9

Clicking macros / VBA editor makes file dirty !?

-niels-
Mentor
Mentor

Ok, so i have no idea where to go with this so i'm just posting it here.

 

Maybe others can confirm this behavior but here is what i'm seeing:

 

If i open a part i can see by the Vault status that it is "clean" (no asterisk to show that there are changes)

I then go to the "Tools" tab and hit "Macros"

I don't do anything else, just hit Cancel in the dialog box.

Then i refresh my Vault status and see an asterisk appearing...

 

I have an idea as to why this would happen, but i find it absolutely ridiculous that it does! Smiley Mad

 

To elaborate on my example:

 

I have a macro to create a dxf from a flat pattern.

The macro is defined in the application project (default.ivb), so not in the document itself...

(If anyone wants to recreate, just copy the code example from the programming help)

 

When i have the VBA editor open, start with a "clean" file and run that macro from the VBA editor the file stays "clean" !

If i start with the same "clean" file but open the VBA editor by clicking the button and then running the same macro the file gets "dirty"...

If i start with the same "clean" file and hit the "macros" button, navigate to the macro and run it the file gets "dirty"...

 

I have also added the macro to the ribbon as a user command for easy access.

Running the macro with that button also makes the file get "dirty"...

 

This is still in IV2016, but i don't expect it to be different in IV2017.

I suspect the dirtying happens because Inventor loads the vba project into the active document, but if i run a macro from the application project through a user button on the ribbon i would expect to circumvent that...

 

Sadly it doesn't and all this is leaving me rather frustrated.... Smiley Frustrated

 

Anyone have any suggestions?


Niels van der Veer
Inventor professional user & 3DS Max enthusiast
Vault professional user/manager
The Netherlands

0 Likes
990 Views
8 Replies
Replies (8)
Message 2 of 9

smilinger
Advisor
Advisor

I can confirm this behavior.

 

This is what I think:

 

When you click Macros or run some VBA, inventor will create an empty VBA project for each open document if there isn't one, which is why the file get dirty. The empty VBA project for each document will take up about 10KB disk space, you can easily find this by monitoring the file size after saving.

 

I'm afraid you can only live with that, I find no way to prevent inventor from creating these empty VBA projects. One thing you can do is, before running any VBA program, close all the other open documents, otherwise all files will get dirty.

 

Another option, to circumvent this "dirty" problem, you can modify your template files: open all your template files, click the Macros button to make the empty VBA project created for each template, and then save them. This should eliminate the dirty flag when running VBA in the future, bad news is all your future documents will have this empty VBA project and take up 10KB more disk space.

 

0 Likes
Message 4 of 9

-niels-
Mentor
Mentor
Thanks Smilinger, that sounds in line with my thoughts.

The only weird thing is that it doesn't happen when you run a macro from an already activated VBA editor window.
At least that was what i noticed:
Open a part (clean), start vba editor, close the part (dirty), reopen the part (clean), switch to (still open) vba editor and run macro.

So it is possible to run macros without dirtying the file, but in a very roundabout way...

Niels van der Veer
Inventor professional user & 3DS Max enthusiast
Vault professional user/manager
The Netherlands

0 Likes
Message 5 of 9

smilinger
Advisor
Advisor

That's true, it can be easily observed that opening documents while VBA Editor is already opened will not create VBA projects. It's weird, looks like a bug.

Message 6 of 9

brendan.henderson
Advisor
Advisor

I struggled with this for many years. Eventually I had all our macros written as Add-in's and this removed the problem entirely. It cost a few hundred dollars for the coder to do his work but it was well worth it.

Brendan Henderson
CAD Manager


New Blog | Old Blog | Google+ | Twitter


Inventor 2016 PDSU Build 236, Release 2016.2.2, Vault Professional 2016 Update 1, Win 7 64 bit


Please use "Accept as Solution" & give "Kudos" if this response helped you.

0 Likes
Message 7 of 9

-niels-
Mentor
Mentor
Hah, you saying that really makes me feel the irony...

I had the dxf code as part of our own custom addin, but since it only fires "on save" it doesn't work as well with our Vaulted files when they are "released", so i made the macro for those situations.
I actually turned it into iLogic code first, but adding those steps on top of the vault process would get a bit too much for my boss i think.

I guess i will have to take the dive into rewriting our addin to get around this...

Still doesn't take away the fact that the macro functionality is doing some seemingly unnecessary stuff though.

Niels van der Veer
Inventor professional user & 3DS Max enthusiast
Vault professional user/manager
The Netherlands

0 Likes
Message 8 of 9

brendan.henderson
Advisor
Advisor

Our Add-ins don't run on save, they run when we run them.

 

The Add-in's are :-

 

Flat Pattern to DXF (sued for single sheet metal part files),

Assembly to DXF (run from an assy to create all the DXF files of all the child Sheet Metal parts),

And a few assy to excel files for all the bought & made items, the plasma cut (sheet metal) parts list and a 3rd spreadsheet for finish (paint, gal, etc...),

An FG length update,

A ground all routine (useful for when other CAD assy files are imported from a STEP and no constraints exist),

A make all phantiom routine (used in conjunction with the above ground all).

A few for the IDW environment also, just to speed up some mundane tasks.

 

Each of these get run when we want it to fire. And they all get run on released files, same as yours.

 

I've tested them all with various files and none of them create a dirty file. I also have a few iLogic routines that do create dirty files and are slowly replacing these with smarter and better written add-ins.

Brendan Henderson
CAD Manager


New Blog | Old Blog | Google+ | Twitter


Inventor 2016 PDSU Build 236, Release 2016.2.2, Vault Professional 2016 Update 1, Win 7 64 bit


Please use "Accept as Solution" & give "Kudos" if this response helped you.

Message 9 of 9

-niels-
Mentor
Mentor
The "on save" bit is of my own doing, i wrote (read: copy/pasted together) our own addin quite some years ago and it always served us well.
At that time we didn't use Vault and i never anticipated this would be a problem.
There might be addins available that do basically the same, you already mention you have a flat pattern to DXF addin as well, but i made ours with some custom naming rules...

Making it a macro had the benefit of adding it to the ribbon as a button, but the dirtying is a bit of a drawback.

So, like i said, i'll just have to take the dive and rewrite our addin a bit.

Niels van der Veer
Inventor professional user & 3DS Max enthusiast
Vault professional user/manager
The Netherlands

0 Likes