Message 1 of 9
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, how can I get the automation from iLogic?
I found
https://adndevblog.typepad.com/manufacturing/2015/05/use-goexcel-outside-a-rule.html
https://adndevblog.typepad.com/manufacturing/2013/04/call-ilogic-from-net.html
but I could not do it with c#. Here is my code
using Autodesk.iLogic.Interfaces;
...
public static IiLogicAutomation GetIlogicAutomation(Inventor.Application inventorApp) { IiLogicAutomation _iLogicAutomation = null; string iLogicAddinGuid = "{3BDD8D79-2179-4B11-8A5A-257B1C0263AC}"; Inventor.ApplicationAddIn addin = null; try { addin = inventorApp.ApplicationAddIns.get_ItemById(iLogicAddinGuid); } catch { } if (addin != null) { if (!addin.Activated) addin.Activate(); _iLogicAutomation = addin.Automation as IiLogicAutomation; _iLogicAutomation = (IiLogicAutomation)addin.Automation; <- //Invalid Cast Exception! } return _iLogicAutomation; } public static Autodesk.iLogic.Interfaces.iLogicRule GetiLogicRuleByName( IiLogicAutomation _iLogicAutomation, Inventor.Document oDoc, string ruleName) { Autodesk.iLogic.Interfaces.iLogicRule myRule = null; foreach (Autodesk.iLogic.Interfaces.iLogicRule eachRule in _iLogicAutomation.get_Rules(oDoc)) { if (eachRule.Name == ruleName) { myRule = eachRule; break; } } return myRule; } }
References:
..\Program Files\Autodesk\Inventor 2018\Bin\Autodesk.iLogic.Interfaces.dll
..\Program Files\Autodesk\Inventor 2018\Bin\Public Assemblies\Autodesk.Inventor.Interop.dll
Anyone have any suggestions or things I might try?
Christoph
Solved! Go to Solution.