Instancing creation Problem

Instancing creation Problem

Anonymous
Not applicable
206 Views
0 Replies
Message 1 of 1

Instancing creation Problem

Anonymous
Not applicable
Hiya
So one of our artists didnt like using instances and we came up with a naming convention for the exporter. Howerver the maya file has got way too big (surprise surprise), so I wrote a plugin to got through the file, find all the instances using our naming convention, and turn these things into actual maya instances.
Heres the part where I duplicate the master object instance and replace the instance with it:

MFnDagNode instNode(dagPathList); //this is the named instnace

MObject parent = instNode.parent(0, &stat);
MFnDagNode parentNode(parent);
if(stat == MS::kSuccess)
MGlobal::displayInfo( MString("got parent ") + parentNode.name() );
else
continue;

MFnDagNode originalNode(originalInstPath); //this is the master instance, a dagpath

MObject duplicate = originalNode.duplicate(true, false, &stat);
if(stat == MS::kSuccess)
MGlobal::displayInfo( "created duplicate" );
else
continue;

stat = parentNode.addChild(duplicate);

MFnTransform dupTrans(duplicate);
MFnTransform origTrans(dagPathList);
dupTrans.set(origTrans.transformationMatrix());
if(stat == MS::kSuccess)
MGlobal::displayInfo( "added child" );
else
continue;

stat = parentNode.removeChild(instNode.object());

if(stat == MS::kSuccess)
MGlobal::displayInfo( "removed original" );
else
continue;


MDGModifier Modifier;
stat = Modifier.deleteNode(instNode.object());
if(stat == MS::kSuccess)
MGlobal::displayInfo( "deleted original" );
else
continue;


I create a duplicate, add it to the instanced object's parent, set the transform, remove the old object and delete it. All looks good in the scene. I click on an instance shape and see many things light up in the view. However when I save the file out it is still the same whopping size! Is there something else I need to do?
Any help or advice much appreciated.
0 Likes
207 Views
0 Replies
Replies (0)