Changing iProperties w VBA

Changing iProperties w VBA

Anonymous
Not applicable
649 Views
4 Replies
Message 1 of 5

Changing iProperties w VBA

Anonymous
Not applicable

Hi, All!  We're running a fresh install of Inventor R2019, and I'm having some VBA trouble.  We upgraded from a well-worn installation of Inventor R2011, which (I understand) is quite a jump.  The whys and wherefores of our white-knuckled grip on R2011 are water under the bridge, and now I'm trying to resurrect a host of customization tools written in VBA.  I've found and fixed a lot of them, but the one I'm working on now is dogging me.  The macro is used to change the iProps of a Content Center part, and its purpose is to allow the user to change iProps in the read-only Content Center file without closing everything and switching the project to the Library Project.

 

It worked in R2011, and the code runs right up to the point where it tries to write to the iProperties.  The macro bombs out at the point where it begins to write the new iProps to the part file, so I suspect it's something to do with the way R2019 handles read-only files.  I've attached a notepad++ file with the code.  My code migght be a little wonky, as I learned VBA from a complete novice -- in other words, I'm self-taught.

 

I'd appreciate any help you can give me!  Thanx.

 

Ed

 

 

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

pball
Mentor
Mentor
Accepted solution

The issue you're seeing is a change with 2018 and newer that fixes a "bug" where the api could edit library files. The fix is quite simple though. It's best to only turn this option on when needed and to unset it when finished.

 

'2018 fix to modify library files
ThisApplication._LibraryDocumentModifiable = True

 

'edit library files here

 

'Unset fix

ThisApplication._LibraryDocumentModifiable = False

Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
0 Likes
Message 3 of 5

Anonymous
Not applicable

Thanx for the help!  The basic command worked, but the syntax was wrong.  Investigating the LibraryDocumentModifiable property, I found three different syntax: (all in the AutoDesk Knowledge Network site 😲)

 

ThisApplication._LibraryDocumentModifiable = True

 

ThisApplication.LibraryDocumentModifiable = True

 

ThisApplication.[_LibraryDocumentModifiable] = True

 

The first gave an "invalid character" error, the second gave a run-time error "object doesn't support this method or property", the third worked!

 

 

0 Likes
Message 4 of 5

pball
Mentor
Mentor

The syntax might vary depending on the language being used. I copied that from my VB.net addin.

Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
0 Likes
Message 5 of 5

Anonymous
Not applicable

Apologies, I stated that very poorly.  This is likely a difference in programming language, and, to be honest, I'm not sure what I'm using.  Whatever came bundled with Inventor R2019....  Thanx for the help, I've now gotten all my R2011 macros to run on R2019.

Ed

0 Likes