Get value from ...

   1830   6   1
User Avatar
Member
26 posts
Joined: Nov. 2019
Offline
Hi!

Can somebody please tell me whats the expression to get a channel value from the currently processed input operator of an operators input list?

I mean those lists that usually operators like merge, switch, etc. have.

Thank you and greetings!
User Avatar
Member
26 posts
Joined: Nov. 2019
Offline
Heya! Is it bad explained what I've tried to ask?

Nobody knows, maybe?
User Avatar
Member
68 posts
Joined: Nov. 2021
Offline
If you're using a switch you can just read the attribute afterwards, because only the data of the active switch item will be processed anyway. I think a more detailed explanation what you're trying to achieve would be helpful.
User Avatar
Member
26 posts
Joined: Nov. 2019
Offline
Lets say I have multiple file operators in a switch and I want to get the file path with file name and file extension from the currently processed switch input as a string in a parameter of an operator thats placed somewhere in the tree after the switch.
User Avatar
Member
68 posts
Joined: Nov. 2021
Offline
here's a solution using VEX and hscript

string inputnode = chs('inputnode'); //get nodename connected to input 1 via opinput expression
string fullpath = '../' + inputnode + '/file'; //recreate relative path
s@filepath = chs(fullpath); //write to attribute

string filepathblocks[] = split(s@filepath, "/"); //split path into array using "/" as separator
s@filename = filepathblocks[-1]; //write filename from last item of array, with filetype
string filenameblocks[] = split(s@filename, "."); //split filename into array using "." as separator
s@filetype = filenameblocks[-1]; //write filetype from last item of array


int filetypelength = strlen(@filetype) + 1; //calculate length of filetype (number of characters)
s@filename = s@filename[:-filetypelength]; //remove filetype from filename

create spare parameter for the first string and input hscript expression
`opinput(".", 0)`

set wrangle to detail and place a wrangle after each file-node to write the attributes for each input.

as an example a file with the following path X:/Assets/Models/Skull/skull.objwould result in the following attributes
filename = skull
filepath = X:/Assets/Models/Skull/skull.obj
filetype = obj


as long as you dont delete any of the attributes you can then call them at any point in the stream. the easiest way to to do that is to rightclick into the channel you want the attribute to sample -> reference -> scene data -> find node with attribute (not itself, will error) -> attributes -> global -> attribute


since only one item gets processed with the switch, you automatically only have the attributes for the processed stream. if you want to use this with a merge, you could just change the wrangle type to points or prims and write point/prim attributes instead to keep track of the different inputs.

i dont know if there is a way with vex or hscript to go a certain number of nodes up the stream so you only need one wrangle after the switch but then again you would have to make sure you have the same amount of nodes in each stream before the switch. if you have a manageable amount of file nodes i think the solution above should work just fine.

hope this helps!
Edited by eaniix - Aug. 16, 2023 11:16:39
User Avatar
Member
26 posts
Joined: Nov. 2019
Offline
Alright I will try that! Thanks a lot!
User Avatar
Member
152 posts
Joined: Aug. 2012
Offline
eaniix
i dont know if there is a way with vex or hscript to go a certain number of nodes up the stream...

sure, you could use recursion to store nodes and get their inputs, but beware edge cases like reaching into loop/compile blocks.
  • Quick Links