Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Running iLogic rules from .net app is extremely slow

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
greg.mort
1557 Views, 12 Replies

Running iLogic rules from .net app is extremely slow

Open inventor, run a rule that makes a handful of parameter changes, etc. It takes ~20 seconds to run

 

Open a .net app that uses the Inventor .net API to call 

 

iLogicAutomation.RunRuleWithArguments

 

with Inventor running in the background or as a separate app

 

it takes minutes to run.

 

How can we have similar performance to running these rules as if we ran them manually within inventor?

12 REPLIES 12
Message 2 of 13
yan.gauthier
in reply to: greg.mort

The .Net app in question is it an .exe app that Marshalls to the inventor app ?

 

If yes, then I'd say it is to be expected. marshalling takes time. My guess is that the Ilogic Rule runs on the calling thread. Your app being on an external thread, it means that every calls to Inventor objects are to be marshalled...

If what you hope, by using a .Net app, is to improve performance, then I recommend that you create an Addin and then translate all your  ILogic rules into your addin, you would be able to create command button just like with VBA macros and the performance will be better. 

 

In my experience, a complex operation took about 16 sec with VBA, 30 sec with a .NET app and 10 sec with a .Net addin  

Message 3 of 13
greg.mort
in reply to: yan.gauthier

interesting... Could I then go the c++ route? and build my .exe app using the c++ API instead of the .net API? I haven't dug deep enough to understand if that uses Pinvoke and perhaps has better performance. It does appear possible to run c++ with ilogic rules https://adndevblog.typepad.com/manufacturing/2013/09/run-ilogic-rule-from-external-application.html
Message 4 of 13
yan.gauthier
in reply to: greg.mort

Hi,

 

Honestly, I am pretty sure switching to C++ won't change anything. My approach would be to create an addin with C# and simply rebuild the rules from within the addin.

 

You can use the code samples from the SDK.

 

On a side note, Unity's dev team confirmed that C# can run as fast as C++ if you use the right libraries and all. On the other end, Linq is so much of a godsend, performance loss is rarely an issue is those case. 

Message 5 of 13
greg.mort
in reply to: yan.gauthier

Tried it yesterday in c++ with negligible changes. Running COM that then has to interface with the addin (which is still a .net dll) means it only adds to the complexity.

 

The ilogic rules are already created (hundreds of them), so switching them to be an add in I don't think makes a lot of sense for our end goal. We are trying to eventually replace them all, but wanted to have our API approach be able to match what they are currently doing (by simply just calling them) and slowly replace them, but its just too slow...

 

Not sure there is a winning solution to this, unless someone has a novel idea of what to do?

 

 

 

Message 6 of 13
yan.gauthier
in reply to: greg.mort

I'm pretty sure that using that calling the ilogic automation API from within an addin would work without issue. All you need is declare the addinServer and the button definitions. that way, the process that calls the Ilogic would be Inventor itself, so no com interop performance loss

 

Otherwise, you could set your Ilogic to trigger with a parameter and then use your .Net app to change the parameter only ?

Message 7 of 13

If you know the command name you can use the commandmanager for it!

This should be easy.

Like:

Thisapplication.commandmanager.contoldefinition.item(commandname).execute

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

Message 8 of 13

There are quite a few commands available within the ControlDefinition, but not 'runrule'

iLogic.About : About iLogic : About iLogic
iLogic.AddForm : Add Form : Add Form
iLogic.AddRule : Add Rule : Add Rule
iLogic.AssignName : Assign Name... : Assign Name...
iLogic.ClearCodeClipboard : Clear captured code : Clear captured code
iLogic.Configuration : iLogic Configuration : iLogic Configuration
iLogic.DeleteAllRules : Delete All Rules : Delete All Rules
iLogic.DeleteName : Delete Name : Delete Name
iLogic.DrawingGenerateCode : Capture Current State : Capture Current State
iLogic.EditName : Edit Name... : Edit Name...
iLogic.EditRule : Edit Rule : Edit Rule
iLogic.EventTriggers : Event Triggers : Event Triggers
iLogic.FreeILogicMemory : Free iLogic Memory : Free iLogic Memory
iLogic.HideLabel : Hide Label : Hide Label
iLogic.HideLabels : Hide Labels : Hide Labels
iLogic.iCopy : iLogic Design Copy : iLogic Design Copy
ilogic.logwindow : :
iLogic.PlaceComponent : Place iLogic Component : Place iLogic Component
iLogic.RegenAllRules : Regenerate All Rules : Regenerate All Rules
iLogic.RuleBrowser : iLogic Browser : iLogic Browser
iLogic.ShowLabel : Show Label : Show Label
iLogic.ShowLabels : Show Labels : Show Labels
ilogic.treeeditor : :
iLogic.Trigger : iTrigger : iTrigger
iLogic.XmlExport : Export to XML : Export to XML
iLogic.XmlImport : Import from XML : Import from XML

Message 9 of 13
johnster100
in reply to: greg.mort

any update on this? I'm facing the exact same issue 😞

Message 10 of 13
TONELLAL
in reply to: johnster100

Same thing for me, 2 years later...
Always no improvements ?
Message 11 of 13
Frederick_Law
in reply to: greg.mort

Don't think so.

App run outside IV processing and memory space.  It'll always be slower.

https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-4939ABD1-A15E-473E-9376-D8208EC029EB

 

ilogic, addin and macro run inside IV.

 

Converting iLogic to VB.Net shouldn't be difficult.  Most of it is VB code.

I've converted all my macro to addin.

Message 12 of 13
TONELLAL
in reply to: Frederick_Law

I have a current VBA macro like this :

Sub bt_Extraire_Click()
   ExportPartsBOM
End Sub

The workflow is :

-from the iLogic browser : right click "Run all rules"

-run the macro

 

So I've modified the macro :

Sub bt_Extraire_Click()
 ThisApplication.CommandManager.ControlDefinitions.Item("iLogic.RegenAllRules").Execute
   ExportPartsBOM
End Sub

 

And now... The execution of the rules take several minutes, instead of some seconds !

Message 13 of 13
Frederick_Law
in reply to: greg.mort

Yes, it is slow.  We all know it.  It can't be faster.  Use something else.

 

That's why I converted all my macros to Addin.  Since at least IV2012.

I've been using iLogic for 2 years and again I found the need to go to Addin.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report