Defensive programming with Inventor Server

Defensive programming with Inventor Server

anthony_pizzigoni
Community Visitor Community Visitor
253 Views
3 Replies
Message 1 of 4

Defensive programming with Inventor Server

anthony_pizzigoni
Community Visitor
Community Visitor

Hi all,

I am relatively new to the Inventor API, and I am currently working on a tool to open files using Inventor Server and obtain metadata and references from said files.  For ease of use for the user, what are some defensive practices that would be best to put in place to make sure that the file does not crash on open? Some of the checks that implemented are:

  • Ensuring that the file attempting to be read exists
  • Making sure the user has read permissions for the files attempted to be read.
  • Confirming that the file attempting to be opened is an Inventor File
  • Checking the version of the file to be read to ensure that it can be opened in the current version of Inventor.

Are there any other defensive practices that you would implement, or are there any references or documentation for the best defensive practices for something like this? Thanks!

0 Likes
254 Views
3 Replies
Replies (3)
Message 2 of 4

CGBenner
Community Manager
Community Manager

@anthony_pizzigoni 

Welcome to the Community.  I've moved your post here for greater visibility with the programming experts.  Good luck!

Did you find a post helpful? Then feel free to give likes to these posts!
Did your question get successfully answered? Then just click on the 'Accept solution' button.  Thanks and Enjoy!


Chris Benner
Community Manager

0 Likes
Message 3 of 4

JelteDeJong
Mentor
Mentor

Not so many tips here. But be aware that all inventor files implement the interface "Document". If you get a document then you always need to check what kind of document you have. For example the list Inventor.Documents can have  PartDocuments, AssemblyDocuments or Drawing documents.  Instead of checking for the interface you could also check the property Document.DocumentType.

Many list in the Inventor api are List of Object. Always check if you get the type that you expect.

Inventor API throws only 2 or 3 meaningless different exceptions. I use a lot of try/cathch blocks just to rethrow the exception with a bit more sensible description.

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 4 of 4

CGBenner
Community Manager
Community Manager

@anthony_pizzigoni Did the information provided answer your question? If so, please use Accept Solution so that others may find this in the future. Thank you very much!

Did you find a post helpful? Then feel free to give likes to these posts!
Did your question get successfully answered? Then just click on the 'Accept solution' button.  Thanks and Enjoy!


Chris Benner
Community Manager

0 Likes