C# iLogic Automation

C# iLogic Automation

Daan_M
Collaborator Collaborator
1,128 Views
1 Reply
Message 1 of 2

C# iLogic Automation

Daan_M
Collaborator
Collaborator

Hi forum,

 

The code below adds iLogic and then runs a rule of my choice. which is great.

Now i want to run a rule multiple times, i call 'AddiLogic()' elsewhere in my code when i need the rule to run.

 

I assume it's not needed to run this whole block of code just for the rule to run. I think i only need the last part of block, so i could split the block into two:

 

one does AddiLogic();

the other does RunRule();

 

the problem is that i'm quite new to coding and when i split it it looses all references and creates a whole list of errors, see the code further below for what my goal is...

 

 

 

void AddiLogic()
        {
            string MyRuleName = textBox2.Text;
            string iLogicAddinGuid = "{3BDD8D79-2179-4B11-8A5A-257B1C0263AC}";
            ApplicationAddIn iLogicAddin;
            dynamic iLogicAutomation = null;

            try
            {
                iLogicAddin = _invApp.ApplicationAddIns.ItemById[iLogicAddinGuid];
                iLogicAutomation = iLogicAddin.Automation;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to access iLogic addin " + ex.Message);
            }

            // niet nodig om de hele AddIlogic toe te voegen, alleen de rule uitvoeren is voldoende...

            try
            {

                iLogicAutomation.Runrule(oDoc, MyRuleName);
            }
            catch
            {
                MessageBox.Show("There is no rule called " + MyRuleName);
            }

        }
   void AddiLogic()
        {
            string MyRuleName = textBox2.Text;
            string iLogicAddinGuid = "{3BDD8D79-2179-4B11-8A5A-257B1C0263AC}";
            ApplicationAddIn iLogicAddin;
            dynamic iLogicAutomation = null;

            try
            {
                iLogicAddin = _invApp.ApplicationAddIns.ItemById[iLogicAddinGuid];
                iLogicAutomation = iLogicAddin.Automation;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to access iLogic addin " + ex.Message);
            }
        }
           
        void RunRule()
        {
                try
                {

                    iLogicAutomation.Runrule(oDoc, MyRuleName);
                }
                catch
                {
                    MessageBox.Show("There is no rule called " + MyRuleName);
                }
        }

 

0 Likes
Accepted solutions (1)
1,129 Views
1 Reply
Reply (1)
Message 2 of 2

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@Daan_M,

 

Try suggestion in the below blog link.

 

https://adndevblog.typepad.com/manufacturing/2013/09/run-ilogic-rule-from-external-application.html

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes