Hello,
Is there any command/option to add a keyboard shortcut for ilogic rule ?
Thanks
Solved! Go to Solution.
Solved by MjDeck. Go to Solution.
I know about event triggers but want to control
my rules by using keyboard shortcut
any suggestion
There's no way to create a keyboard shortcut directly for an iLogic rule. But you could create a VBA macro that would launch an iLogic rule, and add a keyboard shortcut for the macro.
Here's VBA code to run an iLogic rule:
Sub RuniLogicRule() Dim iLogicAuto As Object Set iLogicAuto = GetiLogicAddin(ThisApplication) If (iLogicAuto Is Nothing) Then Exit Sub Dim doc As Document Set doc = ThisApplication.ActiveDocument Dim ruleName As String ruleName = "Rule0" Dim rule As Object Set rule = iLogicAuto.GetRule(doc, "Rule0") If (rule Is Nothing) Then Call MsgBox("No rule named " & ruleName & " was found in the document.") Exit Sub End If Dim i As Integer i = iLogicAuto.RunRuleDirect(rule) End Sub Function GetiLogicAddin(oApplication As Inventor.Application) As Object Set addIns = oApplication.ApplicationAddIns Dim addIn As ApplicationAddIn On Error GoTo NotFound Set addIn = oApplication.ApplicationAddIns.ItemById("{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}") If (addIn Is Nothing) Then Exit Function addIn.Activate Set GetiLogicAddin = addIn.Automation Exit Function NotFound: End Function
Thanks everybody,
I was off for the meeting. Got all your discussion details
right now. Thanks for the macro.
Okay, so I've set this up and have it working. . . sort of.
I have an iLogic Rule that works as expected when run manually or with a trigger.
The last line of the rule is: iLogicVB.UpdateWhenDone = True
I've set this macro up (using the code Mike provided)to call the macro when I press K on the keyboard.
I had to remove the line for the trigger in the rule, otherwise it called the rule 2x in a row.
But what I get at this point is the rule is triggered, my listbox appears, I select a value from the list and click OK, and...
Inventor is minimized, not sure why?
And the rule didn't have any effect, not sure why?
any thoughts?
'trigger=iTrigger0 Foam_Thickness = InputListBox("Select Foam To Use", MultiValue.List("Foam_Thickness"), _ Foam_Thickness, Title := "Foam Thickness List", ListName := "Stock Foam Thicknesses") Foam_THK=Foam_Thickness * "-1" if Foam_Thickness = "1/4 in. thick" then Foam_PN = "100607-02" Foam_Description = "foam, LD-45, Black, 39.4''x 78.7'' x 1/4'' thick" iProperties.Value("Project", "Stock Number") = Foam_PN iProperties.Value("Custom", "Stock Number Description") = Foam_Description elseif Foam_Thickness = "1/2 in. thick" then Foam_PN = "100607-05" Foam_Description = "foam, LD-45, Black, 39.4''x 78.7'' x 1/2'' thick" iProperties.Value("Project", "Stock Number") = Foam_PN iProperties.Value("Custom", "Stock Number Description") = Foam_Description End If iLogicVB.UpdateWhenDone = True
What version of Inventor are you running?
I tried a keyboard shortcut running a similar rule with an InputListBox, and it worked OK.
Does your rule run with no error when you right-click on it and choose Run Rule?
What does this line do?
Foam_THK = Foam_Thickness * "-1"
Please try taking out that line and see if it makes any difference.
Can you post your model, or a simplified version that shows the same problem?
Thanks Mike.
I'm running 2010.
This does work when I right-click on it and choose Run Rule.
also this line:
Foam_THK=Foam_Thickness * "-1"
is setting a user work plane offset value using the listbox input value.
Here is the part file, it's a modification of a Base solid, which may seem an odd way to startout, but this is template of a known size and the idea is not to have parameters a user can edit.
I should point out too that I've modified the iLogic code a bit since originally posting.
I tried it in Inventor 2010 and I can't reproduce the problem.
Do you have the latest version of iLogic for Inventor 2010? There are two versions. Please try the About iLogic Extension button on the iLogic Utilities dialog. If it shows version 2.5.165.0, I would recommend upgrading to 2.5.172.0. You can get this at
http://subscription.autodesk.com/sp/servlet/download/item?siteID=11564774&id=12940747
Although the page says Release Date: 2009-03-24 at the top, if you open the Readme.htm file it gives a date in Aug 2009. This will install over your current version of iLogic. Exit Inventor before installing it.
If you already have that version, or upgrading doesn't fix it:
Does running the macro and rule always minimize the Inventor window?
Maybe try a different shortcut key.
As a test, please try using the same macro to run a different rule (with the same name) in another part.
I could modify the macro so it would run the first rule in a model. That would make it more general.
thanks Mike.
It looks like I have the right version:
I'll post back later today if I come up with more information from your suggested troubleshooting steps. Thanks again for your time and input.
Bmiller63,
Are you running 64-bit?
I was testing on a 32-bit system. I tried it on 64-bit. I don't get the exact behavior that you're describing, but it doesn't work very well. This seems to be due to the way VBA works on a 64-bit system.
Sorry, I can't recommend using VBA to run a rule with a shortcut key. It should work for simple rules, but not for rules that show dialogs on 64-bit systems.
If I could, I would go back and add this caveat to my previous posts.
ahhhhhhhh!
I am running 64 bit XP.
That never even occured to me.
Thanks for following up.
I'll look into going another route.
Hello everybody.I'am from Greece and my English are not so good, so forgive me...
My problem is following.I have create a finger to autocad,I have done the import to inventor, I've give all the constraints and now i want to move it when i push a keyboard.For example i have the finger in the first position and when i put the key "A" i want my finger go to the second position.I attach two foto to help you.Please help me...
I forgot to explane you the mechanism that do the first part of finger to move.I attach another foto to see that...
I have do the angle constraint at two red surfaces and first of all i want to make a rule, that change this angle at any degree i want.And after that i want to connect the rule with a macro code, that when i push the button "A" to activate this rule and my finger go from the first potision, to second...
In this case i want to learn how this order draw up...(Constraint.IsActive.....)
"angle" is the name of parameter an "up","down" are two of the multi value.When i choose the "up" i want my finger go to the first position and when i choose "down" i want go to the second.This will be happen if i can affect the angle constraint between two red surfaces..This code of course is just an example and i know that the is absolutely wrong.Please help me i am novice...
Ok i think i find the solution about the rule.I get the right code, and i can affect the angle at any degree i want.Now my problem is to connect the Keyboard with the rule.The same problem with Ktelang, but i dont understand how it solve...I want to push the button "A" for example and execute a specific rule...HELP
Please someone to help me.As I wrote earlier, i want to "connect" my Keyboard with a rule.Actually i want to push a button, like "A", and executeς an order.
The idea is like the code that give us the MjDeck.I create a pushButton,i wrote the code in there, and when i click on it it's work, the rule is execute.Now i want to do the same thing, but this time by pushing a key of my keyboard...please be need.I want it for my graduate...
Mike. I cant get this to run. I removed the ? in the ItemById but i keep seeing the msg at
If (rule Is Nothing) Then
Call MsgBox("No rule named " & ruleName & " was found in the document.")
Any ideas?
2012 Pro.Win7 64.