How to add variable in File node name

   2923   8   2
User Avatar
Member
46 posts
Joined: Oct. 2019
Offline
Hi, What's the best way to add variable in File node.
I have files that need to be load depending of the frame. I created wrangle with list of file name. But I don't know how to "send " my names into file node name attribute.
Anyone can help with this? Thx

string fileName[] = {'$HIP/file/F001.obj', '$HIP/file/F025.obj', '$HIP/file/F75.obj'};
s@fileName = fileName[@Frame-1];
Edited by tosiho19 - Nov. 30, 2021 02:38:37

Attachments:
fileName.PNG (48.3 KB)

User Avatar
Member
2528 posts
Joined: June 2008
Online
There is a global variable called $F. This holds the current frame number. You can use the back tick character to execute hScript inside a text field, so something like this may work for you.

Type this into the Geometry File name:
$HIP/my_geo/the_file_`padzero(4,$F)`.obj
The obvious flaw is that is won't work with your array of filenames, because those files name have no common zero padding. This type of filename creation is used more often when trying to load a sequence over time.
Edited by Enivob - Nov. 30, 2021 10:35:58
Using Houdini Indie 20.0
Ubuntu 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
46 posts
Joined: Oct. 2019
Offline
Thanks @Enivob, However using $F doesn't really solve my problem as I need to load files with different names.
User Avatar
Member
2528 posts
Joined: June 2008
Online
Another way is to place your wrangle in detail mode and fetch the value of the attribute using a function, instead of a direct reference to the attribute name.

Type this into the Geometry File name: (adjust the path to match the path to your wrangle)
`details("/obj/geo1/File_List/","fileName")`
Notice the backticks. They are required for the function to be evaluated.
Edited by Enivob - Nov. 30, 2021 10:41:54
Using Houdini Indie 20.0
Ubuntu 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
7737 posts
Joined: Sept. 2011
Offline
This type of task is also more or less what tops was made for. It might be overkill for certain trivial cases, but it scales in complexity better than using sop attributes.

Attachments:
file_pattern.hip (239.2 KB)

User Avatar
Member
46 posts
Joined: Oct. 2019
Offline
@Enivob, Thanks! that's what I was looking for, but I didn't know how to properly write the function
User Avatar
Member
88 posts
Joined: Feb. 2021
Offline
Hello,

It seems that after the 19.5 update, I'm no longer able to use backticks in filenames ?
Pressing the name of the field doesn’t change what is rop doesn't render when I put

$JOB/render/$HIPNAME/render_`@pdg_index`.$F4.jpg

As name, but renders fine if I just put $JOB/render/$HIPNAME/render.$F4.jpg
Edited by TangheStudent - Aug. 16, 2022 06:14:02
User Avatar
Member
7737 posts
Joined: Sept. 2011
Offline
TangheStudent
Hello,

It seems that after the 19.5 update, I'm no longer able to use backticks in filenames ?
Pressing the name of the field doesn’t change what is rop doesn't render when I put

$JOB/render/$HIPNAME/render_`@pdg_index`.$F4.jpg

As name, but renders fine if I just put $JOB/render/$HIPNAME/render.$F4.jpg

Are you evaluating a topnetwork?
User Avatar
Member
88 posts
Joined: Feb. 2021
Offline
If I Dirty and cook the node, it gets stuck when it arrives at the saving.
This doesn't happen if I don't use `@pdg_index`.

Am I missing a step ?

The clicking of the name not showing me the path it points to also doesnt work with just.

$JOB/geo/boat.obj
Edited by TangheStudent - Aug. 16, 2022 06:12:57
  • Quick Links