Jump to content

Creating workflows from scripts


Recommended Posts

Hi all, 

Here you have a small example to illustrate how to create workflows using Py scripting

In this example, the created workflow will look like this:

image.png.b943edc6778173aafbeed41ce01ae091.png

Code:

# imports used in the example
import Mistika
from Mistika.classes import CbaseItem
from Mistika.classes import Cconnector
from Mistika.QtCore import QPointF

#create the example workflow

wf=Mistika.workflows.addWorkflow("My Test")                                             # creates a workflow 
file=wf.importFile("G:/MATERIAL/formatos/EXR/CU_BIC_FX008_BICHA_V3_0035.exr",True)       #automatically create a node from a file (the node created depends on the file type (It is similar to droping a file into the workflow editor. The second parameter says if the file comes from a sequence
file.pos=QPointF(0,0)
prores=wf.addNode("ProRes",CbaseItem.NODETYPE_TASK)                                      # add a prores file (From the Tasks group. this helps to diferenciate nodes that appear in more than one group (such us FTP)
prores.pos=QPointF(300,0)                                                                # reposition the prores node (just for clarity)
ftp=wf.addNode("FTP",CbaseItem.NODETYPE_OUTPUT)                                          # add an ftp output node
ftp.pos=QPointF(600,0)                                                                   # reposition the prores node (just for clarity)

file.getFirstConnectorByName("VideoOut").link(prores.getFirstConnectorByName("VideoIn")) # connect file->prores
prores.getFirstConnectorByName("VideoOut").link(ftp.getFirstConnectorByName("File"))     # connect prores->ftp

#populate node properties
file.gamma="Linear"                       # define source color space
file.gamut="ACES (AP1)"
prores.colorSpace="Rec2020"               # define destination Color Space
prores.resolution="HD 1080 (1920x1080)"   # define destination resolution
prores.displayFilter="watermark"          # set a display filter called watermark
ftp.url="ftp://ftp.sgo.es/"               # set the destination ftp address

 

once you have this kind of script, you can add it into a GUI menu button using the following steps:

1.- Write the script in your own myExample.py file There is a default location in SGO AppData/shared/scripts but you can write the script in any other directory 

2.- Add it to the menu using the the bindPyFile command:

i.e. lets suppose my py script is "c:/tmp/myExample/py"example

and I want to create a command called "My Example" in the "menu bar->My Scripts" submenu

I can use the following command: 

Mistika.app.bindPyFile("menuBar->My Scripts","My Example","c:/tmp/myExample/py",10)

If "My Scripts" menu does not exist. it will be created as well.

The number 10 represents the load priority, and it can be used to order the items in the menu (from lower to higher values )

This command will create a bind in the "SGO AppData/workflows/codeBinds" folder linking the menu and the created py file.

to delete the menu, delete the bind file from that folder (the change is applied the next time the sw starts).

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.