I am trying to replace primitives by their centroid point within an attribute wrangle node, inheriting all their attributes.
So I read the detail intrinsic “primitiveattributes” and loop over this array
I can create the points, with attributes, but I can't get the attribute types and dimension right
For instance Cd gets created, but is only one dimension instead of three
Any idea how to achieve this ?
Thanks
B
Here is my code:
// add point at primitive center
int ptnum = addpoint(geoself(), @P);
// get primitive attributes list
string primattribs[] = detailintrinsic(geoself(), "primitiveattributes");
// for each attribute get type, name and value and create point attribute
foreach(string attribname; primattribs)
{
string typeinfo = attribtypeinfo(geoself(), "prim", attribname);
int attribsize = attribsize("defgeo.bgeo", "prim", attribname);
float attribvalue = prim(geoself(), attribname, @primnum);
addattrib(geoself(), "point", attribname, 0.0);
setattribtypeinfo(geoself(), "point", attribname, typeinfo);
setattrib(geoself(), "point", attribname, ptnum, @primnum, attribvalue, "set");
}
// remove primitive
removeprim(0, @primnum, 1);