How to access iLogic in Interop.Inventor?

How to access iLogic in Interop.Inventor?

shkangE79NB
Participant Participant
288 Views
3 Replies
Message 1 of 4

How to access iLogic in Interop.Inventor?

shkangE79NB
Participant
Participant

Hi, I'm creating an addin in c#.

I want to create a program that creates a ribbon button and runs iLogic when it is clicked.

 

This is my source.

 

 

_buttonDefinition.OnExecute += delegate(NameValueMap context)
{
    var addin = m_inventorApplication.ApplicationAddIns.get_ItemById(AddInClientID);
    iLogicAutomation logic = addin.Automation as iLogicAutomation;
    logic.RunRule(m_inventorApplication.ActiveDocument, "Hello");
};

 

 

In the above source code, addin.Automation is null in line 4.

"Hello" iLogic exists in the document.

 

shkangE79NB_0-1705303619775.png

Help me!!

 

Is my method wrong or is there a different way to access iLogic in Inventor 2024?

0 Likes
Accepted solutions (2)
289 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor
Accepted solution

Hi @shkangE79NB.  I am not fluent in C#, and I am not an experienced Inventor add-in creator, but the object there are a couple things in your code that might be questionable in my opinion.  First, you may need to use the 'IiLogicAutomation' Type for the variable instead of just 'iLogicAutomation' Type.  However, since I am not fluent in C#, you may need to 'cast' (or convert) the value you get from the iLogic ApplicationAddIn.Automation property to the IiLogicAutomation Type for it to work.  The second thing I would check is the value of your 'AddInClientID' input, to make sure that is the what you would get from the iLogic ApplicationAddIn.ClientId property, not some other ApplicationAddIn.  Not every ApplicationAddIn is going to have a useful value for that ApplicationAddIn.Automation property, but the one for iLogic does, but you must also make sure that the ApplicationAddIn has been activated before trying to use its Automation resources.  Just some initial thoughts.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

rjay75
Collaborator
Collaborator
Accepted solution

Verify the value of AddinClientID. The call you're making there is to get the addin corresponding to the id passed. If the value on line 4 is null then it means you're not getting the iLogic addin.

 

The id for iLogic is "{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}".

0 Likes
Message 4 of 4

shkangE79NB
Participant
Participant

The problem was solved by modifying the clientID.

Thank you!!

0 Likes