Hi. I downloaded your mel-file “setupRyanKeys” and it works great. However I don’t quite understand it so if you could find the time, please elaborate on it. It doesn’t seem to overwrite the default hotkeys, cause you can’t find your custom hotkeys in the hotkey editor. For instance, number “2″ is still assigned to “smothness 2″ as per default but instead of executing that command, “outlinerwindow” is executed instead. How does this work? Also how would anyone find out how to write all this stuff in code. Can’t get nada out of the script editor even with “echo all commands” turned on.
However it’s a smart and useful script I intend to customize to my own preferences. Really cool it doesn’t really overwrite any of mayas preferences to. For example I could bring this over when helping a friend and would want all of my custom prefs with me and then deleted when I’m done as he’d like his own. It seems this ensures leaving maya intact, not really messing it up even though I change plenty of settings in there for a moment. Is this the correct perception of how your script works?
Oh, my bad. I see now it really does overwrite the commands in the userHotkeys.mel-file, but now there’s even more questions =O
Why is it that, the name does not match the one found in the hotkey editor. If you’d make a shortcut inside maya and take a look in the userHotkeys.mel-file you get the name “OutlinerWindowNameCommand” whereas your script produce “NameComOutliner” and I can’t find this in the hotkey editor.
Yeah unfortunately it does overwrite the users current settings… A script could be made to “capture” the settings before they are modified so that you could revert back. But that is beyond the scope of this script. To see all the hotkeys, go to the hotkey editor and click the “List All…” button… all the commands made from the script will have NameCom attached as a prefix.
From the maya help docs on nameCommand:
This command creates a nameCommand object. Each nameCommand object can be connected to a hotkey. Thereafter, the nameCommand’s command string will be executed whenever the hotkey is pressed (or released, as specified by the user).
Still don’t fully grasp it. I don’t understand the use of the nameCommand. But, I can see the benefit of using it. As stated earlier, it doesn’t show up in the hotkey editor except when you “list all” so you can still have your prior hotkeys intact(right?), but overridden by your new ones. So then before exiting Maya you could press a button or if this script generates a ui with 2 buttons called “add hotkeys” and “delete hotkeys” you could get rid of your hotkeys next time you restart.
Now I just have to come up with a way to delete the hotkeys generated by the script, but that shouldn’t be so hard. “internalVar -userPrefDir ” to get to the prefs folder and then open hotKeys.mel and delete all code the script generates. This ought to be fairly easy just by copying the exact code from the hotKeys.mel-file and delete the matching string, right?
The nameCommand is a little bit of a strange creature and should prolly only be used for you own stuff. The main reason I generated the setupRyanKeys.mel script was so that whenever Maya corrupted my settings (which is all to often) I could quickly get all my settings back. Latah!
I wrote another reply earlier, but seems it never got sent or that it has to be approved by you before showing up.
Anyway I’ll make another try suppose it was never sent. I don’t blame you for being irritated by my persitent manner, so It’s okay for you to say so and I’ll stop bugging you. It’s just that finally I have someone to ask and debate about this so I’m kinda excited.
I read what you wrote in the link, but that can’t be the case, cause when exiting maya and open it up once again, your previously assigned hotkeys work like they should without having to execute the script again, so this means that your hotkeys have been added to the hotKeys.mel and by opening up and examine that file you’ll see that this is truly the case. To get rid of your custom settings, hotkeys etc. you’d need a procedure that deletes all generated code from the various files it is added to, like windowPrefs, hotKeys, userPrefs, pluginpPrefs. etc.
As i wrote four posts above the easiest way I can see to accomplish this immno(In my mel-noobish opinion) is to get the exact string generated by the script by opening the different Prefs-files and copy the code over to the mel-script, but this can be a daunting task so there has to be an easier way. Perhaps by looking for every line of codes with the nameCommand appended to them and delete that line, but this is beyond my capabilities.
I’d hoped you have some thoughts or ideas concerning the issue.
I mean, whenever you find the time. Appreciate it a bunch! Thank YOU!
Sorry, Didn’t think straight there. That won’t work cause as soon as you exit Maya it will restore your userHotkeys.mel when saving the preferences upon exiting. So they will still be there when restarting. You need this script to delete them after maya exits. Now, how do you do that, assuming you want the preferences to be saved automatically upon exiting if this option is checked by the user.
Understand what I’m trying to say?
PS. Do you know the command for checking on or off the interactive creation option under Create> nurbs or polygon primitives?
Yeah I just found another bug that was making it seem like the -default flag was doing the trick. But your right it’s not doing it… I was hoping to get an easy win there.. Ok so yeah its gonna be more complicated. Just to make sure we are on the same page. What you are looking for is a way to temporarily set hotkeys without overwriting the previous users keys permanently. Is that correct? If so it seems that the only really good way to do it is to make a script that re-directs the maya user temporarily so that it is using your prefs and not overwriting the others… Somewhere I have a script that does this. I will see if I can dig it up.
As far as the interactive create stuff (which is the first thing OI turn off ) those values are stored as an option var: For the polygon one use this:
toggleCreatePolyPrimitiveAsTool
If you are wondering what that does: Here is the .mel that command runs
int $val = (!`optionVar -q createPolyPrimitiveAsTool`);
optionVar -intValue createPolyPrimitiveAsTool $val;
Wow, thanks alot. Really descriptive. And greatly appreciated.
yeah, I can see I’m confusiong you throwing away ideas in all directions. I’ve come to realise that the script is perfect the way it is and that the code it generates store itself inside the respective prefs-files is awesome. Just what I’d prefer. So it’s stored if the user decide to keep it and need not be reloaded upon each restart.
However an option I’d like to be available is to also remove all or some of the settings from the different prefs-files without having to manually delete the prefs-files after exiting Maya. However if you manually edit the files when Maya is running and then exits Maya, the prefs are restored to the state at which they had when maya was running. So the edit needs to happen after exiting Maya, but how would someone script this? Maybe this won’t be needed if you wouldn’t have the option “save prefs on exit” turned on, so if maya doesn’t save the prefs on it’s own this ought to work.
But since I wan’t a user to be able to use this script in combination with his own settings and setup or if I simply wan’t to get in there and help another user and have maya set up the way I’d like I don’t want to change any of his settings just override them. then he could choose to keep them or delete them by triggering the UI I have in mind.
Thanks, I’m learning so much and to get all my questions answered and discussed is GREAT! THANKS for all your effort and time!! =) =)
Before ending this post I want to share this brief explanation of my current setup to discuss with you.
I use the maya env. for setting up my sripts folder using relative paths and I really like this setup. Earlier I’ve used the modules interface before I knew about the maya.env. I tried using the modules interface with maya.env but couldn’t get it to work properly so I scrapped it completely and only use the maya.env with my own”custom config folder”. Inside this config folder I have three folders called “Mel_scripts” “Python_Scripts” and “shelves” and then many subdirectories in the mel-folder all named conveniently to what they contain, such as “modeling_scripts”, “texturing_scripts” etc. This way I only need to manage 2 files, the maya env and the “custom config folder”. I’m very happy with this, but I’m interested in what your setup looks like and how you manage your scripts, shelves and such.
So sorry for the long post. Thanks for bear with me.
Just tried the whole settings-script putting in this code you posted. toggleCreatePolyPrimitiveAsTool
Certainly not a major issue, but when pressing the shelficon repeatedly the script toggles as it’s supposed to, but what if I’d like to always set it to “uncheck interactive creation” no matter what state it’s on. can this be queried? Perhaps using a simple if statement? not a big issue, I’m just interested. As always whenever you find the time. God, this is so great!! =)THANKS
Ahh that’s because the UI has not been made yet… Those lines are only necessary to have the UI display the proper setting… But it will totally work with just setting the option var.
I don’t mean to bug you, but when you find the time, please respond to my post #11 above.
Nebs :
Ahh that’s because the UI has not been made yet… Those lines are only necessary to have the UI display the proper setting… But it will totally work with just setting the option var.
Ya sorry I got distracted with a bunch of stuff and have not posted my reply.
What I mean by “the UI has not been made yet” is that the menuItem does not exist yet to Maya. So when you call on it to change it’s state to “unchecked” Maya throws an error because it cannot find the menuItem. But like I said if you are not super worried about the menuItem showing the correct state, just using the option vars will be fine.
First off… If Maya is saving those prefs out after every session there will be no way to “script” in a way to overwrite prefs and have them stick. You would need ot do that with some external code. If turning off the save prefs on exit does the trick then it may be possible. Tho I have never tried it.
So the way I have handled the multiple users issue was with the windows environment variables… Meaning that I created a script that re-pointed the environment variables to use that particular persons setup.
The environment variables I use are:
MAYA_APP_DIR which basically points maya at a different startup directory that has all the user prefs in it.
MAYA_SCRIPT_PATH which tells Maya where to look for my scripts.
XBMLANGPATH which tells maya where to look for custom icons.
Because I want all my .mel tools to be shared across all the users on the project we use a common directory for scripts and icons that are then checked into perforce. Also all the users pref files checked in so that anybody can have access to their settings on any machine.
The shitty thing about switching prefs this way is that to get Maya to recognize a new MAYA_APP_DIR, you have to restart Maya. But I think that’s a small price to pay to have the system be simple and elegant. Also because you are never actually digging around in the files themselves it’s less prone to error. And because the users check their files into perforce they have a backup waiting in case something wacky happens.
Hi. I downloaded your mel-file “setupRyanKeys” and it works great. However I don’t quite understand it so if you could find the time, please elaborate on it. It doesn’t seem to overwrite the default hotkeys, cause you can’t find your custom hotkeys in the hotkey editor. For instance, number “2″ is still assigned to “smothness 2″ as per default but instead of executing that command, “outlinerwindow” is executed instead. How does this work? Also how would anyone find out how to write all this stuff in code. Can’t get nada out of the script editor even with “echo all commands” turned on.
However it’s a smart and useful script I intend to customize to my own preferences. Really cool it doesn’t really overwrite any of mayas preferences to. For example I could bring this over when helping a friend and would want all of my custom prefs with me and then deleted when I’m done as he’d like his own. It seems this ensures leaving maya intact, not really messing it up even though I change plenty of settings in there for a moment. Is this the correct perception of how your script works?
Oh, my bad. I see now it really does overwrite the commands in the userHotkeys.mel-file, but now there’s even more questions =O
Why is it that, the name does not match the one found in the hotkey editor. If you’d make a shortcut inside maya and take a look in the userHotkeys.mel-file you get the name “OutlinerWindowNameCommand” whereas your script produce “NameComOutliner” and I can’t find this in the hotkey editor.
Yeah unfortunately it does overwrite the users current settings… A script could be made to “capture” the settings before they are modified so that you could revert back. But that is beyond the scope of this script. To see all the hotkeys, go to the hotkey editor and click the “List All…” button… all the commands made from the script will have NameCom attached as a prefix.
From the maya help docs on nameCommand:
This command creates a nameCommand object. Each nameCommand object can be connected to a hotkey. Thereafter, the nameCommand’s command string will be executed whenever the hotkey is pressed (or released, as specified by the user).
Hope this helps!
ryan
Still don’t fully grasp it. I don’t understand the use of the nameCommand. But, I can see the benefit of using it. As stated earlier, it doesn’t show up in the hotkey editor except when you “list all” so you can still have your prior hotkeys intact(right?), but overridden by your new ones. So then before exiting Maya you could press a button or if this script generates a ui with 2 buttons called “add hotkeys” and “delete hotkeys” you could get rid of your hotkeys next time you restart.
Now I just have to come up with a way to delete the hotkeys generated by the script, but that shouldn’t be so hard. “internalVar -userPrefDir ” to get to the prefs folder and then open hotKeys.mel and delete all code the script generates. This ought to be fairly easy just by copying the exact code from the hotKeys.mel-file and delete the matching string, right?
Something like that should work… Let me fiddle around a bit and see what I find…
Sure, take your time and thanks alot for the answers you’ve provided.
Really appreciate it. Thanks man and keep up the good job!
Please see this post http://www.ryane.com/?p=600
The nameCommand is a little bit of a strange creature and should prolly only be used for you own stuff. The main reason I generated the setupRyanKeys.mel script was so that whenever Maya corrupted my settings (which is all to often) I could quickly get all my settings back. Latah!
I wrote another reply earlier, but seems it never got sent or that it has to be approved by you before showing up.
Anyway I’ll make another try suppose it was never sent. I don’t blame you for being irritated by my persitent manner, so It’s okay for you to say so and I’ll stop bugging you. It’s just that finally I have someone to ask and debate about this so I’m kinda excited.
I read what you wrote in the link, but that can’t be the case, cause when exiting maya and open it up once again, your previously assigned hotkeys work like they should without having to execute the script again, so this means that your hotkeys have been added to the hotKeys.mel and by opening up and examine that file you’ll see that this is truly the case. To get rid of your custom settings, hotkeys etc. you’d need a procedure that deletes all generated code from the various files it is added to, like windowPrefs, hotKeys, userPrefs, pluginpPrefs. etc.
As i wrote four posts above the easiest way I can see to accomplish this immno(In my mel-noobish opinion) is to get the exact string generated by the script by opening the different Prefs-files and copy the code over to the mel-script, but this can be a daunting task so there has to be an easier way. Perhaps by looking for every line of codes with the nameCommand appended to them and delete that line, but this is beyond my capabilities.
I’d hoped you have some thoughts or ideas concerning the issue.
I mean, whenever you find the time. Appreciate it a bunch! Thank YOU!
Sorry, Didn’t think straight there. That won’t work cause as soon as you exit Maya it will restore your userHotkeys.mel when saving the preferences upon exiting. So they will still be there when restarting. You need this script to delete them after maya exits. Now, how do you do that, assuming you want the preferences to be saved automatically upon exiting if this option is checked by the user.
Understand what I’m trying to say?
PS. Do you know the command for checking on or off the interactive creation option under Create> nurbs or polygon primitives?
Uhh Im not irritated at all!
Yeah I just found another bug that was making it seem like the -default flag was doing the trick. But your right it’s not doing it… I was hoping to get an easy win there..
Ok so yeah its gonna be more complicated. Just to make sure we are on the same page. What you are looking for is a way to temporarily set hotkeys without overwriting the previous users keys permanently. Is that correct? If so it seems that the only really good way to do it is to make a script that re-directs the maya user temporarily so that it is using your prefs and not overwriting the others… Somewhere I have a script that does this. I will see if I can dig it up.
As far as the interactive create stuff (which is the first thing OI turn off
) those values are stored as an option var: For the polygon one use this:
toggleCreatePolyPrimitiveAsTool
If you are wondering what that does: Here is the .mel that command runs
int $val = (!`optionVar -q createPolyPrimitiveAsTool`);
optionVar -intValue createPolyPrimitiveAsTool $val;
if ( `menuItem -ex toggleCreatePolyPrimitivesAsToolItem` )
menuItem -e -cb $val toggleCreatePolyPrimitivesAsToolItem;
if ( `menuItem -ex togglePolyPrimitivesAsToolItemExitOnComplete` )
menuItem -e -enable $val togglePolyPrimitivesAsToolItemExitOnComplete;
The Nurbs one is this:
toggleCreateNurbsPrimitiveAsTool;
Wow, thanks alot. Really descriptive. And greatly appreciated.
yeah, I can see I’m confusiong you throwing away ideas in all directions. I’ve come to realise that the script is perfect the way it is and that the code it generates store itself inside the respective prefs-files is awesome. Just what I’d prefer. So it’s stored if the user decide to keep it and need not be reloaded upon each restart.
However an option I’d like to be available is to also remove all or some of the settings from the different prefs-files without having to manually delete the prefs-files after exiting Maya. However if you manually edit the files when Maya is running and then exits Maya, the prefs are restored to the state at which they had when maya was running. So the edit needs to happen after exiting Maya, but how would someone script this? Maybe this won’t be needed if you wouldn’t have the option “save prefs on exit” turned on, so if maya doesn’t save the prefs on it’s own this ought to work.
But since I wan’t a user to be able to use this script in combination with his own settings and setup or if I simply wan’t to get in there and help another user and have maya set up the way I’d like I don’t want to change any of his settings just override them. then he could choose to keep them or delete them by triggering the UI I have in mind.
Thanks, I’m learning so much and to get all my questions answered and discussed is GREAT! THANKS for all your effort and time!! =) =)
Before ending this post I want to share this brief explanation of my current setup to discuss with you.
I use the maya env. for setting up my sripts folder using relative paths and I really like this setup. Earlier I’ve used the modules interface before I knew about the maya.env. I tried using the modules interface with maya.env but couldn’t get it to work properly so I scrapped it completely and only use the maya.env with my own”custom config folder”. Inside this config folder I have three folders called “Mel_scripts” “Python_Scripts” and “shelves” and then many subdirectories in the mel-folder all named conveniently to what they contain, such as “modeling_scripts”, “texturing_scripts” etc. This way I only need to manage 2 files, the maya env and the “custom config folder”. I’m very happy with this, but I’m interested in what your setup looks like and how you manage your scripts, shelves and such.
So sorry for the long post. Thanks for bear with me.
Just tried the whole settings-script putting in this code you posted. toggleCreatePolyPrimitiveAsTool
Certainly not a major issue, but when pressing the shelficon repeatedly the script toggles as it’s supposed to, but what if I’d like to always set it to “uncheck interactive creation” no matter what state it’s on. can this be queried? Perhaps using a simple if statement? not a big issue, I’m just interested. As always whenever you find the time. God, this is so great!! =)THANKS
I’m in the process of responding to your other comment. But in the mean time I think this is what your are looking for:
optionVar -intValue createPolyPrimitiveAsTool 0;
menuItem -e -cb 0 toggleCreatePolyPrimitivesAsToolItem;
optionVar -intValue createNurbsPrimitiveAsTool 0;
menuItem -e -cb 0 toggleCreateNurbsPrimitivesAsToolItem;
That will force both the Nurbs and Poly “interactive create options” to off.
Damn, thanks for superfast replies!
However adding your new code this occured:
// Error: Object not found: toggleCreatePolyPrimitivesAsToolItem
erasing those lines and only keeping:
optionVar -intValue createPolyPrimitiveAsTool 0;
optionVar -intValue createNurbsPrimitiveAsTool 0;
made it work without headaches, but why?
Ahh that’s because the UI has not been made yet… Those lines are only necessary to have the UI display the proper setting… But it will totally work with just setting the option var.
I don’t mean to bug you, but when you find the time, please respond to my post #11 above.
What do you mean “the UI has not been made yet”?
Ya sorry I got distracted with a bunch of stuff and have not posted my reply.
What I mean by “the UI has not been made yet” is that the menuItem does not exist yet to Maya. So when you call on it to change it’s state to “unchecked” Maya throws an error because it cannot find the menuItem. But like I said if you are not super worried about the menuItem showing the correct state, just using the option vars will be fine.
REPLY TO #11
First off… If Maya is saving those prefs out after every session there will be no way to “script” in a way to overwrite prefs and have them stick. You would need ot do that with some external code. If turning off the save prefs on exit does the trick then it may be possible. Tho I have never tried it.
So the way I have handled the multiple users issue was with the windows environment variables… Meaning that I created a script that re-pointed the environment variables to use that particular persons setup.
The environment variables I use are:
MAYA_APP_DIR which basically points maya at a different startup directory that has all the user prefs in it.
MAYA_SCRIPT_PATH which tells Maya where to look for my scripts.
XBMLANGPATH which tells maya where to look for custom icons.
Because I want all my .mel tools to be shared across all the users on the project we use a common directory for scripts and icons that are then checked into perforce. Also all the users pref files checked in so that anybody can have access to their settings on any machine.
The shitty thing about switching prefs this way is that to get Maya to recognize a new MAYA_APP_DIR, you have to restart Maya. But I think that’s a small price to pay to have the system be simple and elegant. Also because you are never actually digging around in the files themselves it’s less prone to error. And because the users check their files into perforce they have a backup waiting in case something wacky happens.
Thanks. yeah, that is kinda cool. Have to do some research on perforce, not at all familiar with it.