def multiload(): fusion=eyeon.scriptapp("Fusion") comp=fusion.GetCurrentComp() str=comp.AskUser("Multi-Loader",{1:{1: "loaderNum", 2: "Slider","Name":"No. of Loaders","Min":1,"Max":mx,"Integer":True}, 2:{1: "Msg", 2:"Text","Name":wrn,"ReadOnly":True,"Default":msg,"Wrap":True,"Lines":3}, 3:{1: "dlgCheck", "Name": "Lock Composition",2: "Checkbox", "Default": 1}, 4:{1: "Msg2", 2:"Text","Name":nte,"ReadOnly":True,"Default":lok,"Wrap":True,"Lines":4} }) print(str) if str is not None: if str['dlgCheck'] == 1: cmpLk=1 else: cmpLk=0 t=(int(str['loaderNum'])) dialog={} for i in range(t): pat={1: 'Sequence{0}'.format(i), 2: 'FileBrowse','Save': True,'Default': ''} dialog.update({i:pat}) seqLoader = comp.AskUser("Load Multiple Sequences",dialog) for i in range(t): if cmpLk==1: comp.Lock() if seqLoader['Sequence{0}'.format(i)]!='': loader = comp.Loader({'Clip' : seqLoader['Sequence{0}'.format(i)]}) elif seqLoader['Sequence{0}'.format(i)]=='': print("You didn't selected anything for Sequence{0}".format(i)) if cmpLk==1: comp.Unlock() else: print(usrcan)
def _do_fusion_pre_publish(self, task, work_template, progress_cb): """ Do Fusion primary pre-publish/scene validation :param task: The primary task to pre-publish :param work_template: The primary work template to use :param progress_cb: A callback to use when reporting any progress to the UI :returns: A list of any errors or problems that were found during pre-publish """ import PeyeonScript f_connection = PeyeonScript.scriptapp ("Fusion") the_comp = f_connection.GetCurrentComp () progress_cb(0.0, "Validating current scene", task) # get scene path scene_path = the_comp.GetAttrs ('COMPS_FileName') self.parent.log_info ("Fusion Scene_Path: " + scene_path) # validate it: scene_errors = self._validate_work_file(scene_path, work_template, task["output"], progress_cb) progress_cb(100) self.parent.log_info("Scene Errors: " + str(scene_errors)) return scene_errors
def load_item_from_path_fusion(self, path): import PeyeonScript f_connection = PeyeonScript.scriptapp ("Fusion") # open f_connection.LoadComp (path)
def __init__(self, version=None, name='', extensions=None): """fusion specific init """ # and add you own modifications to __init__ self.fusion = PeyeonScript.scriptapp("Fusion") self.fusion_prefs = self.fusion.GetPrefs()['Global'] self.comp = self.fusion.GetCurrentComp() self.comp_prefs = self.comp.GetPrefs()['Comp'] self._main_output_node_name = "MAIN_OUTPUT"
def __init__(self, name='', version=None): """fusion specific init """ super(Fusion, self).__init__(name=name, version=version) # and add you own modifications to __init__ self.fusion = bmf.scriptapp("Fusion") self.fusion_prefs = self.fusion.GetPrefs()['Global'] self.comp = self.fusion.GetCurrentComp() self.comp_prefs = self.comp.GetPrefs()['Comp'] self._main_output_node_name = "Main_Output"
def _do_fusion_publish(self, task, work_template, comment, thumbnail_path, sg_task, progress_cb): """ Publish the main Fusion Comp :param task: The primary task to publish :param work_template: The primary work template to use :param comment: The publish description/comment :param thumbnail_path: The path to the thumbnail to associate with the published file :param sg_task: The Shotgun task that this publish should be associated with :param progress_cb: A callback to use when reporting any progress to the UI :returns: The path to the file that has been published """ import PeyeonScript f_connection = PeyeonScript.scriptapp ("Fusion") the_comp = f_connection.GetCurrentComp () self.parent.log_debug("Working Fusion Comunication: " + str(f_connection)) progress_cb(0.0, "Finding scene dependencies", task) dependencies = self._fusion_find_additional_scene_dependencies() # get scene path scene_path = the_comp.GetAttrs ('COMPS_FileName') if not work_template.validate(scene_path): raise TankError("File '%s' is not a valid work path, unable to publish!" % scene_path) # use templates to convert to publish path: output = task["output"] fields = work_template.get_fields(scene_path) fields["TankType"] = output["tank_type"] publish_template = output["publish_template"] publish_path = publish_template.apply_fields(fields) if os.path.exists(publish_path): raise TankError("The published file named '%s' already exists!" % publish_path) # save the scene: progress_cb(10.0, "Saving the scene") self.parent.log_debug("Saving the scene...") the_comp.Save (scene_path) # copy the file: progress_cb(50.0, "Copying the file") try: publish_folder = os.path.dirname(publish_path) self.parent.ensure_folder_exists(publish_folder) self.parent.log_debug("Copying %s --> %s..." % (scene_path, publish_path)) self.parent.copy_file(scene_path, publish_path, task) except Exception, e: raise TankError("Failed to copy file from %s to %s - %s" % (scene_path, publish_path, e))
def get_current_frame_range(self, engine): if engine == "tk-maya": import pymel.core as pm import maya.cmds as cmds current_in = cmds.playbackOptions(query=True, minTime=True) current_out = cmds.playbackOptions(query=True, maxTime=True) elif engine == "tk-nuke": import nuke current_in = int(nuke.root()["first_frame"].value()) current_out = int(nuke.root()["last_frame"].value()) elif engine == "tk-motionbuilder": from pyfbsdk import FBPlayerControl, FBTime lPlayer = FBPlayerControl() current_in = lPlayer.LoopStart.GetFrame() current_out = lPlayer.LoopStop.GetFrame() elif engine == "tk-softimage": import win32com xsi = win32com.client.Dispatch('XSI.Application') current_in = xsi.GetValue("PlayControl.In") current_out = xsi.GetValue("PlayControl.Out") elif engine == "tk-houdini": import hou current_in, current_out = hou.playbar.playbackRange() elif engine == "tk-3dsmax": from Py3dsMax import mxs current_in = mxs.animationRange.start current_out = mxs.animationRange.end elif engine == "tk-3dsmaxplus": import MaxPlus ticks = MaxPlus.Core.EvalMAXScript("ticksperframe").GetInt() current_in = MaxPlus.Animation.GetAnimRange().Start() / ticks current_out = MaxPlus.Animation.GetAnimRange().End() / ticks elif engine == "tk-fusion": import PeyeonScript f_connection = PeyeonScript.scriptapp ("Fusion") the_comp = f_connection.GetCurrentComp () current_in = the_comp.GetAttrs ('COMPN_RenderStart') current_out = the_comp.GetAttrs ('COMPN_RenderEnd') else: raise tank.TankError("Don't know how to get current frame range for engine %s!" % engine) return (current_in, current_out)
def _import_script(self, path, sg_publish_data): """ Import contents of the given file into the scene. :param path: Path to file. :param sg_publish_data: Shotgun data dictionary with all the standard publish fields. """ import PeyeonScript f_connection = PeyeonScript.scriptapp ("Fusion") the_comp = f_connection.GetCurrentComp () if not os.path.exists(path): raise Exception("File not found on disk - '%s'" % path)
def __init__(self, name='', version=None, extensions=None): """fusion specific init """ super(Fusion, self).__init__(name=name, version=version, extensions=extensions) # and add you own modifications to __init__ self.fusion = PeyeonScript.scriptapp("Fusion") self.fusion_prefs = self.fusion.GetPrefs()['Global'] self.comp = self.fusion.GetCurrentComp() self.comp_prefs = self.comp.GetPrefs()['Comp'] self._main_output_node_name = "Main_Output"
def __init__(self, seqdat): self.seqdat = seqdat fu = eyeon.scriptapp("Fusion") self.comp = fu.NewComp() self.comp.SetAttrs({ 'COMPB_HiQ': True, 'COMPN_GlobalStart': 0.0, 'COMPN_GlobalEnd': 100.0, 'COMPN_RenderStart': 0.0, 'COMPN_RenderEnd': 100.0, })
def serverConnect(ip): basla2= time.clock() fusion = PeyeonScript.scriptapp("Fusion",ip) with basla2>1: print "ssss" if fusion != None: comp = fusion.GetCurrentComp() try: compName= comp.GetAttrs('COMPS_Name') username = fusion.GetEnv("USERNAME") print "Username: %s Composition Name: %s Ip Adress: %s" %(username,compName,ip) except AttributeError: print "AttributeError" basla3 = time.clock() print("Toplam Sure = {:10.8f}".format(basla3-basla2), ip)
def __init__(self, name='', version=None): """fusion specific init """ super(Fusion, self).__init__(name=name, version=version) # and add you own modifications to __init__ self.fusion = bmf.scriptapp("Fusion") self.fusion_prefs = self.fusion.GetPrefs()['Global'] # update name with version self.name = 'Fusion%s' % self.fusion.GetAttrs("FUSIONS_Version").split('.')[0] self.comp = self.fusion.GetCurrentComp() self.comp_prefs = self.comp.GetPrefs()['Comp'] self._main_output_node_name = "Main_Output"
def serverConnect(ip): basla2 = time.clock() fusion = PeyeonScript.scriptapp("Fusion", ip) with basla2 > 1: print "ssss" if fusion != None: comp = fusion.GetCurrentComp() try: compName = comp.GetAttrs('COMPS_Name') username = fusion.GetEnv("USERNAME") print "Username: %s Composition Name: %s Ip Adress: %s" % ( username, compName, ip) except AttributeError: print "AttributeError" basla3 = time.clock() print("Toplam Sure = {:10.8f}".format(basla3 - basla2), ip)
def __init__(self, path="", slices_in_x=5, slices_in_y=5, plate_width=0, plate_height=0): self.fusion = bmf.scriptapp("Fusion") self.comp = self.fusion.GetCurrentComp() self.fusion_version = float( self.fusion.GetAttrs("FUSIONS_Version").split(".")[0]) self.path = path self.slices_in_x = slices_in_x self.slices_in_y = slices_in_y self.plate_width = plate_height self.plate_height = plate_width
def server_connect(ip): """connects to server :param str ip: The IP of the :return: """ basla2 = time.clock() fusion = bmf.scriptapp("Fusion", ip) if fusion is not None: comp = fusion.GetCurrentComp() try: comp_name = comp.GetAttrs('COMPS_Name') username = fusion.GetEnv("USERNAME") fusion_version = float(fusion.GetAttrs("FUSIONS_Version")) print {"Username": username, "Composition Name": comp_name, "Ip Adress": ip, "Fusion Version": fusion_version} except AttributeError: print "AttributeError"
def _create_read_node(self, path, sg_publish_data): """ Create a read node representing the publish. :param path: Path to file. :param sg_publish_data: Shotgun data dictionary with all the standard publish fields. """ import PeyeonScript f_connection = PeyeonScript.scriptapp ("Fusion") the_comp = f_connection.GetCurrentComp () (_, ext) = os.path.splitext(path) valid_extensions = [".png", ".jpg", ".jpeg", ".exr", ".cin", ".dpx", ".tiff", ".tif", ".mov", ".psd", ".tga", ".ari", ".gif", ".iff"] if ext.lower() not in valid_extensions: raise Exception("Unsupported file extension for '%s'!" % path) # find the sequence range if it has one: seq_range = self._find_sequence_range(path) # create the read node the_comp.Lock() if seq_range: the_comp.Loader ({'Clip' : seq_range[0]}) else: the_comp.Loader ({'Clip' : path}) the_comp.Unlock()
def update(self, items): """ Perform replacements given a number of scene items passed from the app. Once a selection has been performed in the main UI and the user clicks the update button, this method is called. The items parameter is a list of dictionaries on the same form as was generated by the scan_scene hook above. The path key now holds the that each node should be updated *to* rather than the current path. """ f_connection = PeyeonScript.scriptapp ("Fusion") the_comp = f_connection.GetCurrentComp () engine = self.parent.engine list_of_loaders = {} for index, value in the_comp.GetToolList (False, "Loader").iteritems (): list_of_loaders[value.Name] = value #node_type_list = ["Read", "ReadGeo2", "Camera2"] node_type_list = ["Read"] for i in items: node_name = i["node"] node_type = i["type"] new_path = i["path"] if node_type in node_type_list : engine.log_debug("Node %s: Updating to version %s" % (node_name, new_path)) node = list_of_loaders[node_name] # make sure slashes are handled correctly - always forward new_path = new_path.replace(os.path.sep, "/") node.Clip = new_path
def __init__(self): self.sumshot = 0.0 self.offset = 0 self.fusion = PeyeonScript.scriptapp("Fusion") self.comp = self.fusion.GetCurrentComp()
"""Window class for Blackmagic Fusion.""" from __future__ import absolute_import import os import sys try: import fusionscript fusion = fusionscript.scriptapp('Fusion') except ImportError: import PeyeonScript as eyeon fusion = eyeon.scriptapp('Fusion') from .utils import setCoordinatesToScreen, hybridmethod from .standalone import StandaloneWindow VERSION = str(int(fusion.Version)) def getMainWindow(): """Get a pointer to the Fusion window. However as of Fusion 9, this doesn't seem to return anything. """ return fusion.GetMainWindow() class FusionWindow(StandaloneWindow): def __init__(self, parent=None, **kwargs): if parent is None: parent = getMainWindow()
# -*- coding: utf-8 -*- # Copyright (c) 2012-2019, Anima Istanbul # # This module is part of anima and is released under the MIT # License: http://www.opensource.org/licenses/MIT """Merges sliced renders in to one big plate """ try: # for Fusion 6 and 7 import PeyeonScript as bmf except ImportError: # for Fusion 8+ import BlackmagicFusion as bmf fusion = bmf.scriptapp("Fusion") comp = fusion.GetCurrentComp() fusion_version = float(fusion.GetAttrs("FUSIONS_Version")) class RenderMerger(object): """A tool to merge sliced renders """ def __init__(self, path="", slices_in_x=5, slices_in_y=5, plate_width=0, plate_height=0): self.path = path
# -*- coding: utf-8 -*- # Copyright (c) 2012-2015, Anima Istanbul # # This module is part of anima-tools and is released under the BSD 2 # License: http://www.opensource.org/licenses/BSD-2-Clause """Merges sliced renders in to one big plate """ import PeyeonScript fusion = PeyeonScript.scriptapp("Fusion") comp = fusion.GetCurrentComp() fusion_version = float(fusion.GetAttrs("FUSIONS_Version")) class RenderMerger(object): """A tool to merge sliced renders """ def __init__(self, path="", slices_in_x=5, slices_in_y=5, plate_width=0, plate_height=0): self.path = path self.slices_in_x = slices_in_x self.slices_in_y = slices_in_y self.plate_width = plate_height self.plate_height = plate_width def ui(self): """the UI for the script """ result = comp.AskUser(
# -*- coding: utf-8 -*- # Copyright (c) 2012-2018, Anima Istanbul # # This module is part of anima-tools and is released under the BSD 2 # License: http://www.opensource.org/licenses/BSD-2-Clause """Merges sliced renders in to one big plate """ try: # for Fusion 6 and 7 import PeyeonScript as bmf except ImportError: # for Fusion 8+ import BlackmagicFusion as bmf fusion = bmf.scriptapp("Fusion") comp = fusion.GetCurrentComp() fusion_version = float(fusion.GetAttrs("FUSIONS_Version")) class RenderMerger(object): """A tool to merge sliced renders """ def __init__(self, path="", slices_in_x=5, slices_in_y=5, plate_width=0, plate_height=0): self.path = path self.slices_in_x = slices_in_x self.slices_in_y = slices_in_y self.plate_width = plate_height self.plate_height = plate_width
def __init__(self): self.dialog = {} self.fusion = bmf.scriptapp("Fusion") self.comp = self.fusion.GetCurrentComp()
# Copyright (c) 2013 Shotgun Software Inc. # # CONFIDENTIAL AND PROPRIETARY # # This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit # Source Code License included in this distribution package. See LICENSE. # By accessing, using, copying or modifying this work you indicate your # agreement to the Shotgun Pipeline Toolkit Source Code License. All rights # not expressly granted therein are reserved by Shotgun Software Inc. import os import PeyeonScript f_connection = PeyeonScript.scriptapp ("Fusion") import tank from tank import Hook from tank import TankError class SceneOperation(Hook): """ Hook called to perform an operation with the current scene """ def execute(self, operation, file_path, **kwargs): """ Main hook entry point :operation: String
def set_frame_range(self, engine, in_frame, out_frame): if engine == "tk-maya": import pymel.core as pm # set frame ranges for plackback pm.playbackOptions(minTime=in_frame, maxTime=out_frame, animationStartTime=in_frame, animationEndTime=out_frame) # set frame ranges for rendering defaultRenderGlobals=pm.PyNode('defaultRenderGlobals') defaultRenderGlobals.startFrame.set(in_frame) defaultRenderGlobals.endFrame.set(out_frame) elif engine == "tk-nuke": import nuke # unlock locked = nuke.root()["lock_range"].value() if locked: nuke.root()["lock_range"].setValue(False) # set values nuke.root()["first_frame"].setValue(in_frame) nuke.root()["last_frame"].setValue(out_frame) # and lock again if locked: nuke.root()["lock_range"].setValue(True) elif engine == "tk-motionbuilder": from pyfbsdk import FBPlayerControl, FBTime lPlayer = FBPlayerControl() lPlayer.LoopStart = FBTime(0, 0, 0, in_frame) lPlayer.LoopStop = FBTime(0, 0, 0, out_frame) elif engine == "tk-softimage": import win32com Application = win32com.client.Dispatch('XSI.Application') # set playback control Application.SetValue("PlayControl.In", in_frame) Application.SetValue("PlayControl.Out", out_frame) Application.SetValue("PlayControl.GlobalIn", in_frame) Application.SetValue("PlayControl.GlobalOut", out_frame) # set frame ranges for rendering Application.SetValue("Passes.RenderOptions.FrameStart", in_frame) Application.SetValue("Passes.RenderOptions.FrameEnd", out_frame) elif engine == "tk-houdini": import hou # We have to use hscript until SideFX gets around to implementing hou.setGlobalFrameRange() hou.hscript("tset `((%s-1)/$FPS)` `(%s/$FPS)`" % (in_frame, out_frame)) hou.playbar.setPlaybackRange(in_frame, out_frame) elif engine == "tk-3dsmax": from Py3dsMax import mxs mxs.animationRange = mxs.interval(in_frame, out_frame) elif engine == "tk-3dsmaxplus": import MaxPlus ticks = MaxPlus.Core.EvalMAXScript("ticksperframe").GetInt() range = MaxPlus.Interval(in_frame * ticks, out_frame * ticks) MaxPlus.Animation.SetRange(range) elif engine == "tk-fusion": import PeyeonScript f_connection = PeyeonScript.scriptapp ("Fusion") the_comp = f_connection.GetCurrentComp () the_comp.SetAttrs ({'COMPN_GlobalEnd': out_frame}) the_comp.SetAttrs ({'COMPN_RenderEnd': out_frame}) the_comp.SetAttrs ({'COMPN_GlobalStart': in_frame}) the_comp.SetAttrs ({'COMPN_RenderStart': in_frame}) else: raise tank.TankError("Don't know how to set current frame range for engine %s!" % engine)
# -*- coding: utf-8 -*- # Copyright (c) 2012-2015, Anima Istanbul # # This module is part of anima-tools and is released under the BSD 2 # License: http://www.opensource.org/licenses/BSD-2-Clause """Merges sliced renders in to one big plate """ import PeyeonScript fusion = PeyeonScript.scriptapp("Fusion") comp = fusion.GetCurrentComp() fusion_version = float(fusion.GetAttrs("FUSIONS_Version")) class RenderMerger(object): """A tool to merge sliced renders """ def __init__(self, path="", slices_in_x=5, slices_in_y=5, plate_width=0, plate_height=0): self.path = path self.slices_in_x = slices_in_x self.slices_in_y = slices_in_y self.plate_width = plate_height self.plate_height = plate_width
def __init__(self): self.sumshot = 0.0 self.offset = 0 self.fusion = bmf.scriptapp("Fusion") self.comp = self.fusion.GetCurrentComp()
def __init__(self): self.fusion = PeyeonScript.scriptapp("Fusion") self.comp = self.fusion.GetCurrentComp() self.comp_active_tool = self.comp.ActiveTool if self.comp_active_tool is not None: self.path = str(self.comp_active_tool.GetInput("Clip"))
def connect(self): """docstring for connect""" self.app = eyeon.scriptapp("Generation") return self.status()
def connect(self): """docstring for connect""" self.app = eyeon.scriptapp("Fusion") return self.status()
def scan_scene(self): """ The scan scene method is executed once at startup and its purpose is to analyze the current scene and return a list of references that are to be potentially operated on. The return data structure is a list of dictionaries. Each scene reference that is returned should be represented by a dictionary with three keys: - "node": The name of the 'node' that is to be operated on. Most DCCs have a concept of a node, path or some other way to address a particular object in the scene. - "type": The object type that this is. This is later passed to the update method so that it knows how to handle the object. - "path": Path on disk to the referenced object. Toolkit will scan the list of items, see if any of the objects matches any templates and try to determine if there is a more recent version available. Any such versions are then displayed in the UI as out of date. """ f_connection = PeyeonScript.scriptapp ("Fusion") the_comp = f_connection.GetCurrentComp () self.parent.log_debug("Current Comp: %s" % the_comp) # Here we save the file so we can read the most updated data from the loaders file_path = the_comp.GetAttrs ('COMPS_FileName') the_comp.Save (file_path) # first let's look at the loaders # we start adding their names to a list, so we can use it later to find # their paths in the composition file loader_list = [] for index, node in the_comp.GetToolList (False, "Loader").iteritems (): node_name = node.Name loader_list.append (node_name) # We use this function to get a dict list with the loaders and their content # Values in order are: [list of loader names], "path to composition", "Type of node" reads = self.get_loader_filename_from_comp (loader_list, file_path, "Read") self.parent.log_debug("Finding the follwing loaders: %s" % reads) # UNLESS THERE ARE OTHER KIND OF LOADERS OR THINGS TO CARE ABOUT, THIS IS UNNECESSARY # HOWEVER I LEAVE THIS HERE AS REFERENCE IN CASE IT IS INDEED NEEDED ''' # then the read geometry nodes for node in nuke.allNodes("ReadGeo2"): node_name = node.name() path = node.knob('file').value().replace("/", os.path.sep) reads.append( {"node": node_name, "type": "ReadGeo2", "path": path}) # then the read camera nodes for node in nuke.allNodes("Camera2"): node_name = node.name() path = node.knob('file').value().replace("/", os.path.sep) reads.append( {"node": node_name, "type": "Camera2", "path": path}) ''' return reads