any examples of detailattrib?

   5276   11   1
User Avatar
Member
82 posts
Joined: Aug. 2006
Offline
so I can add a detail attribute, but I can't seem to read it back. the attribute is being written, I can see it in my geometry spreadsheet, but I can't seem to be able to read it.

I can add it:
adddetailattrib(0, “DontPanic”, 42);

I try to read it:
http://www.sidefx.com/docs/houdini/vex/functions/detailattrib [www.sidefx.com]

I get ambiguous call errors.

I have looked at the help but its no help, I really wish sidefx would add examples to their help, it mostly looks like auto-generated help which seems to just repeat itself and not be very helpful.

here is a help file with a small example, this is immensely helpful and I wish more examples, even short ones, existed.
http://www.sidefx.com/docs/houdini/vex/functions/hasdetailattrib.html [www.sidefx.com]

and yes, i can test and see that my detail exists lol. I just can't seem to get it to tell me what the heck the value is.
User Avatar
Member
82 posts
Joined: Aug. 2006
Offline
ok figured it out, i think the help actually confused me more than if i just guessed at the answer.

int test = detailattrib(0, “DontPanic”, 0, 0);
User Avatar
Member
82 posts
Joined: Aug. 2006
Offline
so this is related, i want to read my detail value back in to a for loop, any pointers? thanks!
User Avatar
Member
8223 posts
Joined: Sept. 2011
Offline
don't use those, use detail() to read from non-detail context, setattrib to write from non-detail context, and use binding so read/write in detail context. There are rare cases where you might not want to use bindings, but they usually very specific, and have to do with non knowing the name of the attribute to be written beforehand.

addattrib() is only used to create an attribute, and doesn't actually set the value. It is mostly obsolete, since bound attributes are created if they don't exist, and setattrib() also creates attributes that don't exist.
User Avatar
Member
82 posts
Joined: Aug. 2006
Offline
jsmack
don't use those, use detail() to read from non-detail context, setattrib to write from non-detail context, and use binding so read/write in detail context. There are rare cases where you might not want to use bindings, but they usually very specific, and have to do with non knowing the name of the attribute to be written beforehand.

addattrib() is only used to create an attribute, and doesn't actually set the value. It is mostly obsolete, since bound attributes are created if they don't exist, and setattrib() also creates attributes that don't exist.

I'm sorry i dont understand, i can make a detail attribute, set the detail attribute, even check to see if it exists. what i can't figure out how to do is read the detail attributes values. is this a new feature that people haven't used much yet? it looks like it was added in 15?
i want to read the detail attributes so i can use them in for-loop counts/etc
i also want to use them for storing metadata i can write out for use in a separate program. it looks like just the thing i need but i can't find examples of anyone actually using it for anything.
User Avatar
Member
2177 posts
Joined: Sept. 2015
Offline
Maybe you should post an example that's giving you the problem.

If your problem is from using the same function you noted in a previous post….

int test = detailattrib(0, “DontPanic”, 0, 0);

The last argument of that function - which in your case you put 0, needs to be a variable of int type( could be attribute of type int too ).

The function needs to return a value to that argument, 1 or 0 depending on if it was successful or not.

So, it should look something like this if that's the function you want to use:
// DetailType should be the declared type of the Detail your trying to get.
DetailType My_Fetched_Detail;
int My_Function_Succeeded;
My_Fetched_Detail = detailattrib(0, “DontPanic”, 0, My_Function_Succeeded);
Edited by BabaJ - Feb. 13, 2018 09:28:50
User Avatar
Member
82 posts
Joined: Aug. 2006
Offline
ah, that worked. i didnt realise i needed a variable to store if it succeeded or not. It makes sense since it will return the results if it succeeded and you need a mechanism to detect failure.

so is there a way to access a detail attribute to use in something like a for loop?

if i were to make an attribute called “DontPanic” i can call it in my forloop like this:


is there a way to access the objects details to get a value to feed into here?

thanks
Edited by asmischney - Feb. 13, 2018 11:17:34

Attachments:
2018-02-13_10-14-56.jpg (23.0 KB)

User Avatar
Member
2177 posts
Joined: Sept. 2015
Offline
Sorry..can't help you with loops using nodes…I do my loops with wrangles
User Avatar
Member
8223 posts
Joined: Sept. 2011
Offline
asmischney
jsmack
don't use those, use detail() to read from non-detail context, setattrib to write from non-detail context, and use binding so read/write in detail context. There are rare cases where you might not want to use bindings, but they usually very specific, and have to do with non knowing the name of the attribute to be written beforehand.

addattrib() is only used to create an attribute, and doesn't actually set the value. It is mostly obsolete, since bound attributes are created if they don't exist, and setattrib() also creates attributes that don't exist.

I'm sorry i dont understand, i can make a detail attribute, set the detail attribute, even check to see if it exists. what i can't figure out how to do is read the detail attributes values. is this a new feature that people haven't used much yet? it looks like it was added in 15?
i want to read the detail attributes so i can use them in for-loop counts/etc
i also want to use them for storing metadata i can write out for use in a separate program. it looks like just the thing i need but i can't find examples of anyone actually using it for anything.

You could read the post. You are using the archaic version of the function that passes success back. Use the simpler detail() function:

int myvar = detail(1, "value")
User Avatar
Member
8223 posts
Joined: Sept. 2011
Offline
BabaJ
Sorry..can't help you with loops using nodes…I do my loops with wrangles

The two are not even remotely connected. You can't multi-thread a loop in a wrangle. You can't execute sops, or read back your results if you loop in a single vex block.
User Avatar
Member
2177 posts
Joined: Sept. 2015
Offline
The two are not even remotely connected. You can't multi-thread a loop in a wrangle. You can't execute sops, or read back your results if you loop in a single vex block.

I didn't mean or imply that.

There was no context ( he didn't supply a hip file to actually show what he intended to do ).

All I saw was reference to looping using a node, of which, I say again - don't really know how to use.

I did know he was wanting use detail attribute function/s and use loops.

I do that all the time - so in the context I was thinking, yes the two are related.
Edited by BabaJ - Feb. 13, 2018 14:30:59
User Avatar
Member
82 posts
Joined: Aug. 2006
Offline
thanks much everyone, please excuse my ignorance it's only my 30th day inside houdini and the learning curve is a bit on the steep side. I am chugging along but sometimes i hit things and its a wall. Part of the problem is i dont know how to formulate my question, as y'all have your own “houdini speak”
thanks again for the help, I hope ot pay it forward.

in case others stumble here…
another houdini user at work helped me out and this works:
detail(“../NodeIMadeTheDetailAttributeWith/”,“DontPanic”,0)
Edited by asmischney - Feb. 14, 2018 16:37:48
  • Quick Links