Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to assign "IDs" to global variables in a definition
    text
    copied!<p>Okay, I have a function which is basically a grouping up global variables that get updated by other definitions.</p> <p>What I want to do is be able to re-use this definition to add CTRLS to other layouts later on, but I run into the issue of the same variable names being used. Is there a way to add an attribute per variable? or an ID in python so that when the function is run a second time the variables have an identifer? </p> <pre><code>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 </code></pre> <p>Thank you so much! let me know if there's an easier or better way to achieve this, as I am definitely new to python. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload