python scripting for foundry Nuke ; lesson - 01. Simple scripts.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hey there satish here welcome to python for new video series in this video series i'm not going to tell you how to open the script editor how are these buttons are working what is integer what is float how to type and those kind of basics most of you all already know those kind of basic things if you don't know those kind of basics and go to youtube and type new python essentials and it will give you series of videos for new python basics so you can learn from that first thing first we'll tell the new say hi to the world for that you need to type new york dot mess message hello world and select on ctrl enter in windows linux or command enter in mac and you can pop up a window with your comment let's see how can we use small small python scripts in our day-to-day compositing life if you want to create a node in nuke where python you have to say new york dot create node and whatever the node class it's i'm creating a blur here select and run it will create a blur node you can see when when i create this node this property window automatically open in the properties window there is one more code to create a node inside your new york dot nodes dot whatever the node class plus select this and then bam it will create a node if you want to get this node name you need to select this and go here print dot selector and you dot this it will print the selected node name okay let's move it to a bit more complex coding okay now if i want to move this node via python how can we do that one i need to use for loop function for this one so i'm saying like for n in nuke dot selector okay now i need to assign a new value to this node expose if i want to move in x direction so i will go n dot set expose so i have to give some value to move this one to assign a new value first i need to get this nodes x position value and then add my extra value and then re-assign that value into this node then this node will automatically move in x direction first we need to get this node's x position value n dot x position okay so with this we need to add our extra value i can say 100 plus and dot expose and i need to add on my clause bracket and then go here select this node and this command it is now moving 100 pixels in x position if i run this code again and again and again it will go in a plus direction you can use the same function without for loop for that you need to assign a value to this node and apply in the x position value to that node select this and run it will do the same function the difference between these two functions if i have multiple nodes and select if i run for loop function it will work for both nodes but this function will work only with one node will move into bit complex coding for that i need to create one mode close this property okay now i'm adding a transform node i want to scale this rectangle from the center so how do we do that take the pivot and move into center and we do the scaling okay but moving the pivot in the center it's a manual work so how do we automate that one for that we can utilize the new bounding box to find the center of this rectangle go here so as i said i can use like i'll use my name yes we've got milk dot selector not now we need to assign the values to the center knobs in this transform node i'll close this enter s and center that's the knob name for this one i am going to use set expression function set x ssi to get the bounding box value i need to use t cell function here i need to get the node name first dot box dot if i say x it will give me the x value of the bonding box if i say r it will give me the right side of the boundary mass values if i say okay my pivot moved here but this is not the center of this rectangle so how do you find that inside center of this rectangle for that we need to add a couple more maths first we need to minus the x value from the right side value i'm just plusing the bounding box right side value plus with the value of x and y division value okay here i'll say paste it again x minus r saying divided by 2 so what this will give us i will just remove this one first okay if i say okay our pivot move out of the or working resolution that's because we just divide these two values to get a proper center we need to plus the r value with this divided value if i say okay it will come in the center of the rectangle now we need to find the y value for that i already have a written math i'll just go here and copy this and put it here once i say okay it will come in the center how do we assign this function via python just go here and copy your expression and function i'm adding one more transform node and connect with this so we're going to assign this function to this transform node let's see what happened and i run this comment it will create the different result because when we assign this kind of expression it will assign both the knobs we haven't mentioned which knob it should assign so if we say zero then i will do like reset this node then i run this command again now you can see it will assign only in the x when i run this whole code by selecting this node and i run its assign the same function here and here so we got our pivot center automatically i hope all you enjoyed in the next video we going to see bit more complex python script which i made to help the artist in the day-to-day work i will discuss with you guys what are the requests i got from the artist how i planned that script how i made it work in the production so those kind of tricks we going to discuss in the next video until then see you bye peace [Music]
Info
Channel: Digital Compositing Tips & Tricks
Views: 6,380
Rating: undefined out of 5
Keywords: compositing, digital compositing, foundry nuke, nuke, nuke tutorials, nuke tutorial, compositing tutorial, green screen, despill tutorial, visual effects, comp, edge fixes, comp edge issues, compositing edge, nuke tips and tutorials, nuke tips tricks, nuke tips, python, python scripting, python for nuke, python for compositing
Id: GzxzJ9m-GSc
Channel Id: undefined
Length: 9min 27sec (567 seconds)
Published: Fri Oct 16 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.