 Howdy guys, IndiePixel here, and in this next video in the intro to Python series for Houdini I wanted to dive a little deeper and show you guys how we can go about automating the exports of all these particular barrels. So what I did is I went ahead and just created a really basic procedural barrel here. All right, and I promoted a bunch of parameters here So we can go and change some of these values. It looks like I forgot to hook one of those guys up Let me actually see here, and it looks like I'm just doing the wrong one. There we go All right, so now we've got you know our procedural barrel I can change you know quite a few of the the properties here, but this particular video is not necessarily about creating HDAs it's about using Python to automate it. So Let's just set up the the case or the scenario here so basically I've got a bunch of HDAs over here a bunch of barrel assets that I've gone ahead and created using an HDA a bunch of different variations. All right, and so each one of these basically represents a barrel, and I've gone and changed you know the parameters just so I have different variations of each of these. All right, and now instead of having to go and you know export each one of these I went ahead and I created a tab on the HDAs up here that allows me to go and export the FBX file to Unity. All right, so this is the path to my Unity project Okay, so if we come over here to Unity you can see I have all my barrels in here, and I really don't want to Have to go through let's say I have like a hundred of these barrels all different variations I don't want to have to go and select each one of these and hit export basically We can use Python to go and automate all of that. All right So what I'm going to do is I'm going to come in here, and I'm just going to blow these guys away Just so we start fresh and blow these guys way out of the the hierarchy view there All right, and we're going to go back into Houdini and Let's start with a new scene. So I'm going to go and save this guy. All right, cool now Let's go and create another version of that barrel, so I'm going to import that digital asset and I placed it Inside of my Desktop here. Let's go to there we go And we have assets and there is my HDA. So I'm going to import and create this So install and create awesome. So now I have a barrel. All right So let's just go and create some variations and the noise on this guy is a little bit high for me All right, and let's go and add maybe another set of rings there I will call that good for that guy. All right So what I'm going to do is just go and alt click and drag to make a copy of this So now we have another barrel. Let's turn that guy off and let's go and make this one like a blue barrel Like so we'll put this back down to a height of one All right, maybe we say it just has the four rings. All right, so let's make another copy All right, so the whole idea here is that I'm just making a bunch of variations. I'm going to go and make this guy red and Maybe we'll adjust the fall off a little bit on this guy And maybe intensify the noise a little bit Yeah, well, it's pretty good when we add lots of rings to this one Awesome. All right, we'll do one more variation So now we have barrel four Cool. Let's make this one kind of tiny. So we'll do a point eight. Let's turn this guy off so we can see it and Let's go and make this one. I don't know Like a maybe a really Orangish color like that Yeah, I think that'll work for now. Let's make actually turn down some of those guys awesome And I have kind of a stumpy one So now we have a bunch of barrels here that we want to export to our game engine now It's totally possible because I don't really only have four here It's totally possible to come in here and just go and export and stuff like that but we can actually automate that with the script so let's go and Let's come in here and launch the Python source editor Alright, so just like we did in the last video We went and created a Function inside of the who.session module. Alright, so we're basically going to do the same thing We're just going to keep it simple. All right, we're not going to dive into creating user interfaces You know, like a floating window or anything like that. Let's just keep it basic for now So we can understand what's happening with the code. So I'm going to write out def We're going to say export all barrels something like that. All right So now we've got our functional setup and what I need to do first is I need to get access to the obj Object. All right, so we at least need to get access to this space right here where all these nodes exist And that's obj. So again to do that, we're going to type out the variable name obj. All right We're going to store obj the obj node inside of this variable. We're going to say who dot node And we're going to type out obj Like so sort of say obj And there we go All right, so now inside of that what I want to do is I want to find out What nodes are basically inside of obj? Okay and to do that. It's actually quite simple. We can say We and we're also going to have to store all this stuff too. So we can say children. All right, that's the variable name And we're going to say obj dot children Like that And with that we basically have everything all set up so I could go in here and I could say print children Just to see what we get. All right, so I'm going to hit apply on that and Then I'm going to say who dot session down here in the Python shell. Okay Who dot session dot export all barrels And look at that we get a list of all the barrels that are contained within the obj Space all right, so we have access to all that now What we want to do here is we want to loop through each one of those nodes now and basically Press the export button Automatically all right Instead of having to go through manually and press that I just want to roll through all these nodes since I have access to them Now inside of this children variable. I just want to go through and press that button using Python Okay, so first let's set up a for loop. So we're going to say for node and children All right, that's your Standard for loop inside of Python right there and we're basically saying for all the children inside of This variable. All right, we're going to store it into node So each for each one of the nodes that are in here. So we're going to loop through each one We're going to sort in node which means then that we can get access to The nodes parameters down here. Okay, so first let's um Let's make a variable called node name and I'm going to call this node dot name Or I'm going to get the name from the current node that we're on and let's just print that so we can see what the result is So we're going to say print node name like so hit apply And then down here in the Python shell just hit up once to get to your last Function call and look at that. I have the name of each of the barrels All right, so we can now work on each barrel Individually and do a lot of things. I mean you can interface with all these parameters through Python In this case what we're going to do is we're going to set our output path and then we're going to hit the button Okay, so to do that before we actually go and export it We need a location. Okay, and I'm just going to hard code that into my Python code just for this example Obviously, you'd want to be able to change that dynamically. So that's when you're going to need some sort of UI For this. All right, so let's just go into Unity over here and I'm going to go Select my barrels folder here, and I'm just going to say show and explore that way I can get the the path here to all that. All right, so I'm going to select that path Or just do a ctrl-c to copy it and I'm going to go back to Houdini over here and we are going to say we're going to create another variable We're going to call this path And that's going to be equal to that path that we just copied. All right And we're gonna have to make sure all these guys are all changed so we get the proper padding for this again You know, I'm just keeping this really basic You're gonna you would want to you know in an actual production. You'd want to set this to be a dynamic All right, and I want to make sure that I send it to the barrels folder. So I'm just gonna do that awesome cool, so now let's come down down to our for loop down here and Let's start to put together the final path for all these guys, okay? So I'm going to say final path is equal to our path plus our node name All right plus Dot fbx. All right. I need to put that there so we it knows that we're going to export this to an fbx file All right, so let's print that now. We're gonna say final path for the print function hit apply Come down to our python shell hit up on the keyboard once And look at that. We now have all the paths. All right, so we're gonna send our Fbx files once each node is done exporting it. We're gonna send it over to unity Okay, awesome. So with that final path information in place, what we need to do is we need to access this parameter Okay, and to do that we need to know what the name of this parameter is So in this case the parameter is sop output All right, so if you just hover over any of these guys you can find what the parameter name is and that that's that internal name that we need Okay, so to set that particular path on the node We're gonna say over here in our Python source editor. We're gonna say node All right that parm for parameter. All right, and we are gonna go and say Dot set and we actually need to put in the name here first before we set it So remember that parameter was sop output like so we're gonna say dot set and we're gonna set it to our final path How cool is that? All right, and I'm actually gonna just comment that out for now So I'm gonna hit apply and we're gonna go and test this out So if everything goes well, we should get a proper path for each one of our nodes now without having to set it manually All right, so let's try this out So I'm gonna come back down to the Python shell hit up once hit enter and look at that all the nodes now have their proper export paths Super cool So all we need to do now is just go and basically hit this button Okay, so how do we do that? We're gonna say node dot parm All right, so we need to get the name of that parameter this button parameter that parameter is execute Okay, so we just type that in here. So you say execute and we say for a button parameter We have to utilize the press button function. Okay, so we say press button like that Cool, we're gonna hit apply and with that all done. We should have our automated exporting all Finished up so I'm gonna hit up once in the Python shell and hit enter And you can see it took a little bit longer, right? It kind of hung there for a little bit So if I go to unity now You can see we just exported all of our barrels Pretty cool. So all these guys now need all their materials hooked up We could actually go and Over to the model here and I'm gonna have to set this to a hundred now. Obviously you can do that Inside of your HDAs as well. All right for the materials I'm gonna go and just set this because I created a material using amplify to Basically just shade each with these objects with their vertex colors, you know just something simple for now So I'm just gonna go to the third one here and assign the material under the fourth and sign the material there Awesome. So with that we can go now. Just drag and drop those into the scene and Just space it out a little bit All right, pretty cool stuff and that my friends is how you go about Automating your export now. Obviously. This is a very very simple example but hopefully gives you a little bit of insight and how to start to work with parameters using Python how to you know Set up your automated pipelines for your games You can have a lot of functions inside of Houdini here inside of the session module So you could say maybe this particular hip file is your prop scene Okay, and you can go for and look for all HDAs that are of type barrel, right? Because remember all of your HDAs have an internal name as well. So you could look for that type You know, we could come over here actually and do that. So I don't need to export again. So I'm just gonna Comment those two out so we could do is we could say something like node type Just print that hit apply And you could see that the node type is IP barrel 01. All right, that's that name So you could look for that specific name. That's the internal HDA name All right, so this could be your your props hips seen and you could have all your exporting stuff up here And then basically use the Python shell to fire it off or you could make a shelf for this You know just have have your little shelf like we went over in the last video You can go and hit the button and it would export all your barrels And let's say you had you know a bunch of I don't know crates You could have another tool up here that says export all your crates kind of thing So with that I'm gonna leave you guys there Hopefully that helped you guys out a little bit and gave you a little more inside about Python and how to use it inside of Houdini Super powerful and I mean like I said, we really only scratch the surface. This is just a very basic example So thanks so much guys. I really appreciate all the support. See you soon