Skip to content

Instantly share code, notes, and snippets.

@tokejepsen
Last active July 8, 2016 15:38
Show Gist options
  • Save tokejepsen/8f2a7d9807bcbbbb1ac0969a654a6b81 to your computer and use it in GitHub Desktop.
Save tokejepsen/8f2a7d9807bcbbbb1ac0969a654a6b81 to your computer and use it in GitHub Desktop.
Nuke: related code
# limited random scaling
import nuke
import random
min_scale = 800
max_scale = 1600
for node in nuke.selectedNodes("Card2"):
scale = random.uniform(min_scale, max_scale)
node['uniform_scale'].setValue(scale)
# random image in folder
import nuke
import random
import os
for node in nuke.selectedNodes("Read"):
path = node['file'].getValue()
root = os.path.dirname(path)
images = []
for f in os.listdir(root):
images.append(f)
f = random.choice(images)
new_path = os.path.join(root, f).replace('\\', '/')
node['file'].setValue(new_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment