def execute(self, **kwargs): shapes = getObjects(selection(), types=[Shape]) if len(shapes) > 0: optype = kwargs["mode"] if "mode" in kwargs.keys( ) else self.from_action_menu if optype == "copy": self.savedkeys = {} ## start with fresh dict beginUndo("KMFX Shape Keyframe Paste") actualframe = player.frame for shape in shapes: path = shape.property("path") if optype == "copy": self.savedkeys[shape.id] = path.getValue(actualframe) elif optype == "paste": if shape.id in self.savedkeys.keys(): path.setValue(self.savedkeys[shape.id], actualframe) if optype == "paste": status("KMFX: pasted select shapes keyframes") else: status("KMFX: copied select shapes keyframes") #alternating the actions if run from action menu # self.from_action_menu = "paste" if self.from_action_menu == "copy" else "copy" endUndo() else: status("KMFX: no shapes selected")
def available(self): node = activeNode() session = activeSession() assert session, "Select a Session" rotoNode = session.node(type="RotoNode") assert rotoNode, "The session does not contain a Roto Node" shapes = getObjects(selection()) assert len(shapes) > 0, "There must be one or more selected shapes/layers"
def execute(self, **kwargs): shapes = getObjects(selection(), types=[Shape]) if len(shapes) > 0: fx.actions["KMFXcopyShapeKeyframe"].execute(**{"mode": "paste"}) else: status("KMFX: no shapes selected")
def execute(self, **kwargs): beginUndo("KMFX move shape") node = activeNode() session = node.session session_size = session.size shapes = getObjects(selection(), types=[Shape]) optype = kwargs["mode"] if "mode" in kwargs.keys() else "TL" multiplier = kwargs["modifier"] if "modifier" in kwargs.keys( ) else fx.prefs["nudging.distance"] if multiplier == "shift": multiplier = fx.prefs["nudging.extendedDistance"] elif multiplier == "ctrl": multiplier = fx.prefs["nudging.ctrlDistance"] mx = { "L": -1, "T": 0, "R": 1, "B": 0, "BL": -1, "TL": -1, "TR": 1, "BR": 1 } my = { "L": 0, "T": -1, "R": 0, "B": 1, "BL": 1, "TL": -1, "TR": -1, "BR": 1 } actualframe = player.frame for shape in shapes: selectedpoints = False if fx.viewer.toolName != "Reshape" else True pathProp = shape.property("path") pathEditor = PropertyEditor(pathProp) path = shape.evalPath(actualframe) matrix = Matrix() matrix.translate( 1 / session.size[0] / fx.viewer.zoom * mx[optype] * multiplier, 1 / session.size[1] / fx.viewer.zoom * my[optype] * multiplier) path.transform(matrix, selected=selectedpoints) pathEditor.setValue(path, actualframe) pathEditor.execute() endUndo()
def execute(self,**kwargs): shapes = getObjects(selection(), types=[Shape]) optype= kwargs["mode"] if "mode" in kwargs.keys() else "default" beginUndo("Keyframe Visibility ON/OFF") node = activeNode() session = node.session startFrame = session.startFrame actualframe = player.frame wasConstant = False for shape in shapes: opacity = shape.property("opacity") if opacity.constant: opacity.constant = False wasConstant = True if optype == "default": if opacity.getValue(actualframe) > 0: opacity.setValue(0, actualframe) else: opacity.setValue(100, actualframe) if wasConstant and actualframe != 0: editor = PropertyEditor(opacity) editor.deleteKey(0) editor.execute() if optype == "singleframe": if actualframe not in (0,session.duration): if opacity.getValue(actualframe) > 0: opacity.setValue(0, actualframe-1) opacity.setValue(100, actualframe) opacity.setValue(0, actualframe+1) if actualframe != 1 and wasConstant: editor = PropertyEditor(opacity) editor.deleteKey(0) editor.execute() elif actualframe == 0: if opacity.getValue(actualframe) > 0: opacity.setValue(100, actualframe) opacity.setValue(0, actualframe+1) elif actualframe == session.duration: if opacity.getValue(actualframe) > 0: opacity.setValue(0, actualframe-1) opacity.setValue(100, actualframe) editor = PropertyEditor(opacity) editor.deleteKey(0) editor.execute() endUndo()
def execute(self): if fx.selection() == []: displayError("KMFXNode Time Offset: Select some nodes", title="Error") return num = {"id": "num", "label": "Frames to offset", "value": 0} direction = { "id": "list", "label": "Direction", "value": "Head", "items": ["Head", "Tail"] } fields = [num, direction] result = getInput(title="Offset Node Keyframes", fields=fields) if result != None: fx.beginUndo("KMFX Node time offset") offset = result['num'] * -1 if result[ "list"] == "Head" else result['num'] nodes = fx.selection() for node in nodes: if node.isType("PaintNode"): pass ## cant change paint nodes at this time elif node.type in ["RotoNode", "MorphNode"]: child = node.children objects = getObjects(child) selectedlist = [] ## selection is just to refresh timeline for o in objects: if o.selected == True: selectedlist.append(o) for p in o.properties: if o.property(p).constant != True: o.property(p).moveKeys(offset) ### this is for all nodes properties for p in node.properties: if node.property(p).constant != True: node.property(p).moveKeys(offset) x = fx.selection() fx.select([]) fx.select(x) fx.endUndo()
def execute(self, deletekeys=True, propertiesList=["opacity"]): beginUndo("KMFX Clone Shapes in Place") shapes = getObjects(selection(), types=[Shape]) activelayer = activeLayer() if activelayer != None: thisframe_matrix = activelayer.getTransform(player.frame) else: ##shape is on the root of the node thisframe_matrix = Matrix() activelayer = activeNode() selectionlist = [] avoid_duplicates = [] for shape in shapes: # if shape.parent != activelayer and shape not in avoid_duplicates: if shape not in avoid_duplicates: copy = shape.clone() activelayer.property("objects").addObjects([copy]) pathProp = copy.property("path") pathEditor = PropertyEditor(pathProp) path = copy.evalPath(player.frame) if shape.parent.type == "Layer": identity = Matrix() reverseparent = shape.parent.getTransform(player.frame) offset_matrix = -thisframe_matrix * reverseparent path.transform(offset_matrix) elif shape.parent.type == "RotoNode": identity = Matrix() reverseparent = identity offset_matrix = -thisframe_matrix * reverseparent path.transform(offset_matrix) pathEditor.setValue(path, player.frame) keysn = pathProp.numKeys keys = pathProp.keys for t in reversed(range(keysn)): if keys[t] != player.frame: pathEditor.deleteKey(t) pathEditor.execute() if deletekeys: remove_keys(copy, propertiesList) selectionlist.append(copy) avoid_duplicates.append(shape) select(selectionlist) endUndo()
def doExport(self, path): sel = selection() if len(sel) == 0: status("Select some shapes before trying to export!") else: if not os.path.exists(path): print "\nWARNING\n**************\nExportNukeShapes Script: The path does not exists, set it correctly on the script" path = os.path.abspath(path) # get the "Nuke 6.2+" module module = io_modules["Nuke 6.2+ Shapes"] shapes = getObjects(selection(), types=[Shape]) self.counter += 1 name = "sfx_shapes" + str(self.counter)#"s.label ext = ".nk" shapePath = os.path.join(path, name + ext) module.export(shapePath) status("Nuke 6.2+ Shapes exported to " + path)
def available(self): shapes = getObjects(selection(), types=[Shape]) assert len(shapes) > 0, "There must be one or more selected shapes"