...
The script will add random or uniform colors to a selection of objects:
Code Block | ||
---|---|---|
| ||
import random colourModes = ["Random colours","Uniform colour"] guiForm = GUIFormDialog.new() guiForm.addListField("Colour mode", colourModes, 0) guiForm.addIntField("Red (0-255)", 255) guiForm.addIntField("Green (0-255)", 255) guiForm.addIntField("Blue (0-255)", 255) guiForm.addBoolField("Activate RBD mode", False) if (guiForm.show() == GUI_DIALOG_ACCEPTED): mode = guiForm.getFieldValue("Colour mode") rbdActivation = guiForm.getFieldValue("Activate RBD mode") nodeSelection = scene.getSelectedNodes() for entry in nodeSelection: if (mode == 0): red = random.randint(0, 255) green = random.randint(0, 255) blue = random.randint(0, 255) if (mode == 1): red = guiForm.getFieldValue("Red (0-255)") green = guiForm.getFieldValue("Green (0-255)") blue = guiForm.getFieldValue("Blue (0-255)") colour = Vector.new(red, green, blue) entry.setParameter("Color", colour) if (rbdActivation == True): entry.setParameter("Dynamics","Active rigid body") else: scene.message(str("Script cancelled by user")) |