Get name of current ilogic rule

Get name of current ilogic rule

Curtis_Waguespack
Consultant Consultant
2,935 Views
13 Replies
Message 1 of 14

Get name of current ilogic rule

Curtis_Waguespack
Consultant
Consultant

Is there a way to get the name of the current ilogic rule, when it runs.

 

Something like this:

 

'get iLogic addin
Dim iLogicAuto As Object
iLogicAuto = iLogicVb.Automation

'get collection of rules
Dim rules As Object
rules = iLogicAuto.rules(ThisApplication.ActiveDocument)

'make sure there are rules in the file
If Not (rules Is Nothing) Then
    For Each rule In rules
        'write rule to debugger
        If rule.Name = ThisRule.Name Then
        Trace.WriteLine(rule.Name, "iLogic") 
        End If
    Next 
End If

 

 

Thanks in advance,

Curtis

EESignature

0 Likes
Accepted solutions (2)
2,936 Views
13 Replies
Replies (13)
Message 2 of 14

Anonymous
Not applicable

Hi Curtis,

Is it your intention to specifically avoid using a MessageBox? Otherwise, perhaps the simplest solution would be to add MsgBox("Your rule name here") as the first program line in your rule text.

0 Likes
Message 3 of 14

Curtis_Waguespack
Consultant
Consultant

Hi jwterminator1,

 

Thanks for the reply.

 

My intention here is really just not to have to know the name of rule, and have the code write out the name of the rule that is running to the debugger:

http://adndevblog.typepad.com/manufacturing/2014/08/debug-ilogic.html

 

But whether it's the debugger or message box, currently the best I can do is what you suggest, which is to type in the name at the top of the rule.

 

Thanks again,

Curtis

EESignature

0 Likes
Message 4 of 14

Anonymous
Not applicable

After a quick browse through the object references in the various iLogic dlls that I could find, I didn't an accessible pathway to access the information regarding currently running iLogic rules so you may only be left with the hard coded name method which you could still send through to the debugger.

Message 5 of 14

MechMachineMan
Advisor
Advisor

See attached excel in the linked thread for your own look at the exposed calls in the iLogic api.

 

https://forums.autodesk.com/t5/inventor-customization/ilogic-api-documentation/td-p/6785772


--------------------------------------
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
Message 6 of 14

Curtis_Waguespack
Consultant
Consultant

Hi MechMachineMan,

 

Hey thanks for taking the time to post that.

 

In looking through that XLS file I find this:

            Autodesk.iLogic.Interfaces.iLogicRule.Name

 

But I'm still unclear how to call that from the iLogic rule.

 

When I compare it to the line calling the rules collection it looks like this:

            Autodesk.iLogic.Interfaces.IiLogicAutomation.Rules(Inventor.Document)
            Autodesk.iLogic.Interfaces.iLogicRule.Name

 

So does that mean iLogicRule.Name is not part of IiLogicAutomation add in?

 

I see another user was trying to do much the same thing here in the past, but there isn't any reply or solution:

https://forums.autodesk.com/t5/inventor-customization/get-the-name-of-ilogic-rule/td-p/3425633

 

 

I wonder if @wayne.brill can give me a nudge in the right direction?

 

Thanks,

Curtis

 

 

 

 

EESignature

0 Likes
Message 7 of 14

MechMachineMan
Advisor
Advisor

 

From what I could find, using the iLogicVB call only provides access to the Autodesk.iLogic.Interfaces.ILowLevelSupport object, and trying to call iLogicVB.Automation only provides access to the Autodesk.iLogic.Interfaces.IiLogicAutomation.

 

So I tried to go around this with the code below by accessing the iLogic addin and then accessing interfaces from there so I could access the Autodesk.iLogic.Interfaces call directly.

 

Trying this leads me to believe either the code I have doesn't allow me to access the Interfaces directly, or I have to use some other call to access Interfaces from the addin ie;

oiLogicInterfaces = addin.iLogicInterfaces

 

With my limited knowledge so far, I'm not sure if it's even possible to use intelli-sense or object browser to find out if I can go deeper, so at this point I have run out of usefulness. Hopefully one of the Autodesk folk can chime in and help us out here!

 

VB.Net version of code.

Sub Main()
    Dim iLogic As Object
    iLogic = GetiLogicAddin(ThisApplication)
    
    If (iLogic Is Nothing) Then Exit Sub

    Dim doc As Document
    doc = ThisApplication.ActiveDocument
    
    Dim i As Integer
    
    'MsgBox(iLogic.Interfaces.iLogicRule.Name)
End Sub

Function GetiLogicAddin(oApplication As Inventor.Application) As Object
    addIns = oApplication.ApplicationAddIns
    Dim addIn As ApplicationAddIn
    
    'On Error Goto NotFound
    
    addIn = oApplication.ApplicationAddIns.ItemById("{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}")
    
    If (addIn Is Nothing) Then Exit Function
    
    addIn.Activate
    MsgBox(addin.Description)
    MsgBox(addIn.Interfaces.iLogicRule.Name)
    
    Return addIn
    Exit Function
    NotFound:
End Function

 


--------------------------------------
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
Message 8 of 14

Curtis_Waguespack
Consultant
Consultant

 


Autodesk Customer Support wrote: (via email) 

 

 

Dear Curtis Waguespack,

Support Case12523678 (Get name of current ilogic rule) is now closed. If you still need help with this issue, please reply to this email and include additional details. You can also review or respond to your support cases online in your Autodesk support portal.

Autodesk is committed to providing excellent customer service. As part of the support process, we may send you an optional survey for your feedback.

Thanks for contacting Autodesk for support.

Best regards,

Developer Technical Services

 

 


I received this message via email. And replied with this:

 


Curtis_Waguespack wrote: (via email)

 

I assume this is just an automated message, but it misses the mark considering that there was not response from Autodesk on the actual question. If the answer is it can't be done, that's okay.

 

But no response to the question, and then messages informing the customer that the case is being closed, makes Autodesk support look quite bad. 

 


Then I received the same email shown above 3 more times.

 

Smiley Surprised

 

anyway, I'm giving this thread one more bump, so ......bump!

EESignature

0 Likes
Message 9 of 14

MjDeck
Autodesk
Autodesk

Hi Curtis,

There is no way to get the name of the calling rule from the iLogic system. That would definitely be useful. We can add it in a future release.


Mike Deck
Software Developer
Autodesk, Inc.

Message 10 of 14

Curtis_Waguespack
Consultant
Consultant

Hi MjDeck,

 

Thanks for confirming this for us.

 

And yes if we could do this in a future release that would be outstanding!

 

Thanks again,

Curtis

EESignature

0 Likes
Message 11 of 14

WCrihfield
Mentor
Mentor
Accepted solution

Maybe I'm missing something, but the quickest and easiest way I know of to get the name of the currently running rule using iLogic is the following line:

iLogicVb.RuleName

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 12 of 14

MjDeck
Autodesk
Autodesk
Accepted solution

@WCrihfield , that method was not available in Inventor 2018 and earlier.

Thanks for posting. I forgot to announce the new function on this thread.


Mike Deck
Software Developer
Autodesk, Inc.

Message 13 of 14

Maxim-CADman77
Advisor
Advisor

@MjDeck 
Any possibility to get external rule's FullFileName (directory and/or extension)?

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 14 of 14

MjDeck
Autodesk
Autodesk

Hi Maxim,

Yes, that would be relatively easy to do. I created a user story (internal number INVGEN-71847). We should be able to do it soon, but maybe not in the 2025 release.


Mike Deck
Software Developer
Autodesk, Inc.