MStatus MeshParameterHandler::doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const { IECore::ConstObjectParameterPtr p = IECore::runTimeCast<const IECore::ObjectParameter>( parameter ); if( !p ) { return MS::kFailure; } MFnMeshData fnData; MObject data = fnData.create(); /// \todo Pull in userData from parameter to set up conversion parameters ToMayaObjectConverterPtr converter = ToMayaObjectConverter::create( p->getValue(), MFn::kMeshData ); assert(converter); bool conversionSuccess = converter->convert( data ); if ( !conversionSuccess ) { return MS::kFailure; } /// \todo It seems like this can occassionally fail, usually with an empty mesh, but sometimes not. Try to establish exactly why. plug.setValue( data ); return MS::kSuccess; }
MStatus ObjectParameterHandler::doSetValue( IECore::ConstParameterPtr parameter, MPlug &plug ) const { IECore::ConstObjectParameterPtr p = IECore::runTimeCast<const IECore::ObjectParameter>( parameter ); if( !p ) { return MS::kFailure; } // Keep trying all the available handlers until we find one that works. /// \todo Investigate whether we can do a parameter->getValue() here and just get the handler which represents it for (IECore::ObjectParameter::TypeIdSet::const_iterator it = p->validTypes().begin(); it != p->validTypes().end(); ++it) { ConstParameterHandlerPtr h = ParameterHandler::create( *it ); if (h) { if ( h->doSetValue( parameter, plug) ) { return MS::kSuccess; } } } MStatus s; MFnPluginData fnData; MObject plugData = fnData.create( ObjectData::id ); assert( plugData != MObject::kNullObj ); s = fnData.setObject( plugData ); assert(s); ObjectData* data = dynamic_cast<ObjectData *>( fnData.data(&s) ); assert(s); assert(data); data->setObject( p->getValue()->copy() ); return plug.setValue( plugData ); }