View Full Version : MPxContext to MPxManipulatorNode values

12 December 2012, 02:54 AM

I have an MPxManipulatorNode attached to a MPxContext,
in my context doPress() function I get some value
and I want to be able to pass that value to the MPxManipulatorNode
so I can draw something with it, but I can't find a way to pass that value to the manip.
I've tried to add an attribute to the MPxManipulatorNode:

def manipInitialize():
nAttr = OpenMaya.MFnNumericAttribute()
manip.someValue = nAttr.create( "someValue", "sv", OpenMaya.MFnNumericData.kFloat)

and inside my context I set it:

depNode = OpenMaya.MFnDependencyNode(manipObject)
plug = depNode.findPlug('someValue',0)

but when I try to retrieve this value inside my manipulatorNode draw function:

fnThisNode = OpenMaya.MFnDependencyNode(self.thisMObject())
value = OpenMaya.MPlug(self.thisMObject(), fnThisNode.attribute("someValue")).asFloat()

I get this error:
# Warning: Node type 'TdependNode' is abstract. Cannot create. #

any ideas why?
or a different way to do that??
many thanks!

01 January 2013, 03:22 PM
The way I've done this in the past is to just use your standard class accessor/mutator interface. Create a mutator function like 'void setRadius( float val )' or whatever your data represents and invoke it after you've created your manipulator in your context. For example:

MString myManipName = "myManip";
myManipClass* myManip = NULL;
MObject myManipObj;
myManip = (myManipClass*) myManipClass::newManipulator( myManipName, myManipObj );
if( myManip )
// Set any values on your manipulator here from your context.
myManip->setRadius( myRadius );
myManip->connectToDependNode( myDepNode );
addManipulator( myManipObj );

Hope this helps.

02 February 2013, 02:45 PM
hi Keilun,

thank you very much!

I have just tried that and it works perfectly!

CGTalk Moderation
02 February 2013, 02:45 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.