<?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: setting up API in Visual Basic using C# in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/setting-up-api-in-visual-basic-using-c/m-p/12226670#M19308</link>
    <description>&lt;P&gt;Avoid to use ClientId = null. Here is modified version&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using Inventor;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Runtime.InteropServices;

namespace Furnace
{
    /// &amp;lt;summary&amp;gt;
    /// This is the primary AddIn Server class that implements the ApplicationAddInServer interface
    /// that all Inventor AddIns are required to implement. The communication between Inventor and
    /// the AddIn is via the methods on this interface.
    /// &amp;lt;/summary&amp;gt;
    [GuidAttribute("3d2d5718-2cc0-4563-8275-cb8d02ab983a")]
    public class StandardAddInServer : ApplicationAddInServer
    {
        private /*object*/ const string AddClientID = "{3d2d5718-2cc0-4563-8275-cb8d02ab983a}";
        private ButtonDefinition buttonDefinition;

        // Inventor application object.
        private Application m_inventorApplication;
        private UserInterfaceEvents m_uiEvents;

        public StandardAddInServer()
        {
        }

        #region ApplicationAddInServer Members

        public void Activate(ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            // This method is called by Inventor when it loads the addin.
            // The AddInSiteObject provides access to the Inventor Application object.
            // The FirstTime flag indicates if the addin is loaded for the first time.

            // Initialize AddIn members.
            m_inventorApplication = addInSiteObject.Application;
            m_uiEvents = m_inventorApplication.UserInterfaceManager.UserInterfaceEvents;

            var controlDefs = m_inventorApplication.CommandManager.ControlDefinitions;
            //IPictureDisp smallimage = 

            var commandManager = m_inventorApplication.CommandManager;

            buttonDefinition = commandManager.ControlDefinitions.AddButtonDefinition(
                "Furnace Automation", 
                "Automation",
                CommandTypesEnum.kQueryOnlyCmdType, 
                AddClientID);


            // Connect to the user-interface events to handle a ribbon reset.

            buttonDefinition.OnExecute += ButtonDefinition_OnExecute;
            buttonDefinition.AutoAddToGUI();

            if (firstTime) AddToUserInterface();
        }

        private void ButtonDefinition_OnExecute(NameValueMap Context)
        {
            throw new NotImplementedException();

        }

        public void Deactivate()
        {
            // This method is called by Inventor when the AddIn is unloaded.
            // The AddIn will be unloaded either manually by the user or
            // when the Inventor session is terminated

            // TODO: Add ApplicationAddInServer.Deactivate implementation

            // Release objects.
            m_inventorApplication = null;
            m_uiEvents = null;
            buttonDefinition = null;
            buttonDefinition.OnExecute -= ButtonDefinition_OnExecute;

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }

        public object Automation =&amp;gt;
            // This property is provided to allow the AddIn to expose an API 
            // of its own to other programs. Typically, this  would be done by
            // implementing the AddIn's API interface in a class and returning 
            // that class object through this property.
            // TODO: Add ApplicationAddInServer.Automation getter implementation
            null;

        #endregion

        #region User interface definition

        private void AddToUserInterface()
        {
            var ZeroLoc = m_inventorApplication.UserInterfaceManager.Ribbons["ZeroDoc"];
            var ToolLoc = ZeroLoc.RibbonTabs["id_TabTools"];
            string ClientID = AddClientID;
            var FinalLoc = ToolLoc.RibbonPanels.Add("Furnace Automation", "Automation2", ClientID);


            FinalLoc.CommandControls.AddButton(buttonDefinition);
        }

        public void ExecuteCommand(int CommandID)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 08 Sep 2023 08:01:40 GMT</pubDate>
    <dc:creator>Michael.Navara</dc:creator>
    <dc:date>2023-09-08T08:01:40Z</dc:date>
    <item>
      <title>setting up API in Visual Basic using C#</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/setting-up-api-in-visual-basic-using-c/m-p/12226076#M19307</link>
      <description>&lt;P&gt;I have previously had a multiple successful Add-ins created using VB.net. I was told I need to start writing them in C# so our IT department can better assist. The build is successful, it opens inventor, shows in the Add-in manager, however it won't populate the button in any ribbon. I have all functions called out same as in the VB.net Add-ins just translated to C# language. Below is the full 'StandardAddInServer.cs" file any assistance would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using Inventor;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Runtime.InteropServices;

namespace Furnace
{
    /// &amp;lt;summary&amp;gt;
    /// This is the primary AddIn Server class that implements the ApplicationAddInServer interface
    /// that all Inventor AddIns are required to implement. The communication between Inventor and
    /// the AddIn is via the methods on this interface.
    /// &amp;lt;/summary&amp;gt;
    [GuidAttribute("431205c6-c088-422e-82de-9bf8b0801f0c")]
  
