Wrangle Data
Strings
Float to Strings
vector nodecimals = @P * 100;//s@uniqueId = sprintf("%02d", nodecimals.x);string pos = sprintf("%02d", nodecimals.x) +";"+ sprintf("%02d", nodecimals.z);s@uniqueId = "["+pos+"]";
% is the substitution, 02d the padding
Append to array in detail
int sel_prims[] = {5, 21};// this workssetdetailattrib(0, "sel_prims", sel_prims, "append");// also worksforeach (int sel; sel_prims){ setdetailattrib(0, "sel_prims", sel, "append");}
Matrix to dictionary
// Prepare a dictionary for json export// umatrix -> unity json matrix4x4dict umatrix;
int mat_size = 4;
for (int row = 0; row < mat_size; ++row){ for (int col = 0; col < mat_size; ++col){ float comp_val = getcomp(4@transform, col, row); int icol = col*10 + row; string scol = sprintf("m%02d", icol); umatrix[scol]=comp_val; }}d@umatrix = umatrix;
Dictionary in detail
Build a dict
// Move to detailint num_layers = nuniqueval(0, "point", "layer_name");string unique_layers[] = uniquevals(0, "prim", "layer_name");//end detail
d@layer_cd = {};
foreach (int index; string layer ; unique_layers){ vector rand_color = random(index); d@layer_cd[layer] = rand_color;}
Read in prim mode
dict layers = detail(0, "layer_cd", 0);string layer_name = prim(0, "layer_name", @primnum);vector color = layers[layer_name];@Cd = set(color.x, color.y, color.z);
Write array as string
s@Nbg = "[";int num_nbg = len(i[]@Neighbors);
for (int i=0; i < num_nbg ; i++){ int n = i[]@Neighbors[i]; s@Nbg += i < num_nbg - 1 ? itoa(n)+"," : itoa(n);
}s@Nbg += "]";