<?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 Autodesk.AutoCAD.Interop in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/autodesk-autocad-interop/m-p/8168905#M25176</link>
    <description>&lt;P&gt;I'm trying to start AutoCAD using COM Interop but can't get it to work.&amp;nbsp; If I manually start AutoCAD and set the variable "STARTUP" to 3, everything works.&amp;nbsp; If I leave it at the default value of 2, it won't. My AcadApplication is valid but all of the methods throw exceptions.&amp;nbsp; Here's a code snippet:&lt;/P&gt;&lt;PRE&gt;                    try
                    {
                        pACADApp = (AcadApplication)Marshal.GetActiveObject(szProgramId);
                        fWasAutoCADRunning = true;
                    }
                    catch (COMException)
                    {
                        try
                        {
                            pACADApp = new AcadApplication();
                        }
                        catch (Exception) { }
                    }

                    if (pACADApp == null)
                    {
                        Application.Current.Dispatcher.Invoke(() =&amp;gt;
                        {
                            string szErrorMsg = string.Format("Failed to create an instance of AutoCAD. Please ensure AutoCAD is properly installed on this computer before processing.\n\nExpected program id: {0}", szProgramId);
                            GenericMessageBox pErrorDlg = new GenericMessageBox("Process Failed", szErrorMsg, GenericMessageBox.MessageBoxButtons.OK, GenericMessageBox.MessageBoxIcon.Error);
                            pErrorDlg.Owner = pMainWindow;
                            pErrorDlg.ShowDialog();
                        });
                        return;
                    }

                    this.pProgress.szPrimaryStatus = "Sending AutoCAD command";

                    //  Wait for AutoCAD to finish opening
                    while (true)
                    {
                        try
                        {
                            pACADApp.Visible = true;
                            pACADApp.WindowState = Autodesk.AutoCAD.Interop.Common.AcWindowState.acMin;
                            break;
                        }
                        catch { }
                    }&lt;/PRE&gt;&lt;P&gt;It fails to clear the "while (true)" loop.&amp;nbsp; pACADApp.Visible throws an exception.&amp;nbsp; In fact, all of the methods of pACADApp throw exceptions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Joe&lt;/P&gt;</description>
    <pubDate>Tue, 31 Jul 2018 21:38:32 GMT</pubDate>
    <dc:creator>JosephAugustino</dc:creator>
    <dc:date>2018-07-31T21:38:32Z</dc:date>
    <item>
      <title>Autodesk.AutoCAD.Interop</title>
      <link>https://forums.autodesk.com/t5/net-forum/autodesk-autocad-interop/m-p/8168905#M25176</link>
      <description>&lt;P&gt;I'm trying to start AutoCAD using COM Interop but can't get it to work.&amp;nbsp; If I manually start AutoCAD and set the variable "STARTUP" to 3, everything works.&amp;nbsp; If I leave it at the default value of 2, it won't. My AcadApplication is valid but all of the methods throw exceptions.&amp;nbsp; Here's a code snippet:&lt;/P&gt;&lt;PRE&gt;                    try
                    {
                        pACADApp = (AcadApplication)Marshal.GetActiveObject(szProgramId);
                        fWasAutoCADRunning = true;
                    }
                    catch (COMException)
                    {
                        try
                        {
                            pACADApp = new AcadApplication();
                        }
                        catch (Exception) { }
                    }

                    if (pACADApp == null)
                    {
                        Application.Current.Dispatcher.Invoke(() =&amp;gt;
                        {
                            string szErrorMsg = string.Format("Failed to create an instance of AutoCAD. Please ensure AutoCAD is properly installed on this computer before processing.\n\nExpected program id: {0}", szProgramId);
                            GenericMessageBox pErrorDlg = new GenericMessageBox("Process Failed", szErrorMsg, GenericMessageBox.MessageBoxButtons.OK, GenericMessageBox.MessageBoxIcon.Error);
                            pErrorDlg.Owner = pMainWindow;
                            pErrorDlg.ShowDialog();
                        });
                        return;
                    }

                    this.pProgress.szPrimaryStatus = "Sending AutoCAD command";

                    //  Wait for AutoCAD to finish opening
                    while (true)
                    {
                        try
                        {
                            pACADApp.Visible = true;
                            pACADApp.WindowState = Autodesk.AutoCAD.Interop.Common.AcWindowState.acMin;
                            break;
                        }
                        catch { }
                    }&lt;/PRE&gt;&lt;P&gt;It fails to clear the "while (true)" loop.&amp;nbsp; pACADApp.Visible throws an exception.&amp;nbsp; In fact, all of the methods of pACADApp throw exceptions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Joe&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 21:38:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/autodesk-autocad-interop/m-p/8168905#M25176</guid>
      <dc:creator>JosephAugustino</dc:creator>
      <dc:date>2018-07-31T21:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: Autodesk.AutoCAD.Interop</title>
      <link>https://forums.autodesk.com/t5/net-forum/autodesk-autocad-interop/m-p/8194615#M25177</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you getting&amp;nbsp;COM calls rejected error? Have you implemented&amp;nbsp; IMessageFilter as shown in&amp;nbsp;&lt;A href="http://through-the-interface.typepad.com/through_the_interface/2010/02/handling-com-calls-rejected-by-autocad-from-an-external-net-application.html&amp;nbsp;" target="_blank"&gt;http://through-the-interface.typepad.com/through_the_interface/2010/02/handling-com-calls-rejected-by-autocad-from-an-external-net-application.html&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2018 06:08:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/autodesk-autocad-interop/m-p/8194615#M25177</guid>
      <dc:creator>Virupaksha_aithal</dc:creator>
      <dc:date>2018-08-13T06:08:09Z</dc:date>
    </item>
  </channel>
</rss>

