Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import nuke
- import nuke.rotopaint as rp
- def flip_roto_shapes():
- node = nuke.selectedNode()
- if node.Class() not in ("Roto", "RotoPaint"):
- nuke.message("Please select a Roto or RotoPaint node.")
- return
- curves = node['curves']
- root = curves.rootLayer
- frame = nuke.frame()
- format_width = node.format().width()
- def flip_shape(shape, shape_path):
- for i, pt in enumerate(shape):
- center = pt.center
- x_curve = center.getPositionAnimCurve(0)
- y_curve = center.getPositionAnimCurve(1)
- orig_x = x_curve.evaluate(frame)
- orig_y = y_curve.evaluate(frame)
- flipped_x = format_width - orig_x
- x_curve.addKey(frame, flipped_x)
- y_curve.addKey(frame, orig_y)
- print(f" → Flipped {shape_path} pt {i}: ({orig_x:.2f}, {orig_y:.2f}) → ({flipped_x:.2f}, {orig_y:.2f})")
- def walk(layer, path=""):
- for item in layer:
- if isinstance(item, rp.Shape):
- shape_path = path + item.name
- print(f"[✓] Flipping shape: {shape_path}")
- flip_shape(item, shape_path)
- elif isinstance(item, rp.Layer):
- walk(item, path + item.name + "/")
- print("== BEGIN FLIPPING SHAPES ON CURRENT FRAME ==")
- walk(root)
- curves.changed()
- print("== DONE ==")
- flip_roto_shapes()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement