MStatus ObjectParameterHandler::doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const { IECore::ObjectParameterPtr p = IECore::runTimeCast<IECore::ObjectParameter>( parameter ); if( !p ) { return MS::kFailure; } /// Keep trying all the available handlers until we find one that works 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( plug, parameter ) ) { return MS::kSuccess; } } } MStatus s; MObject plugData; s = plug.getValue( plugData ); if (!s) { // We might be here as the attribute isn't storable, // in that case we set the parameter to its default value. // If it is storable, then something has gone awry. MFnAttribute fnA( plug.attribute() ); bool isStorable = fnA.isStorable( &s ); if( s && !isStorable ) { parameter->setValue( parameter->defaultValue()->copy() ); return MS::kSuccess; } else { return MS::kFailure; } } MFnPluginData fnData( plugData, &s ); if (!s) { return MS::kFailure; } ObjectData *data = dynamic_cast<ObjectData *>( fnData.data( &s ) ); if (!data || !s) { return MS::kFailure; } parameter->setValue( data->getObject() ); return MS::kSuccess; }