好的,我有一个函数,它基本上是对由其他定义更新的全局变量进行分组。
我想要做的是以后能够重新使用此定义将 CTRLS 添加到其他布局,但我遇到了使用相同变量名的问题。有没有办法为每个变量添加一个属性?或python中的ID,以便在第二次运行函数时变量具有标识符?
def createDomeLightCTRLS(self,lightName,parentFrame):
lightShape = mel.listRelatives(lightName,shapes=True)
self.LD3 = mel.rowLayout(parent = parentFrame, numberOfColumns = 7, cat = [(1,'left',10)])
self.LD3_Spherical = mel.checkBox(str(lightName[0]) + '_spherical', label = 'Dome Spherical' , value = False )
mel.separator(hr = False, width = 10, height = 20, style = 'out')
self.LD3_SubDivs = mel.intSliderGrp(str(lightName[0]) + '_subdivs', label = 'SubDivs', min = 1, max = 100, field = True, value = 8, cw = [(1,45),(2,45),(3,75)])
mel.separator(hr = False, width = 10, height = 20, style = 'out')
self.LD3_rayDistCheck = mel.checkBox(str(lightName[0]) + '_rayDistCheck', label = 'Use Distance', value = False)
mel.separator(hr = False, width = 10, height = 20, style = 'out')
self.LD3_rayDist = mel.floatSliderGrp(str(lightName[0]) + '_rayDist', label = 'Distance', pre = 3, enable = False, field = True, value = False, min = 1, max = 1000000000, cw = [(1,45),(2,85),(3,85)] )
mel.setParent('..') # LD3 ( LD3 rowLayout) CLOSED
self.LD4 = mel.rowLayout(parent = parentFrame, numberOfColumns = 7, cat = [(1,'left',10)])
self.LD4_shadowBias = mel.floatFieldGrp( annotation = "Dome Light Light Shadow Bias: Distance of Shadows from Objects, (Default Should Be Enough)", label = 'Shadow Bias', numberOfFields = 1, precision = 3, value1 = .020, columnWidth = [(1,65),(2,75)], enable = True)
mel.separator(hr = False, width = 10, height = 20, style = 'out')
self.LD4_shadowColor = mel.colorSliderGrp( annotation = "Dome Light Shadow Color", label='Shadow Color', columnWidth = [( 1,75 ),( 2,75 ),( 3,115 )], rgb=( 0, 0, 0 ), enable = True)
mel.setParent('..') # LD4 ( LD4 rowLayout) CLOSED
self.LD5 = mel.rowLayout(parent = parentFrame, numberOfColumns = 5, columnAttach=[(1,'left',10)])
self.LD5_UseHDRI = mel.checkBox(str(lightName[0]) + '_useHDRI', annotation = "On/Off Use Dome Texture, Overrides Dome Light Color", label='Use HDRI', v=False)
mel.separator(hr = False, width = 10, height = 20, style = 'out')
self.LD5_TexAdaptive = mel.checkBox(str(lightName[0]) + '_texAdaptive', annotation = "On/Off Explict Texture Resoltion, Overrides input File Resolution", label='Texture Adaptive', enable = False, v=False)
mel.separator(hr = False, width = 10, height = 20, style = 'out')
self.LD5_TexRes = mel.floatSliderGrp(str(lightName[0]) + '_texRes', annotation = "Texture Resolution, if Texture Adaptive is Enabled",
columnAttach = [(2,'both',5)],
columnWidth = [(1,95),(2,75),(3,125)],
enable = False,
label='Texture Resolution',
field=True,
minValue=128,
maxValue=4096,
step = 128,
fieldMinValue=128,
fieldMaxValue=4096,
value=128
)
mel.setParent('..') # LD5 ( LD5 rowLayout) CLOSED
self.LD6 = mel.rowLayout(parent = parentFrame, numberOfColumns = 4, columnWidth=[(1,300)],columnAttach=[(1,'both',10)])
self.LD6_UseRGB = mel.checkBox(str(lightName[0]) + '_useRGB', annotation = "Use Color Slider to Determine Dome Light Color", label='Use RGB Dome Color', enable = False, v=False)
self.LD6_UseHDRIFile = mel.checkBox (str(lightName[0]) + '_useHDRIFile', annotation = "Use HDRI to Determine Dome Light Color", label='Use HDRI File', enable = False, v=False)
mel.setParent('..') # LD6 (LD6 rowLayout) CLOSED
self.LD7 = mel.rowLayout(parent = parentFrame,
numberOfColumns = 4,
columnWidth=[(1,300)],
columnAttach=[(1,'both',10),(2,'both',0),(3,'both',5),(4,'both',5)])
self.LD7_DomeColor = mel.colorSliderGrp(str(lightName[0]) + '_domeColor', annotation = "Dome Light Color",
label='Dome Color',
enable = False,
columnAttach = [(1,'both',0), (2,'both',5), (3,'left',0), (4,'both',0)],
columnWidth = [( 1,55 ),( 2,60 ),( 3,10 ),(4,0)],
rgb=( 1, 1, 1 )
)
self.LD7_HDRITextName = mel.text(str(lightName[0]) + '_HDRITextName', annotation = "Search for HDRI (jpg,HDR) to Use in Dome Light", label = 'HDRI File Name', enable = False)
self.LD7_HDRITextField = mel.textField(str(lightName[0]) + '_HDRITextField', text = '', width = 150, enable = False )
self.LD7_HDRIButton = mel.symbolButton (str(lightName[0]) + '_HDRISymbolButton', image='openScript.png',enable = False)
mel.setParent('..') # (LD7 (LD7 rowLayout) CLOSE
#options
self.LD8_optionFrame = mel.frameLayout(str(lightName[0]) + '_optionFrame',parent = parentFrame, label = 'Options', labelVisible = True, cl = True, cll = True )
self.LD8 = mel.rowLayout(parent = self.LD8_optionFrame,numberOfColumns = 9, cat = [(1,'left',10)])
self.LD8_invisible = mel.checkBox(str(lightName[0]) + '_invisible',label = 'Invisible', value = False)
mel.separator(hr = False, width = 10, height = 20, style = 'out')
self.LD8_irradianceMap = mel.checkBox(str(lightName[0]) + '_storeIrradiance',label = 'Store with Irradiance', value = False)
mel.separator(hr = False, width = 10, height = 20, style = 'out')
self.LD8_diffuse = mel.checkBox(str(lightName[0]) + '_diffuse',label = 'Diffuse', value = True)
mel.separator(hr = False, width = 10, height = 20, style = 'out')
self.LD8_specular = mel.checkBox(str(lightName[0]) + '_specular',label = 'Specular', value = True)
mel.separator(hr = False, width = 10, height = 20, style = 'out')
self.LD8_reflection = mel.checkBox(str(lightName[0]) + '_reflection',label = 'Reflection', value = True)
mel.setParent('..') # (LD8 (LD8 rowLayout) CLOSE
mel.setParent('..') # LR8_optionFrame (LR8_optionFrame frameLayout) CLOSED
太感谢了!让我知道是否有更简单或更好的方法来实现这一点,因为我绝对是 python 新手。