Ended up using blinddata to specify what objects part of mesh should belong to and then a new command that grabs the outmesh and creates the new objects from the blind data.
And dummy attributes with setAttr to only recompute when i want.
Now i am having some new problems in the command that creates new objects.
I am trying to assing per polygon shaders but all polygons get the same shader. None of my status checks reports any errors.
This is the code:
MFnSet shaderSet;
MFnSet shaderSet2;
stat = shaderSet.setObject(innerSG);
std::cout << stat << std::endl;
stat = shaderSet2.setObject(outerSG);
std::cout << stat << std::endl;
MItMeshPolygon itPolygon(dagPathnewMesh);
for ( ;!itPolygon.isDone(); itPolygon.next() )
{
std::cout << objects[i].shader[itPolygon.index()] << std::endl;
MObject currentPoly = itPolygon.currentItem(&stat);
std::cout << "get poly object: " << stat << std::endl;
if(objects[i].shader[itPolygon.index()] !=-1)
{
stat = shaderSet.addMember(dagPathnewMesh, currentPoly);
std::cout << stat << std::endl;
}
else
{
stat = shaderSet2.addMember(dagPathnewMesh, currentPoly);
std::cout << stat << std::endl;
}
}
The first assigned shadinggroup to a polygon is the final result for all.