<?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: AddIn Automation Interface problem in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-automation-interface-problem/m-p/7322406#M74405</link>
    <description>&lt;P&gt;Only to extend the discussion, I tested the Add in with a simple form application but it load the dll in a very strange ways&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TestAddIn&lt;BR /&gt;Versione assembly: 1.0.6444.27930&lt;BR /&gt;Versione Win32: 1.0.6444.27930&lt;BR /&gt;Base di codice: file:///C:/Users/p.cappelletto/Documents/workspace/VisualStudio2012/TestAddInApp/TestAddInApp/bin/Debug/TestAddIn.DLL&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;.DLL???? Could be this the problem?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;P&lt;/P&gt;</description>
    <pubDate>Wed, 23 Aug 2017 14:37:31 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-08-23T14:37:31Z</dc:date>
    <item>
      <title>AddIn Automation Interface problem</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-automation-interface-problem/m-p/7319414#M74387</link>
      <description>&lt;P&gt;HI&lt;/P&gt;&lt;P&gt;I have this error when I try to call the AddIn from the other application:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unable to cast COM object of type 'System.__ComObject' to interface type 'HInventorServer2013.IAutomation'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{89D1FA61-3CEB-365D-A1F5-9A664F525CCB}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried many different things but nothing works until now.&lt;/P&gt;&lt;P&gt;The AddIn is here:&lt;/P&gt;&lt;P&gt;C:\Users\me_as_user\AppData\Roaming\Autodesk\ApplicationPlugins\HInventorServer2013&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe I have to register the DLL generated from the StandardAddInServer?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know what else to do.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Paolo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is for inventor 2013 but i didn't works also for Inventor 2017&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Implementation is very easy, nothing fancy:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[GuidAttribute("88095ac1-6393-458d-8327-c168f027da88")]
public class StandardAddInServer : Inventor.ApplicationAddInServer, IAutomation
{
private Inventor.Application _AddInApp;
private string _AddInGuid = "{88095ac1-6393-458d-8327-c168f027da88}";

public StandardAddInServer() {}

public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
{
  _AddInApp = addInSiteObject.Application;
}

public void Deactivate()
{
    // Release objects.
    Marshal.ReleaseComObject(_AddInApp);
    _AddInApp = null;

    GC.WaitForPendingFinalizers();
    GC.Collect();
}

public void ExecuteCommand(int commandID) {}

public object Automation
{
    get { return this; }
}

// Interface implementation
public string HI_GetCurrDocument()
{
    PartDocument doc;
    // Container pippo = new Container();
    string text = "";

    try
    {
        doc = _AddInApp.ActiveDocument as Inventor.PartDocument;
        text = doc.DisplayName;
        // pippo.GetContainer = doc.DisplayName;
    }
    catch (Exception e)
    {
        // pippo.GetContainer = e.ToString();
        text = e.ToString();
    }

    return text;
}

public string HI_GetSketchLines()
{
    /*
    Container test = new Container("ciao da API");

    return test;
    */
    return "Hello from API";
}
}&lt;/PRE&gt;&lt;P&gt;and this is the call&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public CallAddIn()
{
    try
    {
        _InvApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application") as Inventor.Application;
    }
    catch
    {
        Type InvAppType = System.Type.GetTypeFromProgID("Inventor.Application");
        _InvApp = System.Activator.CreateInstance(InvAppType) as Inventor.Application;
    }
    
    _InvApp.Visible = true;

    // hard coding Guid of the AddIn
    string AddInGuid = "{88095ac1-6393-458d-8327-c168f027da88}";
    ApplicationAddIn InvAddIn = _InvApp.ApplicationAddIns.get_ItemById(AddInGuid.ToUpper());
    // make sure addIn is activaded
    if (!InvAddIn.Activated)
    {
        InvAddIn.Activate();
    }
    // this works - InvAddIn is correct
    Debug.Print(InvAddIn.DisplayName);
    // version 1 - this give me an error
    IAutomation HIapi = (IAutomation) InvAddIn.Automation;
    // this give a null object - conversion failed
    IAutomation HIapi = InvAddIn.Automation as IAutomation;
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 16:10:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-automation-interface-problem/m-p/7319414#M74387</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-22T16:10:05Z</dc:date>
    </item>
    <item>
      <title>Re: AddIn Automation Interface problem</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-automation-interface-problem/m-p/7322406#M74405</link>
      <description>&lt;P&gt;Only to extend the discussion, I tested the Add in with a simple form application but it load the dll in a very strange ways&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TestAddIn&lt;BR /&gt;Versione assembly: 1.0.6444.27930&lt;BR /&gt;Versione Win32: 1.0.6444.27930&lt;BR /&gt;Base di codice: file:///C:/Users/p.cappelletto/Documents/workspace/VisualStudio2012/TestAddInApp/TestAddInApp/bin/Debug/TestAddIn.DLL&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;.DLL???? Could be this the problem?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;P&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2017 14:37:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-automation-interface-problem/m-p/7322406#M74405</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-23T14:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: AddIn Automation Interface problem</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-automation-interface-problem/m-p/7332806#M74488</link>
      <description>&lt;P&gt;I think that for using Automation it's mandatory redister the AddIn's DLL.&lt;/P&gt;&lt;P&gt;I tried different solutions but in my case it works only on this way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If someone else had the same problems I would like to know alternative solutions.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;P&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2017 11:15:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-automation-interface-problem/m-p/7332806#M74488</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-28T11:15:19Z</dc:date>
    </item>
  </channel>
</rss>

