 Howdy, guys. All right. So in this video, what I want to do is continue the Python projects here And I want to talk a little bit more about the shelf tools All right, so it's totally possible for us to actually create These types of shelf tools, right? If we actually just right click on any of these guys Just hit edit tool. You'll notice that it brings up this window that allows us to edit the contents of This particular shelf tool, right? We have these options. We have the script. All right So we actually can type in some Python, you know, that gets executed when you press this particular shelf tool button You can include a bunch of help Contexts and hotkeys. All right, so let's actually walk through the process of doing this on our own So I'm going to make my own new shelf. All right, I'm just going to call this indie pixel And indie pixel for the label Like so hit apply and accept so now I have a brand new empty shelf where I can put all of my own tools All right, so before we actually go and you know start writing some Python Let's actually look at a couple ways of basically saving out. I would call, you know, like presets Predefined sets of nodes. All right, so, you know in this case what I do a lot You know when I'm setting up a particle system or some sort of effect right off the bat As I always create an effect source. All right, so I just went and created a geometry container I need to do that by hitting tab on the keyboard and then just typing in Geometry and that will come up in the tab and you can hit enter and then just place it. All right So what I usually do is I'll go and create this, you know geometry container I'll put a sphere in there because I want to admit, you know from this particular source I'll set it to a polygon And then what I'll do is add a little bit of noise because usually we animate this stuff just to Create some variation in the actual effect. And then, you know, usually I don't want any particles emitted from the bottom So I'll clip this off like so So I'll use a clip node and then I'll use a polyfill node to fill the Open areas here and that's usually just because you know We convert this to a volume and then scatter a bunch of points in there. All right So I also like to go and just set this to single polygon All right, so, you know, that's the usual setup now what you can do with your own shelf tools Is you can take this setup now, right? So if I just hit you on the keyboard to jump up and out Of the network there what I can do is I can actually just click and drag this up to my shelf Like so and it'll create a button for this. So if I actually delete this now And just hit my button that I just created in the shelf it actually sets that back up formal So if I double click on that you can see everything is all set up All right, and that's because basically what it's doing is it's recording the set of actions, right? So if I were to actually right click on this new shelf tool that we created and use the edit tool option there and go to The script you can see that we go and Automatically generate a bunch of python code All right, so there's quite a bit of code now. It doesn't actually take this amount of code This is just the auto generated code that is generated by Houdini when you Click and drag a preset like that What we can do is we can actually make our own versions of these tools to set up the things that we want All right, so we can create, you know a preset If you will or some sort of network setup, but you can do a lot of stuff Really what I want to do is I want to now, you know, write my own python code to basically just reset up this network So we can practice our python a little bit more. So how do we go and make our own custom tool? All right So let's walk through the process. Okay, so let's come up to our shelf that we created I'm going to right click on it and say a new tool Right like so and I'm going to go to the options tab and I'm going to give this a name. So we're going to say create um, you know fx source like so And then Let's spell that correctly and then if I come down here We'll say fx source for the label. That'll be what's shown here in the actual Tab itself instead of new tool. It'll be fx source and we can also change the icon So you can make your own icon for it and you know load it up. It accepts most of the traditional image formats All right, so with that we are all set up. So I'm going to hit apply All right, so you can see now our label is set to fx source And uh, next what I can do is I can go and you know add some python in here Uh, I can also define my own help for this which I'll make in a separate video because uh, it actually uses a markup language To generate these help and it actually is styled in the format that you see When you go to the houdini help, right? So when we actually launch this so you can actually style it This way, but that requires another video All right, and we can go to the context and really I only want to create this when uh, this is actually in the Object context or the SOP level context here. All right, so I'm just going to click this obj here And then you can go and assign it to hotkeys. So let's actually focus on Creating the code here. So I'm going to double click the fx source here Just so I can see how the network is actually set up What I want to do is I just want to write the code necessary to set this same exact Network up. So the first thing that we want to do is we want to get the obj context and Then what we want to do is we want to create a geometry container. So I'm going to create a geocontainer All right, and so to do that all we need to do is we need to type out a variable name called obj All right, and it could be whatever name. I just type obj just so I know that this is getting the obj context And then we do who dot node. All right, so who is the base module For python inside of houdini. All right, so and then if you say node We're going to go and find a node and all we need to do is open up a parentheses like so and put two quotation marks and a forward slash and obj Like so and that basically gets me access To obj this this entire space here so I can place stuff Into that particular space. All right, so just to verify that let's actually create a new variable called Geo node and let's create our first node what I want to do is I want to create a geometry container And I want to name it effect source Okay, and so to do that we're going to say obj dot create node All right, just like we've seen before and we want to create a particular type of node here And if you come to any node inside of houdini inside of the network editor here And you click this little info button You can get the name of the node that you want to create right here All right, so that's the type that we're expecting so we want to type in geo right here So we say geo and then we do a comma and then we give it a name So in this case, I want to do effect source like so. All right, I'm going to apply Let's make this a little bit smaller. All right, so now that I've hit apply Let's go and actually click our button up here and voila. Look at that. We actually have a new Geometry container named effect source one because there's already a geometry container Named effect source. So it just increments it for you and inside of it. There's obviously nothing So well, we want to do let's actually delete that new one that was created and let's go and create all the nodes first Okay, so let's drop down here and I'm going to do two hashtags. That's how we comment stuff out inside of python Okay, so we need to create all the nodes All right, so let's first start by creating a sphere node So I'm going to say sphere node for the variable name because we actually wanted to store references To these nodes so we can set parameters on them and you know hook up their inputs automatically and stuff like that All right, so that's what we're doing. We're going to declare a variable here and I'm going to say it's going to be equal to the geonode All right, and the reason why we want to use the geonode Is because we want to put a node inside of it. All right, so currently You know in python world the reference to geonode is this particular geometry container All right, so we want to put a node in there. So we say geonode dot create node like so and We want to create a sphere. So again, if you ever want to find the type just hover over it and hit the info button and the type is sphere so easy enough so I say sphere And you know, you don't have to actually give it a name You know, we could give it, you know a name of like my sphere Or you could actually leave a blank All right, by default it'll just give it, you know, whatever name Houdini decides to choose and in this case It'll most likely be sphere. Okay So let's go and create the mountain node. So we'll say mtn node for mountain node And again, we want to put this inside of the geonode. So we'll say geonode dot create node like so Awesome And in this case, let's go look for the type. This was a weird one. This one's actually mountain colon colon 2.0 All right, so this is the second version All right, and that's how you do namespacing inside of Houdini is you use the two colons there They say 2.0 And again, I don't need to give it a name in this case All right, so let's go and create the clip node. So I say uh clip node equals equal to geonode dot create node Like so And this guy is clip. I believe yeah clip. There we go Oh, it's good to double check. All right Let's usually I'll go and set up a network or at least a rough network And then I'll I'll mimic it then kind of run from there You don't have to go and set everything up obviously, but In this case, this is a really simple example just to get you comfortable with the process All right, so let's look at the polyfill and this is you know polyfill for the type So we'll just make another node and I'm going to say fill node Is equal to geonode dot create node and we'll do polyfill Like so awesome. All right, so let's test this out now. We've gone that far Okay, so I'm going to hit apply and then hit the effect source button up our own custom tool here And take a look. All right, and so if I dive inside look at that. We have all the nodes now They're going to be situated right on top of each other Manually you can go in here and just hit l on the keyboard and that'll space them out But we can actually do that here inside of python as well The first thing I want to do though is I just want to get all the nodes all hooked up All right, so let's go and delete all these guys. We'll delete that guy there too And let's jump back into our example. And so what I want to do is I want to set the inputs All right, so I don't want to wire all these guys together Using python over here. So let's do that. We'll set all the inputs here And the way that we do this all right is we need to get Let's start out with a really basic example. So what I want to do is I want to use the mountain node And I want to use its set input function. Okay, so this is the way this works So we're going to say mountain node dot set input Like so All right, and the first argument is going to be the input to take in All right, and that's going to be zero and this is easy because there's only one input for this particular node So that's the index of that input in this case because there's only one it's zero Because they all started zero. It's a zero based index. Okay And we want to provide the node that we want to wire into it in this case. It's the sphere node All right, so here I'm going to put in sphere node And then finally the third argument that it requires is the output node and because there's only one We're just going to put zero Okay Cool, so let's hit apply and take a look at that So I'm going to hit effect source over here There's our new node and let's actually hit l on the keyboard and you'll notice that the sphere node is now hooked into the mountain node All right, and that's because we took the mountain node and we called it set input function And we said we want to hook up the first input with the sphere node And then set up the output of the first input All right in this case, we didn't really do anything Okay, so cool. We're on our way. So let's hook everything else back up. All right so we need to then take the clip node and say clip node dot set input like so and We need to type zero and the node that we want to pass into the clip node is the mountain node Like so and the output is at zero. All right. So then we need to take the fill node Dot set input We'll say zero for that first input and then we want to pass in the clip node. So we say clip node like so All right, so let's hit apply And test that out. All right, so I'm going to hit the effects source button our custom tool Let's move that off to the side here and dive in and hit l on the keyboard And look at that. We set up all of the network just like we had in the previous one that we did manually Awesome. So what I want to do now is I want to make sure that the display flag is all the way at the bottom All right, so that's pretty easy. I also want to make sure that we lay out the children. All right Or all the nodes I should say kind of gave it away there So what we need to do is we need to call the layout children Function that is available on the geo node. All right, so we say geo node dot layout Children like so You don't have to pass anything in it does accept arguments, but by default you don't have to pass anything in So now if I had to apply and hit the effect source button And then dive into my new one. You can see that they're already laid out for me Super cool all right, so now let's take care of the display flags. All right, so what I want to do is Set flags like so and I want to make sure that the fill node so I'm going to say fill node Dot set display flag. All right, so the display flag is the blue flag. All right, so we want to set that down here like so All right, so let's jump open out and I'm going to delete this here and finish off the code So we're going to set the display flag to be true. We just want it to be on All right, so let's see what that does You know apply and hit the Tool button there in the shelf and look at that now the polyfill node is turned on But it's left the render flag on the sphere node. So all we need to do is Get the sphere node here and say set render flag To false. All right, and make sure that these are capital for Python All right, so let's it apply and let's delete this guy and recreate it Like so And let's take a look and look at that. Everything is all set up perfectly Okay, so what we need to do now is set a few parameters So let me jump up and out using you on the keyboard And I'm going to delete this guy and jump back into my example So on the sphere node what it is I set the primitive type to polygon Now one thing to understand about these menu items here is that there's also zero based index. So Basically primitive would be zero Okay, so it would be equivalent to zero polygon would be one polygon mesh would be two three four five six. All right So what we want is polygon or one. All right, so let's set all of our parameters to get this guy going So I'm going to create a new comment here and say set Params Alrighty, let's actually make a little more space for ourselves too There we go. Cool. So now I'm going to say that the sphere node Dot harm Like so and we want to get the name of the parameter. So in this case If we hover over the parameter here, you can see the parameter name is type. All right, so let's type in type Type and we'll say set and we'll set that to one All right, you can also type in true if you want. I'm just going to leave it at one All right So now we're going to get the polygon type set So the only other thing that I think I really set by hand here was polyfill Mode so I set it to a single polygon here So in the polyfill node what I want to do is I want to do the same sort of Operation but I want to set this particular parameter and that parameter's name is fill mode All right, so all we need to do is go and get the fill node here Get the parameter that we want to set. All right, and that was again fill mode. Okay, so fill mode Like so and then we want to say dot set and we will set that to And what number is that so single polygon is zero? All right, so zero one two three four five So zero is what we want So it's automatically sets it to the single polygon type for us So let's hit apply and accept Jump up and out remember. This is our example and let's go and hit our new custom tool and Go inside and look at that. We get the basically the same results All right, so the sphere is set to polygon polyfill is set to single polygon Awesome, we got all these nodes all hooked together all created So now any time I want a new source for you know some particles or maybe some You know pyro effects I can just hit this and I have the setup automatically created for me All right, so that's what I wanted to show in this video. Hope you guys like it. Thanks so much