- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Call external ilogic rule that returns value
Hi there,
What is best practice to call an external rule that returns a value that can be processed by the calling rule?
For example: the external rules iterates through all occs in the assembly
all occs are collected in a collection object
The collection object will then be returned to the calling rule
the calling rule will execute logic on the returned collection
I would like to know if an external rule can return values to the calling rule (without using shared variable)
thanks in advance
br martijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I dont think so.
iLogic is set-up to be more of a macro feature - code that can be run, but doesn't return a value.
A better bet would to be to set up your program to include multiple subs/functions including the 2nd one you want to use as when you use a function you can return results.
ie;
Sub Main() 'Required name and line
oNewValue = YourFunction(args,,,) 'Function call line
'Additional functionality here or above
End Sub
Function YourFunction(arg1 as type, arg2 as type, ....) ' requires args
'Rule Functionality here
End Function
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I know this is old, but seeing as this was a prominent answer in my search I felt I needed to supply an answer.
Yes you can.
Search how to send values to an ExternalRule using a NameValueMap.
Dim Map As Inventor.NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap()
You send the value by the following;
Map.Add("NameofValue", Value)
Map.Add("NameofValue2", Value2), etc.
Call your external Rule via
ilogicVb.RunExternalRule("ExternalRuleName",Map)
In the external Rule you access the Map values from
NameofValue = RuleArguments("NameofValue")
To return a new value to the original Rule use the following;
RuleArguments.Arguments.Value("NameofValue") = NewValue
When you return to the Calling Rule, use the following;
NewValue =Map.Value("NameofValue")
Please exercise caution with copy paste of my code. I typed this in a hurry and nothing was a copy paste from working code. But I hope this will help someone out someday. (Most likely myself if I'm honest)