我有这个脚本,我想根据用户选择复制动画并粘贴回偏移量。对于偏移量,我想使用用户的输入值,但我在字符串中出现错误以浮动,有人可以帮我解决这个问题吗? 提前致谢
import maya.cmds as cmds
# Get the first selection
sel = cmds.ls(sl=True)[0]
# Get the animation curves from the first selection
animCurves = cmds.listConnections(sel, type='animCurve')
# Get the time range of the animation curves
startTime = cmds.findKeyframe(animCurves[0], which='first')
endTime = cmds.findKeyframe(animCurves[0], which='last')
# Get the offset value from user input
offset = float(cmds.promptDialog(title='Offset', message='Enter offset value:', button=['OK', 'Cancel'], defaultButton='OK', cancelButton='Cancel', dismissString='Cancel'))
# Loop through all other selections and paste animation with offset
for obj in cmds.ls(sl=True)[1:]:
cmds.copyKey(sel, time=(startTime, endTime))
cmds.pasteKey(obj, time=(startTime + offset, endTime + offset))