[VEX] How to setdetailattrib() to a dictionary?
3446
2
1
Andr
Member
899 posts
Joined: Feb. 2016
Offline
Dec. 7, 2020 6:29 p.m.
I need to build a detail dictionary with key/values from point attributes.
Ideally something like this in a point wrangle would work:
setdetailattrib (0 , d@mydict [itoa (@ptnum )], myvalue , "append" );
The offender is the second argument of course, as it is expecting a string.
Edited by Andr - Dec. 8, 2020 07:30:01
Andr
Member
899 posts
Joined: Feb. 2016
Offline
Dec. 8, 2020 7:34 a.m.
So I managed to do it from a detail wrangle with a for-loop.
My only question: is there a more direct way to assign the key values without using the intermediate dummy array?
for (int i =0 ; i <@numpt ; i ++)
{
string key = point (0 , "key" , i );
int dummy [] = d@mydict [key ];
append (dummy , i );
d@mydict [key ] = dummy ;
}
Attachments:
point att to dict.JPG (96.4 KB)
trzanko
Member
24 posts
Joined: Oct. 2015
Offline
May 15, 2024 5:22 a.m.
Can also be done via set() and insert():
In a detail wrangle:
string names [] = { 'foo' ,'bar' ,'foobar' } ;
float vals [] = { .123 ,.234 ,.345 } ;
d@myDict ;
for ( int i = 0 ; i < len ( names ); i ++)
{
string thisName = names [i ];
float thisVal = vals [i ];
insert (d@myDict ,set ( thisName , thisVal ));
}
Tighe Rzankowski trzankofx@gmail.com