python快捷键设置_使用python在maya中设置热键

我正在研究为python中的一些自定义脚本生成新的热键,并希望使用pm.nameCommand和pm.hotkey命令。问题是,当我从脚本编辑器运行下面的代码时,它运行得很好,一切都很好,但是当我从脚本运行它时,我在尝试使用热键时会出错。在import pymel.core as pm

import toolTest

#clear existing hotkey

pm.hotkey(keyShortcut='a', ctrlModifier=True, name='')

#create named command for custom tool

#For some reason you need to run the python tool command through a python command in mel

pm.nameCommand( 'hotkeyTest', ann='Hotkey Test', c='python(\"toolTest.testing()\");')

#assign it a hotkey

pm.hotkey( keyShortcut='a', ctrlModifier=True, name='hotkeyTest')

这是工具测试.py上面引用的文件

^{pr2}$

如果您在脚本编辑器中运行以上所有内容,那么它应该可以正常工作。如果你把第一段代码放到一个文件中(热键测试.py)从脚本编辑器中运行,在尝试使用热键时会出现以下错误。在# Error: line 1: NameError: file line 1: name 'toolTest' is not defined #

有人知道如何使用python从外部脚本为自定义工具设置maya热键吗?在

谢谢!在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值