Pancho Posted February 2, 2016 Share Posted February 2, 2016 Coming from SI I'm used to set variables in ICE by set data > self.variable = value Depending on the context I create the variable in it's either per point, per polygon, etc. or per object. In case I need to access variables in Houdini inside a geometry from different nodes (per object in SI), how do I set this up? I know that I can acces values from a node by using ch("../node/entryField"). IS this the way to go or would I use something else do have it floating around in the geometry? In my case I want something like a panel in which I can set up all values needed inside the geometry node, e.g. width, height, subdivisions of the object which gets created inside the node. Which node would I use for this and which kind of referencing is best for this task? Thanks for some input! Tom Quote Link to comment Share on other sites More sharing options...
Atom Posted February 2, 2016 Share Posted February 2, 2016 (edited) In Houdini, self is a context and variable is an attribute. I would us an Attribute Wrangle to write VEX code to access attributes. By providing a path to the API calls you can effectively reach outside of your current context and fetch data from all over the network across context boundaries. You can add parameters/channels to the Attribute Wrangle as well. This way that node becomes your 'panel'. If you start setting up relative pathing to access channels on other nodes your panel can not be moved out of that context without addressing/breaking the references you have established. For instance you can pull in the scatter count from a scatter node from any context with this code. string scatter_path = "op:/obj/geo_target/scatter1"; // Path to our scatter database of attributes. int scatter_count = npoints(scatter_path); // Number of points in the scatter. npoints is one of the API calls I mention above. Other functions: http://www.sidefx.com/docs/houdini15.0/expressions/_index Edited February 2, 2016 by Atom Quote Link to comment Share on other sites More sharing options...
Pancho Posted February 2, 2016 Author Share Posted February 2, 2016 Not sure if I totally get you. E.g., I need this width parameter for the geometry. I want a "central" node in which I can write the value (attribute wrangle?). Then this value is needed in a transform node (x-offset) and an attribute vop (import with bind?). Looking at the attribute wrangle node I typed in float width = 0.25 (run over set to "detail (only once) In the transformation or a box node I type into a field @width or $WIDTH Neither works. I'm able to do quite a lot of stuff in H already, but some concepts still didn't get through to me yet. In SI I use set data > self.blablabla and get data > self blablabla That's the way I'm thinking after years of ICE. But in H it seems to be different. You propose to use the attWrangle as the get or set node? From the code it looks like it is a get node, but I need the value in an entry field of the node as described above. So I still need some info. Thanks so far! Quote Link to comment Share on other sites More sharing options...
rich_lord Posted February 2, 2016 Share Posted February 2, 2016 Ive attached a file which is the simplest version of what you describe. Dive inside the Box1 node. In there is a box node and a null node. Ive changed the name of the null to CTRL and colored it red. I added 3 extra parameters to the null node called width, height and depth. You can add these by clicking the gear icon at the top right of the parameter pane. I then reference these parameters in the box1 node with a ch expression which points to that data on the CTRL node. The expression looks like this for width ch("../CTRL/width) There's many ways to do this. Pulling data from different parts of a network, and between contexts is one of the trickier things in Houdini when starting out. Is this what you are asking? Or did you want something more complex? using_null_parms.hip Quote Link to comment Share on other sites More sharing options...
Atom Posted February 2, 2016 Share Posted February 2, 2016 (edited) This syntax creates a variable that is local in scope and can not be referenced outside the wrangle. float width = 0.25; This syntax will create an attribute on the current geometry within the context that the wrangle is running over (i.e. point, primitive, detail etc...) f@width = 0.25; You can just add parameters, which are not attributes, to a NULL and then reference them via ch("../my_watever"). But in some cases you can't write to them from VEX, they are read-only but animatable. Edited February 2, 2016 by Atom Quote Link to comment Share on other sites More sharing options...
Pancho Posted February 2, 2016 Author Share Posted February 2, 2016 Thanks to you both. Will take a closer look tomorrow. Just in general, from what I'm feeling, I'd like to have a box floating around. The box is named width. Inside this box is a value. 0.25. So, now everybody who want to know what inside this box can look inside of it and can get this value. I don't care if this is a particle, point, polygon, primitive, vop, ..... who wants to do this. This value, in my eyes, doesn't have a context. It's just a floating point scalar value. Now, there's the reality of H and it's hard to tell if you are new to something how it is actually done. Guessing from Richards post I need to know that this value is inside a box (or null or other node). So everytime I want to know this value I need to look inside the box, reference it by name. I thought that this value could be floating around in the ether and I just need to call "width" and the echo will be "0.25". The value would be penetrating all regions inside of Houdini, like a global variable. Not sure if this is a good way in terms of programming, but it sounds comfortable. Where I'm struggling currently is to grasp the concept of data exchange inside of H and how to do it practically. I'll try out both tips as soon as my work horse is powered on and let you know how far I'm getting. Thanks so much so far! Quote Link to comment Share on other sites More sharing options...
rich_lord Posted February 2, 2016 Share Posted February 2, 2016 I don't think you can make a variable global like you want. Its not too bad though, I like having my `global` variables stored in as parameters on a node as you end up with a big controller node at the end of a project from where you can set everything. It ends up with you being very organised as your network gets bigger. You can make the NULL node at obj level also, and just reference from there. Thats handy for parameters you want to use alot, like a global random seed for example. The paths end up getting pretty long though. Quote Link to comment Share on other sites More sharing options...
nosferatu_037 Posted February 2, 2016 Share Posted February 2, 2016 Just go to Edit->Aliases/Variables->Variables tab Enter the name of your variable, enter the value, say name foo value 0.25 And in any context you should be able to access that variable on a global level as a $FOO. it will always return 0.25. Its an ok thing to do however you usually want to make your assets or setups know about these variables from the parent node containing the setup, rather than the Global Alias/Variable. Its going to be very difficult keeping track of all of those global constants you have and you dont have an easy enough access for a typical user to change the value. Quote Link to comment Share on other sites More sharing options...
LukeLetellier Posted February 3, 2016 Share Posted February 3, 2016 (edited) Just go to Edit->Aliases/Variables->Variables tab Enter the name of your variable, enter the value, say name foo value 0.25 And in any context you should be able to access that variable on a global level as a $FOO. it will always return 0.25. Its an ok thing to do however you usually want to make your assets or setups know about these variables from the parent node containing the setup, rather than the Global Alias/Variable. Its going to be very difficult keeping track of all of those global constants you have and you dont have an easy enough access for a typical user to change the value. I would say that this technique is best used for things like project wide texture paths or variables relevant to your system, and not project specific data like the width/height of a box or the pscalevalue of a point set. Edited February 3, 2016 by LukeLetellier 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.