<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: apprentice error in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/apprentice-error/m-p/3451120#M136441</link>
    <description>&lt;P&gt;In a new example in the SDK, I see it is referencing Autodesk.Inventor.Interop.&amp;nbsp; So I changed it to this, but it still doesn't clear up my problem.&amp;nbsp; I guess my hunch was wrong.&lt;/P&gt;</description>
    <pubDate>Wed, 09 May 2012 21:07:23 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-05-09T21:07:23Z</dc:date>
    <item>
      <title>apprentice error</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/apprentice-error/m-p/3449519#M136437</link>
      <description>&lt;P&gt;I am upgrading some code to work with Autodesk 2013 products.&amp;nbsp; My code uses the ApprenticeServer to get some information out of Inventor files.&amp;nbsp; 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);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;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 &amp;gt; 5)
                            {
                                MessageBox.Show("Cannot open Drawing");
                                break;
                            }
                            drgDoc = null;
                        }
                    } while (drgDoc == null);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2012 21:30:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/apprentice-error/m-p/3449519#M136437</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-08T21:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: apprentice error</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/apprentice-error/m-p/3450742#M136438</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please&amp;nbsp;attach a couple of files that will allow me to recreate this behavior. Also&amp;nbsp;does the failure occur with&amp;nbsp;files&amp;nbsp;created in Inventor 2013?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Wayne Brill&lt;/P&gt;
&lt;P&gt;Autodesk Developer Network&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2012 17:15:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/apprentice-error/m-p/3450742#M136438</guid>
      <dc:creator>wayne.brill</dc:creator>
      <dc:date>2012-05-09T17:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: apprentice error</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/apprentice-error/m-p/3450864#M136439</link>
      <description>&lt;P&gt;Here are a few files that have been acting up. They would not have been created in 2013.&amp;nbsp; Also note that they are just randomly failing, sometimes they will work, sometimes they will not.&amp;nbsp; My code will loop through a list of files to open and it never fails on the first file it opens, it is always the second or later file that fails. I will have to try to create a simpler test bed and see if I can duplicate the problem, I suspect it has something to do with the surrounding code.&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2012 18:20:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/apprentice-error/m-p/3450864#M136439</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-09T18:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: apprentice error</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/apprentice-error/m-p/3451110#M136440</link>
      <description>&lt;P&gt;I see now that I am still referencing a 2012 dll&amp;nbsp; (Interop.Inventor.dll)&amp;nbsp; I can't find this file anywhere in the 2013 files. I am assuming I need to reference a different dll now, would somebody know what it would be?&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2012 20:54:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/apprentice-error/m-p/3451110#M136440</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-09T20:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: apprentice error</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/apprentice-error/m-p/3451120#M136441</link>
      <description>&lt;P&gt;In a new example in the SDK, I see it is referencing Autodesk.Inventor.Interop.&amp;nbsp; So I changed it to this, but it still doesn't clear up my problem.&amp;nbsp; I guess my hunch was wrong.&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2012 21:07:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/apprentice-error/m-p/3451120#M136441</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-09T21:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: apprentice error</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/apprentice-error/m-p/3452808#M136442</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my test project Apprentice will open "ALQT - Drawings.idw" but always fails opening "BOQF10 (Parts).idw". This file will not open on my system using Inventor 2012 or 2013. I get&amp;nbsp;an error&amp;nbsp;"The database ... could not be opened".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please let me know if you have other files that open in Inventor but will not open using Apprentice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Wayne Brill&lt;/P&gt;
&lt;P&gt;Autodesk Developer Network&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2012 19:24:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/apprentice-error/m-p/3452808#M136442</guid>
      <dc:creator>wayne.brill</dc:creator>
      <dc:date>2012-05-10T19:24:10Z</dc:date>
    </item>
    <item>
      <title>Re: apprentice error</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/apprentice-error/m-p/3453940#M136443</link>
      <description>&lt;P&gt;Ok, now I have a simple test program that illustrates my problem. When the user clicks the button on the form, a file open dialog box opens, and the user selects an idw file.&amp;nbsp; The program then extracts the first drawing sheet from this file and prints it to an XPS file.&amp;nbsp; The first file selected always works ok, but as soon as a second different file is selected the program crashes. Interestingly enough, if the first file is selected twice in a row, it works fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Note that in order to run this sample code, you will need to have the DWF Writer printer driver installed on your system.&amp;nbsp; Also, if I comment out the code pertaining to the printing, my problem also goes away.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Maybe somebody can spot something that I'm missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Inventor;
using System.IO;
using System.Diagnostics;
using System.Collections;
using System.Xml.Linq;



namespace ApprenticeTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            
            Inventor.ApprenticeServerComponent oApprentice = new ApprenticeServerComponent();
            Inventor.ApprenticeServerDrawingDocument drgDoc;

            string idwName = null;

            OpenFileDialog dlg = new OpenFileDialog();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                idwName = dlg.FileName;
            }

            drgDoc = (Inventor.ApprenticeServerDrawingDocument) oApprentice.Open(idwName);

            string xpsFileName = System.IO.Path.GetFileNameWithoutExtension(idwName);
            xpsFileName = @"C:\tempdwf\" + xpsFileName + ".DWFx";
            if (System.IO.File.Exists(xpsFileName)) System.IO.File.Delete(xpsFileName);

            Inventor.ApprenticeDrawingPrintManager pMgr;
            pMgr = (Inventor.ApprenticeDrawingPrintManager)  drgDoc.PrintManager;
            pMgr.Printer = "Autodesk DWF Writer for 2D";
            
            pMgr.SetSheetRange(1, 1);
            pMgr.PrintRange = PrintRangeEnum.kPrintSheetRange;
            pMgr.ScaleMode = Inventor.PrintScaleModeEnum.kPrintBestFitScale;
            pMgr.Orientation = PrintOrientationEnum.kLandscapeOrientation;
            pMgr.SubmitPrint();

                        
            Process.Start(xpsFileName);
             



        }
    }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 May 2012 13:36:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/apprentice-error/m-p/3453940#M136443</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-11T13:36:34Z</dc:date>
    </item>
  </channel>
</rss>

