Nuke python tutorial | How to add a Python tool inside Foundry Nuke

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hey guys i hope everyone is well and safe while watching this tutorial on this aegis way youtube channel i saw one python tool which can be very handy so this is a tool and we open the link in nuke pdf so basically animated corner pin to matrix is a tool which generates four by four transform matrix in a corner pin node which can be very handy so here we have all the description and the contributor is expert ratio i'm not sure i pronounced it correctly you can see the description like how to install and other basic instructions here i'm gonna download this tool first of all we need to login in nuke pedia click on this download button check this agree option and hola download it yes save the file into your downloads folder so in my pc i have copied that into the dot new folder i'm going to explain now how to install and add that python tool inside nuke okay here we have nuke and this is the script editor inside nuke so if you want to access the script editor windows new script editor so inside nuke we can see a lot of menu like the menu over here render menu help menu and the menu over the nodes and the menu of the viewer and the menu over the node graph also while you create a new node you can see some menu over here too so our work is to create a new menu here and add some python tools inside that so you can go into here and let's create a blur node and see what it shows so here here you can see nuke dot create note blur so by writing codes we can create anything inside nuke nuke dot create node caps and parenthesis ctrl enter so it shows some type error so let's give an argument inside this and let's write blur ctrl enter here you can see a blur node has been created so nuke helps us to learn python by showing all these codes here for accessing this go into preferences and here in script editor you have to check this option echo python commands to output window so that we can see all those scripts all those codes inside this output window and now i'm going to create a new menu using the script editor so i'm gonna delete all this stuff and clear all these windows and we are going to create a new menu over here so the basic function for that is like new nuke dot menu parenthesis and let's run this and see what it shows so it shows an error like takes exactly one argument but zero given so we are going to give an argument inside this function like uh um so first of all i want to tell you like there are certain names for every menu inside nuke so this is new menu and this is nodes menu and the name for this is like viewer and it goes on so we are going to access the nuke menu so nuke dot menu nuke control enter and it shows the result right now let's write argument for this function as nodes and control enter now you can see the result of that here okay i'm going to access nuke menu again execute and you see the result without error here cool copy this and paste it over here and let's write a long code with this so it's kind of tough while writing long codes and we can use variables for assigning these functions so here i am typing mad looks space equals and the function to that and let's execute this so here we have no error and that means we have assigned a variable for this function let's assign m as a variable here and you can see the result without any error so here i can execute this function using this variable so m is a variable and dot add command please note c is uppercase and parenthesis and let's run the code so it throws an error like argument not found so we are going to write an argument inside this function and this is the name of our menu and i'm writing python tools in quartz as it is a string ctrl enter right so there is no error here and you can see a menu named python tools has been added here and if you click on that it shows unknown command as it is not creating anything let's go back to the code and i'm gonna copy all this paste it over here i am changing the menu name as python tools and also here uppercase p and let's put a comma and write an inbuilt function for creating a node so nuke dot create note function parenthesis and blur as string inside the argument let's create an erode node instead of blur remember to type upper case for the node name select the whole code and ctrl enter oops it throws an error as invalid syntax so come back to the node class name and put double quotes here so i am going to select this code and execute yep it's done and you can see the new menu here and if you click on that it creates an error node with all the properties awesome i'm deleting this node and we are going to order the code a bit i just want to create a drop down kind of menu just like this help menu come back to the script editor and let's copy this stuff and paste it again after some lines this time i am going to change my menu name as tools [Music] so deleting this python from here type a slash to separate the menu and create a submenu and type blur [Music] as i'm going to change the string here as blur select the code and execute and it's done you can see the new tool menu here and inside that the blur option and as our code it creates a blur node with all the properties deleting this blur node and let's alter the code a bit more select this code and paste it after in few lines this time i'm gonna create two sub menu and writing the name of the menu as test and here instead of blur changing it as blood type type slash again and write blur as our tool let's select this set of codes and execute and that's done and we have a new set of menu named as test so this is the need for creating a menu and tool inside that and we can write the code in menu and init dot py for that because the thing which i coded here is temporary wait i will show you that let's close new can restart hey we can't find any of those menu here which we created earlier and just come over here also in the script editor there is nothing as a backup though this script can be restored using preference let's close nuke and head over to dot nuke folder here you can see some python files and folders if you have a fresh nuke install things will be different here here is the python folder i created and i copied that downloaded python tool inside here and here we can see the init.py and menu.py which is the main thing for new init.py here you can tell nuke to look after specific parts of folders or gizmos here is menu dot py which can be used to write down all our customization codes i'll show you what to write in both the py files when loading a python tool inside nuke first in init.py let's show nuke the specific path of our tool and the code is nuke dot plugin add path and parenthesis and inside this put a slash and write down the folder name yes it's python okay so you can see it over here this is the folder where our tool exists come back to init.py always remember to add a dot to the path to make it as relative so that dot means the path for the dot nuke folder in your pc so this is done and i am saving the init.py file and moving on to menu.py so in menu.py we have to write somewhat similar stuff which we saw sometime back in nuke so n equals no m equals nu dot menu parenthesis quite nuke inside that as the menu which we are accessing to the next line as m dot add command parenthesis python tools slash blur and here instead of blur i'm gonna write the python tool name and you can see that here i'm copying this name come back to menu.p5 paste it here i'm gonna take off this animated and keeping the tool name as corner pin to matrix [Music] comma and here comes the second argument nuke dot create node [Music] wait a minute instead of this function here in the place of this nuke i am going to paste this so select nuke and paste the python tool name then make sure you write the exact tool name just open the python tool and you can see that code here which makes the tool behave inside nuke gui here we can see a function is defined and it's animated cp2 mtx let's copy this and come back to menu dot py paste it over here so this is our function let's remove this extra quart and it's done i'm saving this file and gonna restart nuke here we have a fresh new can you can see the python tools here as a menu i'm just clicking in this oh no there is there is an error which tells our function is not defined now we need to define this function to nuke close nuke and go back to menu dot py inside dot nuke folder here you can see as import nuke and so on so inside menu dot py here i'm gonna add a line arranging this code bit down here and let's write import and the function name so copy this and paste it over here done let's save this file and reset nuke here we have nuke and let's run the tool again now it's a pop-up telling us that we didn't selected a corner pin node so basically our tool is ready come back to the python file and you can see this pop-up message inside our code itself please select a corner pin node so let's see how we can make use of this tool now take a corner pin node we have four corners here i'm gonna set a keyframe for all these four corner points one two three four in the 30th frame i am animating these corners one by one to create a motion and finally this is the animation and we have some values getting animated inside here let's use our tool to generate a matrix value from this corner pin animation and it asks us to assign a frame range so i am writing the frame range click on ok hola we have the matrix value generated inside another corner pin node and ready to use let's see a way to utilize this matrix values and in new there are certain nodes which can be used for this take a router node and right away the transform tab here we can see the extra matrix option which can be used as transformation okay select this layer and now click and drag oops forgot to hold shift shift and drag these values to here all set i'm going to draw a spline in this layer let's take a eclipse and draw inside this layer wow awesome we have the transformation in this spline too we succeeded to install and use the tool in our work i hope this tutorial helped in some ways thank you [Music] you
Info
Channel: madlookz VFX
Views: 5,652
Rating: undefined out of 5
Keywords: Visualeffects, Nuke tutorials, Boris FX, Silhouette tutorials, Roto tutorials, Paint-Prep in nuke, Compositing tutorials, Nuke compositing, VFX interviews, vfx and animation, vfx jobs, vfx jobs in india, vfx jobs in canada, Vfx podcast, animation podcast, vfx interviews, Animation interviews, vfx industry, vfx student, vfx india, Nuke scripting, Python in nuke, Nuke python tutorial, nuke compositing, python for nuke, nuke tutorial, visual effects, foundry nuke
Id: yLUdKEhz4fY
Channel Id: undefined
Length: 13min 55sec (835 seconds)
Published: Tue Jan 12 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.