    public class StandardAddInServer : Inventor.ApplicationAddInServer
    {

        // Inventor application object.
        private Inventor.Application m_inventorApplication;
        private UserInterfaceEvents m_uiEvents;
        private Inventor.ButtonDefinition buttonDefinition;
        private object AddClientID;

        public StandardAddInServer()
        {
            

        }

        #region ApplicationAddInServer Members

        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            // This method is called by Inventor when it loads the addin.
            // The AddInSiteObject provides access to the Inventor Application object.
            // The FirstTime flag indicates if the addin is loaded for the first time.

            // Initialize AddIn members.
            m_inventorApplication = addInSiteObject.Application;
            m_uiEvents = m_inventorApplication.UserInterfaceManager.UserInterfaceEvents;

            ControlDefinitions controlDefs = m_inventorApplication.CommandManager.ControlDefinitions;
            //IPictureDisp smallimage = 
            
            var commandManager = m_inventorApplication.CommandManager;

            buttonDefinition = commandManager.ControlDefinitions.AddButtonDefinition("Furnace Automation", "Automation", CommandTypesEnum.kQueryOnlyCmdType, AddClientID);



            // Connect to the user-interface events to handle a ribbon reset.

            buttonDefinition.OnExecute += ButtonDefinition_OnExecute;
            buttonDefinition.AutoAddToGUI();
        
            if (firstTime) 
            {
                AddToUserInterface();            
            }

        }

        private void ButtonDefinition_OnExecute(NameValueMap Context)
        {
            throw new NotImplementedException();
        }

        public void Deactivate()
        {
            // This method is called by Inventor when the AddIn is unloaded.
            // The AddIn will be unloaded either manually by the user or
            // when the Inventor session is terminated

            // TODO: Add ApplicationAddInServer.Deactivate implementation

            // Release objects.
            m_inventorApplication = null;
            m_uiEvents = null;
            buttonDefinition = null;
            buttonDefinition.OnExecute -= ButtonDefinition_OnExecute;

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }

        public object Automation
        {
            // This property is provided to allow the AddIn to expose an API 
            // of its own to other programs. Typically, this  would be done by
            // implementing the AddIn's API interface in a class and returning 
            // that class object through this property.

            get
            {
                // TODO: Add ApplicationAddInServer.Automation getter implementation
                return null;
            }
        }

        #endregion

        #region User interface definition

        private void AddToUserInterface()
        {

            Ribbon ZeroLoc = m_inventorApplication.UserInterfaceManager.Ribbons["ZeroDoc"];
            RibbonTab ToolLoc = ZeroLoc.RibbonTabs["id_TabTools"];
            string ClientID = null;
            RibbonPanel FinalLoc = ToolLoc.RibbonPanels.Add("Furnace Automation", "Automation2", ClientID);


            FinalLoc.CommandControls.AddButton(buttonDefinition);
        }

        public void ExecuteCommand(int CommandID)
        {
            throw new NotImplementedException();
        }

        #endregion

    }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 08 Sep 2023 00:31:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/setting-up-api-in-visual-basic-using-c/m-p/12226076#M19307</guid>
      <dc:creator>cstephens58F4Q</dc:creator>
      <dc:date>2023-09-08T00:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: setting up API in Visual Basic using C#</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/setting-up-api-in-visual-basic-using-c/m-p/12226670#M19308</link>
      <description>&lt;P&gt;Avoid to use ClientId = null. Here is modified version&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using Inventor;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Runtime.InteropServices;

namespace Furnace
{
    /// &amp;lt;summary&amp;gt;
    /// This is the primary AddIn Server class that implements the ApplicationAddInServer interface
    /// that all Inventor AddIns are required to implement. The communication between Inventor and
    /// the AddIn is via the methods on this interface.
    /// &amp;lt;/summary&amp;gt;
    [GuidAttribute("3d2d5718-2cc0-4563-8275-cb8d02ab983a")]
    public class StandardAddInServer : ApplicationAddInServer
    {
        private /*object*/ const string AddClientID = "{3d2d5718-2cc0-4563-8275-cb8d02ab983a}";
        private ButtonDefinition buttonDefinition;

        // Inventor application object.
        private Application m_inventorApplication;
        private UserInterfaceEvents m_uiEvents;

        public StandardAddInServer()
        {
        }

        #region ApplicationAddInServer Members

        public void Activate(ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            // This method is called by Inventor when it loads the addin.
            // The AddInSiteObject provides access to the Inventor Application object.
            // The FirstTime flag indicates if the addin is loaded for the first time.

            // Initialize AddIn members.
            m_inventorApplication = addInSiteObject.Application;
            m_uiEvents = m_inventorApplication.UserInterfaceManager.UserInterfaceEvents;

            var controlDefs = m_inventorApplication.CommandManager.ControlDefinitions;
            //IPictureDisp smallimage = 

            var commandManager = m_inventorApplication.CommandManager;

            buttonDefinition = commandManager.ControlDefinitions.AddButtonDefinition(
                "Furnace Automation", 
                "Automation",
                CommandTypesEnum.kQueryOnlyCmdType, 
                AddClientID);


            // Connect to the user-interface events to handle a ribbon reset.

            buttonDefinition.OnExecute += ButtonDefinition_OnExecute;
            buttonDefinition.AutoAddToGUI();

            if (firstTime) AddToUserInterface();
        }

        private void ButtonDefinition_OnExecute(NameValueMap Context)
        {
            throw new NotImplementedException();

        }

        public void Deactivate()
        {
            // This method is called by Inventor when the AddIn is unloaded.
            // The AddIn will be unloaded either manually by the user or
            // when the Inventor session is terminated

            // TODO: Add ApplicationAddInServer.Deactivate implementation

            // Release objects.
            m_inventorApplication = null;
            m_uiEvents = null;
            buttonDefinition = null;
            buttonDefinition.OnExecute -= ButtonDefinition_OnExecute;

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }

        public object Automation =&amp;gt;
            // This property is provided to allow the AddIn to expose an API 
            // of its own to other programs. Typically, this  would be done by
            // implementing the AddIn's API interface in a class and returning 
            // that class object through this property.
            // TODO: Add ApplicationAddInServer.Automation getter implementation
            null;

        #endregion

        #region User interface definition

        private void AddToUserInterface()
        {
            var ZeroLoc = m_inventorApplication.UserInterfaceManager.Ribbons["ZeroDoc"];
            var ToolLoc = ZeroLoc.RibbonTabs["id_TabTools"];
            string ClientID = AddClientID;
            var FinalLoc = ToolLoc.RibbonPanels.Add("Furnace Automation", "Automation2", ClientID);


            FinalLoc.CommandControls.AddButton(buttonDefinition);
        }

        public void ExecuteCommand(int CommandID)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 08 Sep 2023 08:01:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/setting-up-api-in-visual-basic-using-c/m-p/12226670#M19308</guid>
      <dc:creator>Michael.Navara</dc:creator>
      <dc:date>2023-09-08T08:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: setting up API in Visual Basic using C#</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/setting-up-api-in-visual-basic-using-c/m-p/12227639#M19309</link>
      <description>&lt;P&gt;I figured out the issue was I was calling an old .dll file so all the changes I had done were not being updated in the active file in Inventor.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 14:55:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/setting-up-api-in-visual-basic-using-c/m-p/12227639#M19309</guid>
      <dc:creator>cstephens58F4Q</dc:creator>
      <dc:date>2023-09-08T14:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: setting up API in Visual Basic using C#</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/setting-up-api-in-visual-basic-using-c/m-p/12227640#M19310</link>
      <description>&lt;P&gt;Thanks for the pointer on that item. I am learning C# on the fly currently with this change.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 14:56:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/setting-up-api-in-visual-basic-using-c/m-p/12227640#M19310</guid>
      <dc:creator>cstephens58F4Q</dc:creator>
      <dc:date>2023-09-08T14:56:03Z</dc:date>
    </item>
  </channel>
</rss>

