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: 

VBA code to disable event triggers

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
LarsBJepsen
945 Views, 5 Replies

VBA code to disable event triggers

Hi,

 

I've found this code that should disable all event triggers, but i cant get i to work. 

 

Set iLogicVb = ThisApplication.ApplicationAddIns.ItemById("{3BDD8D79-2179-4B11-8A5A-257B1C0263AC}")
Set a = iLogicVb.Automation
a.RulesOnEventsEnabled = False


' your original code here


a.RulesOnEventsEnabled = True

I want to switch between the settings marked in the picture below:

 

LarsBJepsen_0-1612815252761.png

Can anyone help?

5 REPLIES 5
Message 2 of 6
WCrihfield
in reply to: LarsBJepsen

Interesting observation @LarsBJepsen.

I have tried toggling both the IiLogicAutomation.RulesEnabled Property and the IiLogicAutomation.RulesOnEventsEnabled Property by iLogic and VBA, but neither of them toggles any of those visible check boxes within the 'iLogic Security' dialog.  It's almost like they aren't the same settings, even though the descriptions sound almost identical.  Within the code, after toggling the iLogic automation settings, they are definitely being changed (from the iLogic code's perspective), because you can easily check the results in some following lines of the code with a MsgBox.

So, I also tried the reverse process...changing these settings within in the dialog, then checking these settings within the code, to see if maybe they only work in one direction.  That seemed to have no effect either.

Maybe someone at Autodesk could shed some light on this subject? @MjDeck , @chandra.shekar.g , @Scott_Parker 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 6
MjDeck
in reply to: LarsBJepsen

@WCrihfield , that's right. Those are two separate (but related) things.

We don't want it to be possible to disable the security settings by using the API. That would be a vulnerability.
So *both* the API property RulesOnEventsEnabled *and* the security setting in the dialog must be enabled if you want rules to run on events. (There is no separate API property for the Open and Close event.)
But if you want to disable rules on events, it's sufficient to set either the API property to False *or* to disable the option in the dialog.


Mike Deck
Software Developer
Autodesk, Inc.

Message 4 of 6
LarsBJepsen
in reply to: MjDeck

Hi Mike,

 

Disable rules on events is exactly what i want to do, but I can't get the code right for it. Can you help with some code that disables rules on events?

 

/Lars

Message 5 of 6
MjDeck
in reply to: LarsBJepsen

@LarsBJepsen , the code you posted above should work.

a.RulesOnEventsEnabled = False

As I noted above, it will not affect the setting in the dialog. But it should disable rules on events.
Are you testing with code that raises an event after you set RulesOnEventsEnabled to False, and before you set it to True again?
Which version of Inventor are you testing on?


Mike Deck
Software Developer
Autodesk, Inc.

Message 6 of 6
WCrihfield
in reply to: LarsBJepsen

Thanks a lot @MjDeck !

Here is a version of the code that is designed to 'toggle' this setting, and informs you of the before and after state of that setting, when you run it:

 

Sub ToggleEventTriggersEnabled()
    Dim oiLogic As Inventor.ApplicationAddIn
    Set oiLogic = ThisApplication.ApplicationAddIns.ItemById("{3BDD8D79-2179-4B11-8A5A-257B1C0263AC}")
    Dim oAuto As Object
    Set oAuto = oiLogic.Automation
    
    'capture its current state, before changing it
    Dim oEnabled As Boolean
    oEnabled = oAuto.RulesOnEventsEnabled
    
    'toggle the setting
    oAuto.RulesOnEventsEnabled = Not oAuto.RulesOnEventsEnabled
    
    'inform user of the changed status
    Call MsgBox("RulesOnEventsEnabled was set to:  " & oEnabled & vbCrLf & _
    "But it is now set to:  " & oAuto.RulesOnEventsEnabled, , "")
End Sub

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

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

Post to forums  

Autodesk Design & Make Report