Cadline Community

Return to the search page

Blog Clinton Brown's Blog

(ref: cb-190313)

Password Protect your Inventor Files

Autodesk Inventor Files by default, do not offer any Password protection. This got me thinking about creating something similar to the functionality built into .DWF files.

I thought the easiest way to password protect a file, would be to add some iLogic code to a .IPT file. The code would run when the file is opened, and prompt the user for a password, if the password was incorrect, the file would simply close. Although what I have proposed works quite neatly, I would like to challenge you the reader, to come up with a better set of code, as mine is far from perfect.

The Prompt for a Password would look like this:

Before you try this on your files, please read the entire blog post, Including the disclaimer below!

This is what I came up with:

1)      Create a new part file

2)      Create 2 Custom TEXT Parameters, namely Password and Set_Password

3)      Create a new rule called Password Protection (or Something similar) and paste in the following code:

 

'Start of iLogic Code-----------------------------------------------------------------
Password = InputBox("Please input Password", "Password Required", "null")
If Password = Set_Password Then
InventorVb.DocumentUpdate(False)
Else
MessageBox.Show("This file will now Close", "Password Error")
CADline = ThisApplication
doc = ThisDoc.Document
doc.Close
End If

'End of iLogic Code------------------------------------------------------------------------------------

 

4)      Save the file

5)      Set the Parameter “Set_Password” to your desired password

6)      Set up an event trigger to prompt for a password every time you open the file. Manage>Event Triggers> Then Choose “After Open Document” and Select the Rule we just created.

 

Disclaimer: If you get the password wrong, you are going to have some serious looking error messages come up. This is not the end of the world, they are just telling us that we have broken some rules and tried to close a file from within itself, which is not allowed in .NET. More seriously however, is that If you forget the password, the file is not recoverable, I repeat, not recoverable, so be extremely careful!

This is in no way a definitive solution, I am merely showing what I have done on a single part file on my PC, the idea is to get the community to improve on the work. Please feel free to comment on this blog post with ideas, if you wish to share.

I have done only very basic testing on a small part file, this has not been tested on Assemblies or Drawings. Drawings could prove to be a bit more of a challenge, as you can open .DWG files in AutoCAD, there are rules out there that will strip iLogic rules from files, which could render this useless. Be Cautious, and ensure that you test your final design carefully before putting it into a production environment.

The Error messages that come up if you put in the wrong password (after the file is closed) look like this:

   


Leave a comment:

Note you must be logged in before you can post a comment.
Rate this Blog: