public Form1()
        {
            InitializeComponent();

            try
            {
                _InvApplication = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application") as Inventor.Application;
            }

            catch
            {
                Type inventorAppType = System.Type.GetTypeFromProgID("Inventor.Application");
                _InvApplication = System.Activator.CreateInstance(inventorAppType) as Inventor.Application;
            }

            _InvApplication.Visible = true;

            string addInCLSID = "{28e1f9bc-44fb-464c-ba98-e9c14c7eed44}";

            Inventor.ApplicationAddIn addIn = _InvApplication.ApplicationAddIns.get_ItemById(addInCLSID.ToUpper());

            //Make sure addin is activated
            if (!addIn.Activated)
            {
                addIn.Activate();
            }

            _InvAddInInterface = addIn.Automation as HelloWorldCSharp.AutomationInterface;
        }
Пример #2
0
        public static IiLogicAutomation GetiLogicAutomation()
        {
            try
            {
                if (_iLogicAutomation == null)
                {
                    Inventor.ApplicationAddIn addin =
                        AdnInventorUtilities.InvApplication.ApplicationAddIns.ItemById[iLogicAddinGuid];

                    if (addin.Activated == false)
                    {
                        addin.Activate();
                    }

                    _iLogicAutomation = (IiLogicAutomation)addin.Automation;
                }

                return(_iLogicAutomation);
            }
            catch
            {
                return(null);
            }
        }