iLogic rule fails when trying to connect to a running instance of Inventor

iLogic rule fails when trying to connect to a running instance of Inventor

sergio_duran
Advocate Advocate
530 Views
3 Replies
Message 1 of 4

iLogic rule fails when trying to connect to a running instance of Inventor

sergio_duran
Advocate
Advocate

Hi Everyone,

 

An ilogic rule is triggered by an ERP Configurator. An Inventor instance is already running as a process and it was launched by a processor before running the iLogic rule.

 

If I only use iLogic syntax (snippets) within the rule, it works very well. However, if I include API objects (methods and properties), it fails. It doesn't recognize the API objects. ilogic doesn't need to get the Application (ThisApplication or Inventor.Application), but API does. I'm using the following code to get the Application but it doesn't work:

 

' Connect to a running instance of Inventor. 
Dim invApp As Inventor.Application 
invApp = System.Runtime.InteropServices.Marshal.GetActiveObject ("Inventor.Application") 

 

I've been trying to do simple things like displaying a message showing the ActiveDocument.DisplayName or ActiveDocument.FullFileName, but it doesn't work. Any idea how to connect to an existing Inventor instance from an iLogic rule? Thanks!

0 Likes
531 Views
3 Replies
Replies (3)
Message 2 of 4

MechMachineMan
Advisor
Advisor

How are you running these rules?


iLogic in and of itself is embedded in inventor, so you should just be able to get inventor by ThisApplication. I don't think you would be able to connect to a separate instance of inventor from within one iLogic rule, but you can connect to the one in which the rule is ran from.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 4

sergio_duran
Advocate
Advocate

Hi Justin,

Thanks for your reply! iLogic rule is run from an external application that loaded the iLogic dlls (Autodesk.iLogic.Automation.dll and Autodesk.iLogic.Interfaces.dll). Let's say this code executes an iLogic rule named "Configure", then it starts my ilogic rule, makes the changes and it's done. If I only use iLogic syntax (snippets) is fine, but when I combine these iLogic syntax with API objects within the same iLoigc rule, it fails. If I manually open Inventor and run the iLogic rule "Configure" from the Inventor session that I manually opened, it works well with both iLogic syntax and API objects as long as I used 'ThisApplication' to get the API objects. However, in the real scenario, I'm not opening Inventor manually, Inventor is already open by an external processor and I need to connect to that existing/running instance of Inventor. Then, in my code I won't use 'ThisApplication', because I didn't launch it (it's already running). I should use System.Runtime.InteropServices.Marshal.GetActiveObject ("Inventor.Application") but it doesn't work.

I hope I explained my situation better.

 

Any idea? Thanks!

 

 

0 Likes
Message 4 of 4

MechMachineMan
Advisor
Advisor

So you external application doesn't connect to Inventor, and only to the iLogic addin? Why not just connect to the inventor application with your external application and then use the iLogic addin within the scope of the inventor application?

 

Any iLogic rule that is ran within inventor should be aware of the application that it's running from, but if you are somehow running the add-in directly, it would make sense that it's tripping up as I don't think iLogic was ever intended to be utilized separately from the main application.

 

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type