Hi
I have an attributewrangle:
if (@primnum < 15) {
concat(“@group_”, chs(“groupname”));
}
This doesn't work and produces no group.
How can i concatenate “@group_” with the user input chs(“groupname”) ?
Is it possible to build @group_groupname programatically?
-b
VEX concatenate @group_ + chs()
5935 9 3- bonsak
- Member
- 459 posts
- Joined: Oct. 2011
- Offline
- Enivob
- Member
- 2540 posts
- Joined: June 2008
- Offline
Remember, concat will return a result. You are discarding the result.
Try something like this…
// Primitive index.
int index = 1;
string result = concat(“group_”, chs(“group_name”));
addprimattrib(geoself(), result, index, “some_value_here”);
Note: if the attribute does not exist you use addprimattrib. if it does exist you use setprimattrib.
setprimattrib(geoself(), result, index, “some_value_here”,“set”);
Try something like this…
// Primitive index.
int index = 1;
string result = concat(“group_”, chs(“group_name”));
addprimattrib(geoself(), result, index, “some_value_here”);
Note: if the attribute does not exist you use addprimattrib. if it does exist you use setprimattrib.
setprimattrib(geoself(), result, index, “some_value_here”,“set”);
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
- bonsak
- Member
- 459 posts
- Joined: Oct. 2011
- Offline
Thanks. The problem with addprimattrib is that it doesn't add a group (at least not in the attributewrangle), it just add an attribute with the name “group_mygroup”
If i use the virtual variable @group_mygroup = 1; i get an attribute(group) with the name of group:mygroup listed in the spreadsheet.
-b
EDIT:
substituting the underscore with a colon makes it work:
int index = 1;
string result = concat(“group:”, chs(“groupname”));
addprimattrib(geoself(), result, index, “set”);
EDIT2:
I was wrong. Doesn't work with colon.
If i use the virtual variable @group_mygroup = 1; i get an attribute(group) with the name of group:mygroup listed in the spreadsheet.
-b
EDIT:
substituting the underscore with a colon makes it work:
int index = 1;
string result = concat(“group:”, chs(“groupname”));
addprimattrib(geoself(), result, index, “set”);
EDIT2:
I was wrong. Doesn't work with colon.
- sidenimjay
- Member
- 702 posts
- Joined:
- Offline
- bonsak
- Member
- 459 posts
- Joined: Oct. 2011
- Offline
Thanks. I've tried that as well. @group is not a string so it errors with:
Call to undefined binary operator ‘string = float + string’
It's kind of un logical that @group_groupname is a float. I expected it would be an int.
I've also tried with:
s@my_group = “@group” + “_” + chs(“groupname”);
But that results in an attribute called my_group with the value set to “_bound_group_mygroup”
So it's not as easy as it seems.
-b
Call to undefined binary operator ‘string = float + string’
It's kind of un logical that @group_groupname is a float. I expected it would be an int.
I've also tried with:
s@my_group = “@group” + “_” + chs(“groupname”);
But that results in an attribute called my_group with the value set to “_bound_group_mygroup”
So it's not as easy as it seems.
-b
- sidenimjay
- Member
- 702 posts
- Joined:
- Offline
- bonsak
- Member
- 459 posts
- Joined: Oct. 2011
- Offline
- cwhite
- Staff
- 733 posts
- Joined: Oct. 2012
- Offline
- Enivob
- Member
- 2540 posts
- Joined: June 2008
- Offline
You could just add a fixed name attribute such as “my_group” to the spreadsheet. Then populate it with the number. At this point you could just use the standard Group node to fetch items based upon that value.
Type in Group name field.
@my_group==0
Type in Group name field.
@my_group==0
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
- bonsak
- Member
- 459 posts
- Joined: Oct. 2011
- Offline
-
- Quick Links