Accessing Ramp Attribute within compute()

86 views
Skip to first unread message

Sebastian Schoellhammer

unread,
Oct 19, 2010, 3:36:00 AM10/19/10
to maya...@googlegroups.com
Hello again!

I'm working on a custom loft-style node as a scripted plugin.
One thing I wanted to do is having a Ramp Control the silhouette of the loft.

I added the MRampAttribute via:

MakeChain.overallScaleRamp = om.MRampAttribute.createCurveRamp("overallScale", "overallScale")
MakeChain.addAttribute(MakeChain.overallScaleRamp)       
MakeChain.attributeAffects( MakeChain.overallScaleRamp, MakeChain.outputMesh);

And I even managed to write a template that shows the little graph as well. Wow!

My last problem is though how to finally access the attribute in compute. 

Usually getting attributes is convenient via the data handle (.asFloat()) but in this case it's not that easy I guess.. :/

I tried to do create the attribute within compute as in:
ramp = om.MRampAttribute(self, self.overallScaleRamp)

but that doesn't seem to be any good...

Any hints?

seb

Sebastian Schoellhammer

unread,
Oct 20, 2010, 3:57:35 AM10/20/10
to maya...@googlegroups.com
Ok!!

Chad Vernon was so kind and pointed me in the direction of the following scripted plugin (cool!):
http://vimeo.com/13150202

( which uses a ramp :) )

and luckily it comes with source! So if anybody runs into this, this is how it works:

thisNode = MakeChain.thisMObject(self)
suOverallScale = om.MScriptUtil()
overallScaleValue = suOverallScale.asFloatPtr()
overallScaleHandle = om.MRampAttribute(thisNode, self.overallScaleRamp)
overallScaleHandle.getValueAtPosition(spacing*i/curveLength, overallScaleValue)
overallScale = om.MScriptUtil().getFloat(overallScaleValue)

Yay!
--
Sebastian Schoellhammer

Sr. Technical Artist
Square Enix LTD
www.square-enix.com

Sachin Shrestha

unread,
Oct 20, 2010, 10:22:44 AM10/20/10
to maya...@googlegroups.com
Awesome! Thanks for sharing. I can't believe its free along with the source code (while similar plugins are on sale).

-Sachin Shrestha
Reply all
Reply to author
Forward
0 new messages