def setOvrColor(color=None, objs=None): """Sets shape override color on selected objects. Args: - color: RGB (float, float, float). Default=None, color picker window opens.""" if not objs: objs = pmc.ls(sl=True) if not color: #main = qtu.getMayaMainWindow() #colorWin = QtWidgets.QColorDialog(main) #color = colorWin.getColor() pmc.colorEditor() color = pmc.colorEditor(q=True, rgb=True) for s in objs: try: shapes = s.getShapes() except AttributeError: pmc.warning("Object {0} has no shapes.".format(s)) continue for sh in shapes: try: sh.overrideEnabled.set(True) sh.overrideRGBColors.set(True) #sh.overrideColorRGB.set(color.getRgbF()) sh.overrideColorRGB.set(color) except RuntimeError: pmc.warning( "{0} skipped due to existing connection.".format(sh)) continue
def setColor(self, button, leafColor): currentColor = self.getRgb(leafColor) color = pm.colorEditor(rgbValue=currentColor) r, g, b, a = [float(c) for c in color.split()] color = (r, g, b) leafColor.setRgb(r*255,g*255,b*255) self.setButtonColor(button, color)
def setShadowColor(self): shadowColor = self.light.shadowColor.get() color = pm.colorEditor(rgbValue=shadowColor) r, g, b, a = [float(c) for c in color.split()] color = (r, g, b) self.light.shadowColor.set(color) self.setShadowButtonColor(color)
def colorSelectedCustom(self): pos = QtGui.QCursor.pos() colors = pm.colorEditor(position=[pos.x(), pos.y()]) values = str(colors).split(' ') r, g, b, result = [x for x in values if x != ''] if result: rgb = [float(x) for x in [r, g, b]] self.colorSelected(rgb)
def defineSurfaceColor(self): val = colorEditor(rgb=self.customColor) if val[-1] == '1': # Control has strange returns, see maya docs self.customColor = [float(f) for f in val.split()][:-1] self.surfacePalette.setRgbValue([0] + self.customColor) palettePort(self.surfacePalette, e=True, redraw=True) return True return False
def setColor(self): lightColor = self.light.color.get() color = pm.colorEditor(rgbValue=lightColor) r, g, b, a = [float(c) for c in color.split()] color = (r, g, b) self.light.color.set(color) self.setButtonColor(color)
def setColor(self): shadowColor = self.light.color.get() color = pm.colorEditor(rgbValue=shadowColor) r, g, b, a = [float(c) for c in color.split()] color = (r, g, b) # self.light.color.set(color) pm.setAttr(self.light.name() + '.color', color) self.setButtonColor(color)
def setAiShadowColor(self): my_str = self.light.name() + ".aiShadowColor" shadowColor = pm.getAttr(my_str) # shadowColor = self.light.shadowColor.get() color = pm.colorEditor(rgbValue=shadowColor) r, g, b, a = [float(c) for c in color.split()] color = (r, g, b) pm.setAttr(my_str, color) self.setAiShadowButtonColor(color)
def setColor(self): lightColor = self.light.color.get() # maya color editor give us rbc values color = pm.colorEditor(rgbValue=lightColor) # maya give us a string, we split the string a convert to float r, g, b, a = [float(c) for c in color.split()] color = (r, g, b) self.light.color.set(color) self.setButtonColor(color)
def setColor(self): lightColor = self.light.color.get() color = pm.colorEditor(rgbValue=lightColor) # it gives back a string instead of a list of numbers. # split the string, then convert it to floats r, g, b, a = [float(c) for c in color.split()] color = (r, g, b) self.light.color.set(color) self.setButtonColor(color)
def setColor(self): lightColor = self.light.color.get() color = pm.colorEditor(rgbValue=lightColor) r, g, b, a = [float(c) for c in color.split() ] # split the string in every space color = (r, g, b) print(color) self.light.color.set(color) self.setButtonColor(color)
def setAiShadowColor(self): my_str = self.lights_list[0] + ".aiShadowColor" shadowColor = pm.getAttr(my_str) # shadowColor = self.light.shadowColor.get() color = pm.colorEditor(rgbValue=shadowColor) r, g, b, a = [float(c) for c in color.split()] color = (r, g, b) for i in self.lights_list: light_name = i pm.select(i) # light = pm.selected()[0].shadowColor.set(color) pm.setAttr(light_name + ".aiShadowColor", color) self.setAiShadowButtonColor(color)
def setColorLight(self): lightColor = self.light.color.get() # load color editor UI from Maya color = pm.colorEditor(rgbValue=lightColor) # Convert color value above to rgba r, g, b, a = [float(c) for c in color.split()] color = (r, g, b) self.light.color.set(color) self.setButtonColor(color)
def setColor(self): # First of all we get the color values from the light. This will be a list of 3 floats lightColor = self.light.color.get() # Then we provide this to the maya's color editor which gives us back the color the user specified color = pm.colorEditor(rgbValue=lightColor) # Annoyingly, it gives us back a string instead of a list of numbers. # So we split the string, and then convert it to floats r, g, b, a = [float(c) for c in color.split()] # We then use the r,g,b to set the colors on the light and the button color = (r, g, b) self.light.color.set(color) self.setButtonColor(color)
def setShadowColor(self): light = self.lights_list[0] pm.select(light) light = pm.selected()[0] shadowColor = light.shadowColor.get() color = pm.colorEditor(rgbValue=shadowColor) r, g, b, a = [float(c) for c in color.split()] color = (r, g, b) for i in self.lights_list: light_name = i pm.select(i) light = pm.selected()[0].shadowColor.set(color) self.setShadowButtonColor(color)
def set_color(rgb_input, selection=False, input_shape=''): # setting the color value based on the passed argument if selection: input_shape = pm.ls(sl=True)[0] if rgb_input in rgb_dictionary: rgb = rgb_dictionary[rgb_input] else: rgb = pm.colorEditor(query=True, rgb=True) pm.setAttr(input_shape + '.overrideEnabled', 1) pm.setAttr(input_shape + '.overrideRGBColors', 1) pm.setAttr(input_shape + '.overrideColorR', rgb[0]) pm.setAttr(input_shape + '.overrideColorG', rgb[1]) pm.setAttr(input_shape + '.overrideColorB', rgb[2])
def setColor(self): """ Set color of light itself """ # Get color from light lightColor = self.light.color.get() # Open Maya color editor, and value chosen in there will be assigned to 'color' # returns "r g b a" color = pm.colorEditor(rgbValue=lightColor) # Strip the string into variables and convert to float values r, g, b, a = [float(c) for c in color.split()] # Convert 'color' to tuple color = (r, g, b) # Set actual light color and button self.light.color.set(color) self.setButtonColor(color)
def ChangeColor(): selection = pm.ls(selection=True) if len(selection) == 0: pm.inViewMessage(amg='<hl>Select Grp !!!!! </hl>.', pos='midCenter', fade=True) else: Value = pm.colorEditor().split(' ') ok = Value[-1] ColorValue = pm.dt.Color(float(Value[1]), float(Value[3]), float(Value[5])) for grp in selection: grp.useOutlinerColor.set(1) grp.outlinerColor.set(ColorValue) pm.inViewMessage(amg='<hl>ChangeColors</hl>.', pos='midCenter', fade=True)
def setColor(self): light = self.lights_list[0] pm.select(light) light = pm.selected()[0] shadowColor = light.color.get() color = pm.colorEditor(rgbValue=shadowColor) r, g, b, a = [float(c) for c in color.split()] color = (r, g, b) # self.light.color.set(color) # self.setButtonColor(color) for i in self.lights_list: light_name = i pm.select(i) # light = pm.selected()[0].color.set(color) light = pm.selected()[0].name() pm.setAttr(light + '.color', color) self.setButtonColor(color)
def colour_iu(): """ Open up maya's colour picker UI and return the result of what the user selected. Will return blank dict if the user closes the ui. :return: Dict of the result :rtype: dict """ pm.colorEditor() result = {} if pm.colorEditor(query=True, result=True): result['RGB'] = pm.colorEditor(query=True, rgb=True) result['HSV'] = pm.colorEditor(query=True, hsv=True) result['Alpha'] = pm.colorEditor(query=True, alpha=True) else: print('Editor was dismissed') return result
def rgbColorOverride(*args): """ This function can open a rgb color picker and assign a chosen color to the drawing override color of selected obects Args: None Returns (None) """ sel = pm.ls(sl=True) pm.colorEditor() if pm.colorEditor(query=True, result=True): rgb = pm.colorEditor(query=True, rgb=True) hsv = pm.colorEditor(query=True, hsv=True) alpha = pm.colorEditor(query=True, alpha=True) else: print 'Editor was dismissed' for obj in sel: for shape in obj.getShapes(): shape.overrideEnabled.set(1) shape.overrideRGBColors.set(1) shape.overrideColorRGB.set( rgb[0], rgb[1], rgb[2])
def set_color(self, *args): color = pm.colorEditor(rgbValue=(1.0, 1.0, 0.0)) parsedcolor = [float(i) for i in color.split()] self.swatchbtn.setBackgroundColor(parsedcolor[0:-1]) for controller in pm.selected(): mo_curveLib.setRGBColor(controller.getShape(), parsedcolor)