What I want to do is create a script (I presume python) to import x amount of files, create a node for each, and link them all into a switch node.
For context: I am trying to create a picture frame tool in which I can import all images in a given folder, create a picture frame using the image bounds, and randomize the image using a copy stamp and switch node. I want the script to automatically import the images and pipe them into the switch node.
I have been using Houdini for about a year now but have not delved into python in Houdini, so any pointers on where to start to achieve this would be much appreciated!
Need help creating a basic import script
2230 5 0- dankmochi
- Member
- 6 posts
- Joined: May 2017
- Offline
- goldfarb
- Staff
- 3459 posts
- Joined: July 2005
- Offline
do you want to do this with a script?
I think you could cook something like this up with COPs…
just off the top of my head:
make a folder of images with names like ‘whatever_1.png’, ‘whatever_2.png’ etc
make a COPnetwork
go inside an put down a File COP
browse to the folder and select the first image -> whatever_1.png
change the file path to be whatever_$F.png
now when you step forward on the timeline the pictures will change…
you could also make a spare parameter on the node and use a channel reference to drive the image number
if your images have different resolutions you can get that info
now you can get the size of the image with a reference…
and use that to drive the size of your frame.
ah well…here is something to get you started.
if you did want to make a python script to do something like this then I guess we can give it a try.
I think you could cook something like this up with COPs…
just off the top of my head:
make a folder of images with names like ‘whatever_1.png’, ‘whatever_2.png’ etc
make a COPnetwork
go inside an put down a File COP
browse to the folder and select the first image -> whatever_1.png
change the file path to be whatever_$F.png
now when you step forward on the timeline the pictures will change…
you could also make a spare parameter on the node and use a channel reference to drive the image number
if your images have different resolutions you can get that info
now you can get the size of the image with a reference…
and use that to drive the size of your frame.
ah well…here is something to get you started.
if you did want to make a python script to do something like this then I guess we can give it a try.
- dankmochi
- Member
- 6 posts
- Joined: May 2017
- Offline
I appreciate the response and example hip!
I considered doing it this way with a $F function but couldn't think up a way to hold the frame for each image that is instanced (so that the images aren't cycling through the frame range.) I also don't know how I would create shaders for each image (redshift) with the $F variable or any other method that doesn't require manually creating individual shaders. The only way I'm aware of automating the creation of nodes is with python, but I'm no expert! If I can use a similar method as in your example to automate the shader process then that would be great too!
If my solution does require python, would you recommend going from the ground up to learn Python in Houdini or does this maybe fall into a certain category of scripting that in could go straight into? I'm watching python in houdini tutorials but have yet to find one that brings me closer to my solution.
Thanks!
I considered doing it this way with a $F function but couldn't think up a way to hold the frame for each image that is instanced (so that the images aren't cycling through the frame range.) I also don't know how I would create shaders for each image (redshift) with the $F variable or any other method that doesn't require manually creating individual shaders. The only way I'm aware of automating the creation of nodes is with python, but I'm no expert! If I can use a similar method as in your example to automate the shader process then that would be great too!
If my solution does require python, would you recommend going from the ground up to learn Python in Houdini or does this maybe fall into a certain category of scripting that in could go straight into? I'm watching python in houdini tutorials but have yet to find one that brings me closer to my solution.
Thanks!
- goldfarb
- Staff
- 3459 posts
- Joined: July 2005
- Offline
as I said, you could also make a spare parameter on the node to drive the changes from one image to another - just replace the $F with `chs(“nameOfParm”)`
the same can be done with the texture parameter of a shader.
this is the kind of thing that can get you started with python without having to learn it from the beginning (but that is still a good idea) because you can hunt around for the bits that you need and make something work.
the same can be done with the texture parameter of a shader.
this is the kind of thing that can get you started with python without having to learn it from the beginning (but that is still a good idea) because you can hunt around for the bits that you need and make something work.
- dankmochi
- Member
- 6 posts
- Joined: May 2017
- Offline
I am not completely following your last response. Are you suggesting that i use 1 shader inside of a redshift vop which reads an attribute (“ex:nameOfParm”) that I stamp? This seems fairly staightfoward! My only problem now is that my images have various aspect ratios, and in cops, my image is defaulting to the first image's aspect ratio!
I appreciate the help!
Ryan
I appreciate the help!
Ryan
- addysmith
- Member
- 6 posts
- Joined: Aug. 2018
- Offline
-
- Quick Links