PDA

View Full Version : Maya API question


jackyu00
06-03-2006, 07:40 AM
This is my code fragment, the purpose is to move each vertex 1 unit along Y axis for all select NurbsSurface. It compiled succeefully ,but doesnt work in Maya, anyone knows
what's wrong with it? Thanks a lot.

MStatus moveCV::doIt( const MArgList& args ) {
MStatus stat;
MSelectionList list;
MGlobal::getActiveSelectionList( list );
MItSelectionList iter( list, MFn::kNurbsSurface );
for ( ; !iter.isDone(); iter.next() )
{
MDagPath surface;
MObject component;
iter.getDependNode( component );
MItSurfaceCV cvIter( surface, component );
MVector vector(0.0,1.0,0.0);
if ( MS::kSuccess == stat ) {
for ( ; !cvIter.isDone(); cvIter.nextRow() )
{
for ( ; !cvIter.isRowDone(); cvIter.next() )
cvIter.translateBy( vector, MSpace::kWorld );
}
cvIter.updateSurface();
}
else
displayInfo( MString("Error creating iterator!") );
}
return MS::kSuccess;
}

jackyu00
06-03-2006, 06:05 PM
ok, I think I know where the problem is, "MItSurfaceCV" only takes MDagPath for argument,
my code should be corrected like this :

MStatus moveCV::doIt( const MArgList& args ) {
MStatus stat;
MSelectionList list;
MGlobal::getActiveSelectionList( list );
MItSelectionList iter( list, MFn::kNurbsSurface );

for ( ; !iter.isDone(); iter.next() )
{
MDagPath surface;
MObject component;
iter.getDagPath( surface );
MItSurfaceCV cvIter( surface, component );
MVector vector(0.0,1.0,0.0);
if ( MS::kSuccess == stat ) {

for ( ; !cvIter.isDone(); cvIter.nextRow() )
{
for ( ; !cvIter.isRowDone(); cvIter.next() )
cvIter.translateBy( vector, MSpace::kWorld );
}
cvIter.updateSurface();
}
else
displayInfo( MString("Error creating iterator!") );
}
return MS::kSuccess;
}

CGTalk Moderation
06-03-2006, 06:05 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.