[VEX] How to setdetailattrib() to a dictionary?
3536
2
1
Andr
Member
899 posts
Joined: 2月 2016
Offline
2020年12月7日 18:29
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 - 2020年12月8日 07:30:01
Andr
Member
899 posts
Joined: 2月 2016
Offline
2020年12月8日 7:34
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: 10月 2015
Offline
2024年5月15日 5:22
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