Krion Posted October 2, 2019 Share Posted October 2, 2019 Hi, I would like to import a whole folder of images and use them for randomness effects / iterate over them / etc. But it is no images and they are all named differently. Is this possible? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
StepbyStepVFX Posted October 2, 2019 Share Posted October 2, 2019 (edited) You want to import them where ? In COPs by creating nodes that read random omages in a folder (so as many nodes than images ??) ? Or do you want to generate a path attribute on geometry or parameter on a node that takes random values among all the path and image names of a folder ? In both cases, Python is the answer. Otherwise, is they are named sequentially already in your folder, you can easily rebuild a string that match that in VEX. We probably need more info on what you want to achieve precisely to guide you. Edited October 2, 2019 by StepbyStepVFX Quote Link to comment Share on other sites More sharing options...
Krion Posted October 2, 2019 Author Share Posted October 2, 2019 (edited) I want something like this: To import a whole folder of images and be able to have a parameter that goes through them (like you can with the "Select Input" parameter on a switch). And then I wanted to use a Trace SOP on it, but now I see that the Trace SOP has no input, but only a file-path parameter itself.. Hope it is possible in VEX because that I know a bit. Can you also 'rebuild a string' in VEX when they have the same prefix, but not numbered sequentially? Like: Person.Bob.jpg Person.Jane.jpg Thanks again. Edited October 2, 2019 by Krion Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted October 2, 2019 Share Posted October 2, 2019 Hi Dave, you could feed the trace SOP with image file paths from a python node: import os import glob node = hou.pwd() node_tracer = hou.node('../trace1') dir = node.evalParm('dir') num = node.evalParm('num_img') path = hou.expandString(dir) os.chdir(dir) files = glob.glob('*.jpg') total_num = len(files) - 1 num = max(min(total_num, num), 0) image = files[num] node_tracer.parm('file').set(image) read_image_folder.hipnc 1 Quote Link to comment Share on other sites More sharing options...
Krion Posted October 2, 2019 Author Share Posted October 2, 2019 Hi Magnus, How would that work? What do I fill in here? I have already chosen a directory. Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted October 2, 2019 Share Posted October 2, 2019 1 minute ago, Krion said: What do I fill in here? Nothing. The python script should fill it. If it does not replace the 2nd but last image line with: image = path + files[num] read_image_folder_fullpath.hipnc Quote Link to comment Share on other sites More sharing options...
Krion Posted October 2, 2019 Author Share Posted October 2, 2019 Thank you. It works. Also had to connect the python node under the trace. Great! I quickly need to learn Python too. How good do you think you need to be in VEX before you tackle Python? Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted October 2, 2019 Share Posted October 2, 2019 22 minutes ago, Krion said: How good do you think you need to be in VEX before you tackle Python? As long as your Python usage is only about listing files, setting parameters, creating nodes and such I don't think you have to wait. The language has very little to do with VEX anyway. I mainly put together my python scripts by combining results from stackoverflow, odforce threads and SideFX's documentation. 1 Quote Link to comment Share on other sites More sharing options...
ashu_tosh_m Posted May 31, 2021 Share Posted May 31, 2021 On 3/10/2019 at 1:15 AM, konstantin magnus said: As long as your Python usage is only about listing files, setting parameters, creating nodes and such I don't think you have to wait. The language has very little to do with VEX anyway. I mainly put together my python scripts by combining results from stackoverflow, odforce threads and SideFX's documentation. any idea how to import cache sequence from multiple folder using python. Basically i wedge a simulation and i want to import all cache once and add a switch node to select the best output Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.