I have asked about this Pyhton script before, but now i have become faced with a new question: I want to have the texture slider of my script affect the bump depth of my model, but I am not sure how to do so. Is there anyone out there that can help me? I have a bump map texture applied in my model, I just need help getting the slider from the image below into Python format.
import maya.cmds as mc
if mc.window("Mat_Tex", exists=True):
mc.deleteUI(ram)
ram = mc.window("Mat_Tex", t="Material and Texture", w=300, h=300)
mc.columnLayout(adj=True)
imagePath = mc.internalVar(upd=True) + "icons/scriptlogo.jpg"
mc.image(w=300, h=200, image=imagePath)
# A dropdown menu deisnged to change material/color of octopus
matOptionMenu = mc.optionMenu(label="Material")
myBlinn = mc.menuItem(label="Red")
myBlinn = mc.menuItem(label="Blue")
myBlinn = mc.menuItem(label="Yellow")
myBlinn = mc.menuItem(label="Green")
myBlinn = mc.menuItem(label="Orange")
myBlinn = mc.menuItem(label="Purple")
# A slider designed to alter the intensity of the octopus' texture
texBumpDepth = mc.floatSliderGrp(label="Texture", min=-5, max=5, field=True)
def applySlider(*args):
slidervalue = mc.floatSliderGrp(texBumpDepth, q = True, value = True)
# here is where you want to do something with the value
print "setting bump value to", slidervalue
# it will probably look like
mc.setAttr( "bump2d2" + ".bumpDepth", slidervalue)
def set_shader_bump_depth(shader, amount):
bump2ds = mc.listConnections(shader, type = 'bump2d')
# that's always list, so we loop over it
for eachbump2d in bump2ds:
print "editing", eachbump2d
mc.setAttr(eachbump2d + ".bumpDepth", amount)
mc.floatSliderGrp(texBumpDepth, e=True, changeCommand = applySlider)
def applyMaterial(*args):
currentValue = mc.optionMenu(matOptionMenu, query=True, value=True)
if currentValue == "Red":
mc.hyperShade(assign='red')
elif currentValue == "Blue":
mc.hyperShade(assign='blue')
elif currentValue == "Yellow":
mc.hyperShade(assign='yellow')
elif currentValue == "Green":
mc.hyperShade(assign='green')
elif currentValue == "Orange":
mc.hyperShade(assign='orange')
elif currentValue == "Purple":
mc.hyperShade(assign='purple')
# A button to apply any changes
mc.button(label="Apply", command=applyMaterial)
mc.showWindow(ram)