# Error: RuntimeError: file <maya console> line 13: Object '<function save_snapshots at 0x000001757D101EB8>' not found. #
我正在编写一个脚本来创建uv快照。目前,我坚持使用"save_snapshots“来获取"uv_snap_res”应该给出的整数。
在我的UI中,“保存”按钮使用的是partial,我不完全理解它是如何工作的。如果我按照命令的顺序将save_snapshots移到'texSizeControl‘后面,它就不会运行(我想?)。
我希望能有一点帮助来解释在使用函数时传递参数是如何工作的,以及当涉及到“部分”事情时操作的顺序……我走到这一步的唯一原因是因为这个网站和在其他领域寻找例子。整个单选按钮的事情是一个完全的挑战,我不知道我是否完全正确地工作:/对不起。
如果您有任何帮助或建议,我将洗耳恭听!
## UV SNAPSHOTS
## PYTHON
import maya.cmds as mc
def get_snapshot_res(label, *args):
uv_snap_res = label
def save_snapshots(get_snapshot_res, uv_snap_res, *args):
get_snapshot_res(uv_snap_res)
print get_snapshot_res
def passValue(texSizeControl, *args):
radioCol = mc.radioCollection(texSizeControl, query=True, sl=True)
getSelectRadioVal = mc.radioButton(radioCol, query=True, label=True)
get_snapshot_res(getSelectRadioVal)
def save_snapshots_ui(*args):
myWindow = 'Create UV Snapshots'
if mc.window(myWindow, exists=True):
mc.deleteUI(myWindow)
mc.window(myWindow, title = myWindow)
mc.columnLayout(adjustableColumn=True)
mc.text(label='Choose your resolution for UV Snapshots', font='obliqueLabelFont')
texSizeControl = mc.radioCollection()
saveRadio1k = mc.radioButton(label='1024')
saveRadio2k = mc.radioButton(label='2048')
saveRadio4k = mc.radioButton(label='4096')
saveRadio8k = mc.radioButton(label='8192')
texSizeControl = mc.radioCollection(texSizeControl, edit=True, select=saveRadio2k )
mc.button(label='save', command= partial(passValue, save_snapshots, texSizeControl))
mc.setParent( '..' )
mc.showWindow()
save_snapshots_ui()发布于 2019-05-27 12:18:19
试着在不需要的地方删除*args,你应该这样写你的脚本:
get ui UVRANGEgather所有这一切都整合到一个cmd中以启动快照220 HF221>====================================
import maya.cmds as mc
# GATHER
def ui_save_snapshots(texSizeControl, *args):
# *args is only used when the def is inside ui
# here it is gathering information to launch the maya command
RATIO = get_snapshot_res(texSizeControl)
path = 'something to get the path'
save_snapshots(path, RATIO)
# GET RES
def ui_get_snapshot_res(label):
radioCol = mc.radioCollection(texSizeControl, query=True, sl=True)
RATIO = mc.radioButton(radioCol, query=True, label=True)
return RATIO
SNAPSHOT
def save_snapshots(path, resolution, uvRange=[0,1,0,1]):
# this def is a without any ui
# path = "/marza/proj/fuji2019/work/Prop/trap/sim/everyone/simRig/images/outUV.jpg"
uMin, uMax, vMin, vMax = uvRange
cmds.uvSnapshot(o=True,ff='jpg', xr=resolution, yr=4096, aa=True, r=255, g=255, b=255, n=path, uMin=uMin, uMax=uMax, vMin=vMin, vMax=vMax)
def save_snapshots_ui():
myWindow = 'Create UV Snapshots'
if mc.window(myWindow, exists=True):
mc.deleteUI(myWindow)
mc.window(myWindow, title = myWindow)
mc.columnLayout(adjustableColumn=True)
mc.text(label='Choose your resolution for UV Snapshots', font='obliqueLabelFont')
texSizeControl = mc.radioCollection()
saveRadio1k = mc.radioButton(label='1024')
saveRadio2k = mc.radioButton(label='2048')
saveRadio4k = mc.radioButton(label='4096')
saveRadio8k = mc.radioButton(label='8192')
texSizeControl = mc.radioCollection(texSizeControl, edit=True, select=saveRadio2k )
# send textSiZeControl to passValue
mc.button(label='save', command= partial(passValue, texSizeControl))
mc.setParent( '..' )
mc.showWindow()
save_snapshots_ui()https://stackoverflow.com/questions/56315699
复制相似问题