【发布时间】:2021-03-14 06:10:34
【问题描述】:
我有一个我用 python 编写的工具,它在 Maya 脚本编辑器中运行时完全正常。但是,我希望能够从脚本目录中导入脚本。这应该很简单,我很震惊我在搜索网络时找不到解决方案。
我的脚本格式是这样的例子:
import maya.cmds as cmds
# GUI code with buttons, they call the functions below.
#
#
def function1():
#commands that do things
def function2():
#commands that do things
#List of functions continues
就像我说的,程序在脚本编辑器中运行时可以完美运行。将脚本保存到目录并使用此方法时:
import module
reload (module)
module.function()
GUI 加载正常,但是当按下 gui 按钮时,它说功能未定义。我不明白我错过了什么?如果加载了脚本,不应该定义函数吗?任何帮助将不胜感激,谢谢!
【问题讨论】:
-
你的真实密码是什么?
-
如前所述,您调用的是
function()而不是function1()或function2()
标签: python function import maya