这是我的脚本:
import maya.cmds as cmds
def changeLightIntensity(percentage=1.0):
"""
Changes the intensity of each light the scene by percentage.
Parameters:
percentage - Percentage to change each light's intensity. Default value is 1.
Returns:
Nothing.
"""
#The is command is the list command. It is used to list various nodes
#in the current scene. You can also use it to list selected nodes.
lightInScene = cmds.ls(type='light')
#If there are no lights in the scene, there is no point running this script
if not lightInScene:
raise RunTimeError, 'There are no lights in the scene!'
#Loop through each light
for light in lightInScene:
#The getAttr command is used to get attribute values of a node
currentIntensity = cmds.getAttr('%s.intensity' % light)
#Calculate a new intensity
newIntensity = currentIntensity * percentage
#Change the lights intensity to the new intensity
cmds.setAttr('%s.intensity' % light, newIntensity)
#Report to the user what we just did
print 'Changed the intensity of light %s from %.3f to %.3f' % (light, currentIntensity, newIntensity)
import samples.lightIntensity as lightIntensity
lightIntensity.changelightIntensity(1.2)
我的错误是:
ImportError:没有名为 samples.lightIntensity 的模块
有什么问题?我可以这样做吗?解决方案是什么?
谢谢!