Yorkst Posted November 2, 2015 Share Posted November 2, 2015 I created some boxes with copy node. I added an attribute "class" to each primitive by connectivity node. Primitives of the same class belong to the same box. I try to do two things: 1)Add every primitive with class x to a group "box_x" 2)Add every primitive, a blue component of color of which is greater than 0.1, to group "big". (Every box is scaled according to its color) To do it, I iterate with ForEach over values of "class". Each node is called "in" There is a file attached with all three cases. This compiles and works: 1) Group name: box_`prim("../in",0,"class",0)` Expression: all primitives 2) Group name: big Expression: $CB>0.1 This does not compile: 1) Group name: box_`$CLASS` This compiles, but threats blue component as 0: 2) Group name: big Expression: prim("../in",0,"Cb",0)>0.1 Why does prim work inside group name, but doesn't work inside expression field in this particular case? Why does $ behave the opposite way? connectivity.hipnc Quote Link to comment Share on other sites More sharing options...
f1480187 Posted November 3, 2015 Share Posted November 3, 2015 (edited) 1) box_`$CLASS` I have no idea, why $CLASS works inside expression or pattern fields and not works inside group name field. I use user variables once in a century by this reason. Since you are iterating over class' values, it can be changed to: box_`stamp("../..", "FORVALUE", 0)` 2) prim("../in",0,"Cb",0)>0.1 Just a typo, there is no Cb primitive attribute. prim("../in", 0, "Cd", 2) > 0.1 $CB > 0.1 @Cd.b > 0.1 All three will work. The third one is a new Houdini 15's analog to second one. Looks like the most limited at current moment, working only on subset of existing locals, which are limited too. Use them for simplicity, but generally, first expression is better. 3) Useful expressions working inside For-Each Subnetwork SOP: stamp("../..", "FORVALUE", 0) # While iterating over scalar values. stamp("../..", "FORVALUE3", 0) # While iterating over vectors, to get third value (e.g blue in RGB color). stamps("../..", "FORVALUE", "") # While iterating over strings (e.g over name attribute). stamp("../..", "FORIDXVALUE", 0) # To get for loop's "i" variable. Edited November 3, 2015 by f1480187 Quote Link to comment Share on other sites More sharing options...
anim Posted November 3, 2015 Share Posted November 3, 2015 1. no need for foreach SOP, just append Partition SOP after your connectivity and into Rule type: box_$CLASS however it's much better to keep it as class (or creating name attribute ) than generating hundreds of groups 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.