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;
        }
Exemplo n.º 2
0
        public void RunRule(Document doc, string rule)
        {
            string iLogicAddinGuid = "{3BDD8D79-2179-4B11-8A5A-257B1C0263AC}";

            Inventor.ApplicationAddIn addin = null;
            try
            {
                addin = inventorApplication.ApplicationAddIns.get_ItemById(iLogicAddinGuid);
            }
            catch (Exception e)
            {
                LogError("Unable to load iLogic add-in: " + e.Message);
            }

            try
            {
                if (addin != null)
                {
                    LogTrace("Running rule: " + rule);
                    var iLogicAutomation = addin.Automation;
                    iLogicAutomation.RunRule(doc, rule);
                }
            }
            catch (Exception e)
            {
                LogError("Unable to run rule \"" + rule + "\": " + e.Message);
            }
        }
Exemplo n.º 3
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);
            }
        }