SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.

Home / forum / Animation / Mel Scripts & Programming / Python script runs twice from Menu or Hotkey
Register FAQ Members List Calendar Mark Forums Read

New Thread
 
Thread Tools
Old 09-11-2008, 02:31 PM   #1
thurman
Registered User
 
Join Date: Nov 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Python script runs twice from Menu or Hotkey

I have written a python save increment script for Maya to make the saves compatible with our pipeline. The script itself runs fine, and if run from the script editor, only runs once. When I attach a hotkey and a menu list, the script will run twice, the first time you use it. But only when Maya first starts. After that, it will just run once.

Below are the files I altered to make the scripts run:

userSetup.mel (all on one line):

Quote:
menuItem -p "mainFileMenu" -l "EXC IncSave" -ia "" -c "python(\"import maya_incsave\"); python(\"maya_incsave.IncSave_Execute()\");";
userHotkeys.mel:

Quote:
//Maya Preference 8.50 (Release 1)
//
//

hotkey -keyShortcut "0" -releaseName ("HfAttrSelect_Menu_revert");
hotkey -keyShortcut "s" -ctl -name ("EXC_SaveIncNameCommand");
userNamedCommands.mel:

Quote:
//Maya Preference 8.50 (Release 1)
//
//

nameCommand
TAB-annotation "EXC_SaveIncNameCommand"
TAB-command ("EXC_SaveInc")
TABEXC_SaveIncNameCommand;
UserRunTimeCommands.mel:


Quote:
//Maya Preference 8.50 (Release 1)
//
//

runTimeCommand
TAB-annotation "EXC Save Increment"
TAB-category "File"
TAB-command ("python(\"import maya_incsave\");\r\npython(\"maya_incsave.IncSave_ Execute()\");")
TABEXC_SaveInc;
and finally, attached is the python script, maya_incsave.py: It is called .mel, because I cannot upload a .py file! Please rename it to .py.

Can anyone tell me why this is running twice when Maya 2008 first starts, and then running once every time after?

Thanks.
Attached Files
File Type: mel maya_incsave.mel (3.7 KB, 13 views)
__________________
Thurman Merman
thurman is offline   Reply With Quote
New Thread

« Previous Thread | Next Thread »

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

1 Month

$34

Month-to-month billing
$34/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
 
 

3 months

$87

Billing every 3 months
$29/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $5 per month or $15 in total compared to monthly billing with this package.

12 months

$288

Billing every 12 months
$24/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $10 per month or $120 in total compared to monthly billing with this package.

Your plan will automatically renew. You can cancel at any time via your PayPal account to avoid being charged again.

You can view the FAQ on our video plans here. You can contact us directly here. By clicking one of the buttons above, you agree to our Terms and Privacy Policy.