Message 1 of 7
apprentice error

Not applicable
05-08-2012
02:30 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am upgrading some code to work with Autodesk 2013 products. My code uses the ApprenticeServer to get some information out of Inventor files. Anyways, it worked fine with 2012, but it randomly fails on 2013. The line that is failing is the one that tries to open the file (Inventor.ApprenticeServerDrawingDocument)GlobalVar.oApprentice.Open(drawingName);
Any ideas?
foreach (string s in drawingFileList) { Inventor.ApprenticeServerDrawingDocument drgDoc = null; string drawingName = vFileList.GetFullLocalName(Path.GetFileName(s)); if(System.IO.File.Exists(drawingName)) Debug.WriteLine(s + " Exists"); else Debug.WriteLine(drawingName + " does not exist"); // oApprentice.Open call seems to fails sometimes on first try. // loop until file opens, to a maximum of 5 times. int numTries = 0; do { try { numTries++; Debug.WriteLine("The last breath"); drgDoc = (Inventor.ApprenticeServerDrawingDocument)GlobalVar.oApprentice.Open(drawingName); } catch (Exception) { if (numTries > 5) { MessageBox.Show("Cannot open Drawing"); break; } drgDoc = null; } } while (drgDoc == null);