Inventor General Discussion

Inventor General Discussion

Reply
Employee
MjDeck
Posts: 959
Registered: ‎02-24-2009
Message 31 of 54 (324 Views)

Re: ilogic shortcut key

02-02-2012 01:20 PM in reply to: CadUser46

Sorry, you're right: all add-ins run in-process.  Here's more detail: when API code in Inventor (or in an add-in) is run from out-of-process, it will run in a separate thread (not the main Inventor UI thread).



Mike Deck
Software Developer
DLS - Mechanical Design
Autodesk, Inc.

Mentor
CadUser46
Posts: 226
Registered: ‎02-21-2011
Message 32 of 54 (320 Views)

Re: ilogic shortcut key

02-02-2012 01:44 PM in reply to: Ktelang
Thanks for making the time to answer Mike. That's very helpful.
Inventor 2010 Certified Professional
Currently using 2012
Active Contributor
nikhunter
Posts: 28
Registered: ‎05-05-2011
Message 33 of 54 (257 Views)

Re: ilogic shortcut key

11-30-2012 12:17 PM in reply to: Ktelang

Hi everyone.I have create a simple rule, and i copy the VBA code that Mike provided into a Button that i created in UseForm...Thats what happen when i run the programm is to press the button with my mouse and i have the implemetation of the rule.

But what I want in reality is to have the same process (I mean the  implemetation of the rule), but not with a button trigger rather a KeyPress.

I try to write this code in UserForm_KeyDown, but nothings happened.

 

If e.KeyCode = Keys.Enter Then

 

<<<<<< The rule in here>>>>>>

 

End if

 

I also tried the same into the Button_KeyDown, but i had the same result

 

Do you have any idea???

 

Employee
MjDeck
Posts: 959
Registered: ‎02-24-2009
Message 34 of 54 (246 Views)

Re: ilogic shortcut key

11-30-2012 02:06 PM in reply to: nikhunter

Nik,

 

 You can choose a key to run a VBA macro.  You don't need any code (such as UserForm_KeyDown) to do it.

 Are you using VBA only?  You're not using iLogic?  I'm a bit confused because you talk about a rule.  VBA programs are called macros.

 

Mike



Mike Deck
Software Developer
DLS - Mechanical Design
Autodesk, Inc.

Active Contributor
nikhunter
Posts: 28
Registered: ‎05-05-2011
Message 35 of 54 (242 Views)

Re: ilogic shortcut key

11-30-2012 02:24 PM in reply to: MjDeck

Hello Mike.Ok, listen step by step what i have done....

Firstly, i use iLogic to create a rule (Rule0) which modify o part of my construction...

Then, i go to VBA macro, where i use a button in which i copy your code...It's just o copy paste of your code as you have provided, with purpose to activate my rule(Rule0)...

Finally, i run the macro and the only thing I have to do, is to press the button with my mouse and it works...

 

 Substantially it's that you say.I must choose a key to run a VBA macro, but i dont know how...Which is the right code, that connect my keyboard to activate a Rule....

 

That's what i'am asking about, it to do the same thing, but not by pressing the button with my mouse, but pressing a Key by my Keyboard....Thanks for your time...

Employee
MjDeck
Posts: 959
Registered: ‎02-24-2009
Message 36 of 54 (238 Views)

Re: ilogic shortcut key

11-30-2012 02:28 PM in reply to: nikhunter

Nik,

 Could you post your iLogic rule?  If it is more than 3 lines, please put it in a txt file and attach it to the post.  Otherwise formatting will be lost.

 The reason I want to see the rule is to make sure that it can't be easily converted to VBA code.  It will be easier if you can do everything in VBA.



Mike Deck
Software Developer
DLS - Mechanical Design
Autodesk, Inc.

Active Contributor
nikhunter
Posts: 28
Registered: ‎05-05-2011
Message 37 of 54 (230 Views)

Re: ilogic shortcut key

11-30-2012 02:49 PM in reply to: Ktelang

Ok, imagine 2 lines that i have compounds with an angle construction...

I create a Rule, where i write this in there....

 

Parameter("d350") = 90
Constraint.IsActive("Angle:1") = True

Then i go to VBA and copy your code in a button..

When i run the programm, i press the button with my mouse, and two lines get corner 90 degrees between them...

In my progress, i have a lot of construction and a lot of transformations

 

 

That works i want to do, not by pressing the button with my mouse but by pressing a Key

Active Contributor
nikhunter
Posts: 28
Registered: ‎05-05-2011
Message 38 of 54 (224 Views)

I just want to know, how i can activate a Rule, by pressi...

11-30-2012 02:56 PM in reply to: Ktelang

I just want to know, how i can activate a Rule, by pressing a Key...

That only...:smileytongue:

 

You say that i can choose a key to activate a VBA macro....How i can do that???

 

You have given us a code, but i dont know how to use it to activate the rule by my keyboard

 

The only thing i have done, it's to copy that code in a button that i create in VBA editor, and activate the rule by pressing that with my mouse, when the programm running...

 

Hmmmmm.Maybe i dont use macro, but VBA editor???Its that a problem????

 

I realy sorry if i tyried you...

Employee
MjDeck
Posts: 959
Registered: ‎02-24-2009
Message 39 of 54 (206 Views)

Re: I just want to know, how i can activate a Rule, by pressi...

11-30-2012 03:12 PM in reply to: nikhunter

I'm converting your rule to VBA code.  However, it should also work the way you have it, as an iLogic rule.

To make it work from the keyboard:
Put the VBA Macro (Sub) into your ApplicationProject.  This is a global VBA project. Macros in it are available in all documents, and keyboard keys can be assigned to them.
In Inventor, use Tools -> Customize.  Select the Keyboard tab.  Sort by Category and look for the Macros category.  Your macro should be listed there. Then you can enter a shortcut key (or keys) in the first column.



Mike Deck
Software Developer
DLS - Mechanical Design
Autodesk, Inc.

Employee
MjDeck
Posts: 959
Registered: ‎02-24-2009
Message 40 of 54 (198 Views)

Re: I just want to know, how i can activate a Rule, by pressi...

11-30-2012 03:28 PM in reply to: MjDeck

Here's a VBA version of your iLogic rule.



Mike Deck
Software Developer
DLS - Mechanical Design
Autodesk, Inc.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.