CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 12-24-2012, 02:54 AM   #1
luizeliasvfx
New Member
portfolio
luiz elias
dneg
london, United Kingdom
 
Join Date: Mar 2012
Posts: 19
MPxContext to MPxManipulatorNode values

Hello,

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)
manip.addAttribute(manip.someValue)

and inside my context I set it:

depNode = OpenMaya.MFnDependencyNode(manipObject)
plug = depNode.findPlug('someValue',0)
plug.setFloat(20.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!
 
Old 01-07-2013, 03:22 PM   #2
Keilun
Expert
Keilun
Canada
 
Join Date: Aug 2005
Posts: 729
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:

Code:
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.

Last edited by Keilun : 02-05-2013 at 10:18 PM.
 
Old 02-04-2013, 02:45 PM   #3
luizeliasvfx
New Member
portfolio
luiz elias
dneg
london, United Kingdom
 
Join Date: Mar 2012
Posts: 19
hi Keilun,

thank you very much!

I have just tried that and it works perfectly!
 
Old 02-04-2013, 02:45 PM   #4
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 08:50 AM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.