Jump to content
bonassus

foreach loop iteration file path

Recommended Posts

Posted (edited)

How can I loop through texture map names in a foreachloop. I thought this should work with a spare parameter:

H:/Assets/1x/Asset_`detail(-1,“iteration”,0)`.png

 

Capture.JPG

Edited by bonassus
added image

Share this post


Link to post
Share on other sites

Hey! There are a few things with your expression that might be messing it up. The first is in your detail expression. I don't know what "-1" is meant to be pulling data from, but when using the "point", "prim" or "detail" expression in hscript we usually feed it the absolute or relative path to a node instead of feeding it inputs like we do in vex. For example "/obj/geo1/foreach_begin1_metadata1" or like in your spare parameter "../foreach_begin1_metadata1". That should be enough to fix it, at least it seems to work for me in my little test scene, but if not then the second thing you could also try is to splice the strings together with the "strcat" hscript function. Since you are splicing together things before and after an expression it might look a little messy but something like this:

`strcat(strcat("H:/Assets/1x/Asset_",detail(-1,“iteration”,0)),".png")`

Hope some of that can help you fix your issue!

Share this post


Link to post
Share on other sites

Thank you for your reply. I didn't realize that spare parameters were not used with expressions like this. I have used -1 to reference the metadata node in the past with out a problem. Thank you for suggesting the strcat function. Unfortunitly I couldn't make my expression work. It's starting to become quite messy. I've decided to use another approach with material overrides. 

thanks again for you time in answering my question I do apricate it. 

Share this post


Link to post
Share on other sites

Hi bonassus,

I tried out the forloop with a file sop, and the expression is able to evaluate the iteration value with no problem, excuse the error because I didn't create any files.

image.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×