Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Valued Contributor
Postmaster_G
Posts: 72
Registered: ‎12-20-2012
Message 1 of 8 (209 Views)

Need help with custom keyboard shortcut

209 Views, 7 Replies
06-13-2013 12:14 PM

Hello All,

 

I was wondering if anyone has had any luck with doing something like the following:

 

I want to make a keyboard shortcut that will turn on/off my osnap, polar, and otrack.

 

I would be fine with setting F3 to do this, or any other key really...

I like to be able to turn these off on the fly, but it is getting old having to press all three.

Why do I want this?  I guess it is just me being weird lol

Valued Mentor
alanjt_
Posts: 469
Registered: ‎08-25-2008
Message 2 of 8 (203 Views)

Re: Need help with custom keyboard shortcut

06-13-2013 01:10 PM in reply to: Postmaster_G

Assign this to a button:

 

(defun c:OSnapPolarOTrackToggle (/)
  (setvar 'AUTOSNAP (boole 6 (getvar 'AUTOSNAP) 24))
  (setvar 'OSMODE (boole 6 (getvar 'OSMODE) 16384))
  (princ)
)

 

Don't forget to prefix the command with an apostrophe so it can be executed transparently.

eg. 'OSnapPolarOTrackToggle

 

Now, keep in mind that this is a toggle for each variable, meaning that if polar is off and otrack is on, they will be toggle. 

*Expert Elite*
Kent1Cooper
Posts: 5,242
Registered: ‎09-13-2004
Message 3 of 8 (196 Views)

Re: Need help with custom keyboard shortcut

06-13-2013 01:43 PM in reply to: alanjt_

alanjt_ wrote:

....

Now, keep in mind that this is a toggle for each variable, meaning that if polar is off and otrack is on, they will be toggle. 


I was thinking the same thing.  Postmaster_G, would it be acceptable to have two commands, one to turn all three off together [whatever their current states may be, and whether or not they are the same as each other] and one to turn all three on?

Kent Cooper
Valued Mentor
alanjt_
Posts: 469
Registered: ‎08-25-2008
Message 4 of 8 (193 Views)

Re: Need help with custom keyboard shortcut

06-13-2013 01:56 PM in reply to: Kent1Cooper

Just in case:

 

(defun c:OSnapPolarOTrackToggle (/)
  (setvar 'AUTOSNAP (boole 6 (getvar 'AUTOSNAP) 24))
  (setvar 'OSMODE (boole 6 (getvar 'OSMODE) 16384))
  (princ)
)



(defun c:OSnapPolarOTrackOn (/)
  (setvar 'AUTOSNAP (boole 7 (getvar 'AUTOSNAP) 24))
  (setvar 'OSMODE (boole 2 (getvar 'OSMODE) 16384))
  (princ)
)



(defun c:OSnapPolarOTrackOff (/)
  (setvar 'AUTOSNAP (boole 2 (getvar 'AUTOSNAP) 24))
  (setvar 'OSMODE (boole 7 (getvar 'OSMODE) 16384))
  (princ)
)

 

Valued Contributor
Postmaster_G
Posts: 72
Registered: ‎12-20-2012
Message 5 of 8 (184 Views)

Re: Need help with custom keyboard shortcut

06-13-2013 02:15 PM in reply to: alanjt_

This is what I am looking for...

 

Now the problem is how do I add this to a button?

 

When you say button do you mean a key on my keyboard or a button on the cad screen?

 

I wouldn't mind just making my F3 be the button that toggles all of these.

 

Also, I think the version where nomatter what state each button is in, pushing F3 will either turn them all on or off.

 

I use the snaps a lot, but sometimes I like to be able to turn them all off so that I can wing something into the position I like without the snaps taking over.

 

Thank you

*Expert Elite*
scot-65
Posts: 2,125
Registered: ‎12-11-2003
Message 6 of 8 (173 Views)

Re: Need help with custom keyboard shortcut

06-13-2013 03:18 PM in reply to: Postmaster_G

Postmaster_G wrote:
I wouldn't mind just making my F3 be the button that toggles all of these.
 

Thank you


Have a look at the attached...

 

Once you have created your routine with the the command "c:XXX",

open the CUI and create the command in the bottom-left pane.

Drag and drop to the upper-left.

Highlight the command in the upper left, then do your thing in the lower-right pane.

 

Of course the routine you created must be in a support path defined folder.

 

???

 

Scot-65
Dyslexia is a permanent physical disability that cannot be seen.
Valued Contributor
Postmaster_G
Posts: 72
Registered: ‎12-20-2012
Message 7 of 8 (157 Views)

Re: Need help with custom keyboard shortcut

06-13-2013 06:09 PM in reply to: Postmaster_G

It seems to have worked. This is what I did.

 

First I took the first routine that you gave me and created a lsp

 

Next I made sure that my lsp folder was in my support file search path list

 

Then I did an appload of that lsp and added it to the startup suite in that dialog

 

I created a command that used the "OSNAPPOLAROTRACKTOGGLE" lsp command

 

I assigned a button image to it

 

Added that button to my single slim common use toolbar I had created for other common commands

 

Then the last step, which was tricky and Im not sure I did it correctly, was to create a copy of one of the keyboard shortcuts and edit it to be as i wanted it.  It gave me a warning that F3 was already used and that the priority of the list was bottom to top, but I couldn't move mine below the other F3 command on the list.

 

Either way it works!!!! And very nicely I might add, I love it!

 

Thank You!!!

 

Can we marked this as solved? Also, any comments on the "last step" I mentioned would be appreciated.

Valued Mentor
alanjt_
Posts: 469
Registered: ‎08-25-2008
Message 8 of 8 (146 Views)

Re: Need help with custom keyboard shortcut

06-13-2013 07:28 PM in reply to: Postmaster_G

You're very welcome. 

 

Another thing you can do, which will make loading routines, settings would be to use your own custom mnu/mnl. Easy to edit and work with. Put both files in a support path and MENULOAD the .mnu file. The rest is done for you from now on, and since it will be loaded after the core menu files, it gets priority.

 

I used your name as the menu group title, but you can change it however you like.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community