Created
November 18, 2015 17:40
-
-
Save jedypod/8cd23b28e67625e8b826 to your computer and use it in GitHub Desktop.
Scales all strokes in a rotopaint node by a specified scale: expects a layer full of strokes that have all been scaled by the specified amount from a center of 0,0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Adjust size of all brush stokes in a layer | |
## Expects a single layer in the rotopaint node containing strokes that want to be scaled. | |
## This script scales the brushsize and source transform by the scale value | |
_SCALE_ = 1.53706293 | |
rn = nuke.selectedNode() | |
cKnob = rn["curves"] | |
rootLayer = cKnob.rootLayer | |
layers = [elem for elem in rootLayer if isinstance(elem, nuke.rotopaint.Layer)] | |
for layer in layers: | |
for stroke in layer: | |
print stroke.name | |
stroke_attr = stroke.getAttributes() | |
brushsize = stroke_attr.getCurve('bs') | |
curValue = brushsize.constantValue | |
newValue = curValue*_SCALE_ | |
stroke_attr.remove('bs') | |
stroke_attr.add('bs', newValue) | |
src_translate_x = stroke_attr.getCurve('stx').constantValue | |
src_translate_y = stroke_attr.getCurve('sty').constantValue | |
new_src_translate_x = src_translate_x * _SCALE_ | |
new_src_translate_y = src_translate_y * _SCALE_ | |
stroke_attr.remove('stx') | |
stroke_attr.remove('sty') | |
stroke_attr.add('stx', new_src_translate_x) | |
stroke_attr.add('sty', new_src_translate_y) | |
cKnob.changed() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment