Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Maya® / SDK / C++ Maya API - Get an attribute's value?
  RSS 2.0 ATOM  

C++ Maya API - Get an attribute's value?
Rate this thread
 
38143
 
Permlink of this thread  
avatar
  • wiegje
  • Posted: 26 December 2009 02:36 AM
  • Total Posts: 12
  • Joined: 18 August 2009 05:52 PM

Hi,

I want to get the value of an attribute. How do I get that? I can’t find anything on it.



Replies: 0
avatar
  • geofffox
  • Posted: 26 December 2009 10:15 AM

In the MEl input field, for example:
getAttr polySurface1.tx;
my MEL knowledge is very rusty, so won’t say more…



Replies: 0
avatar
  • wiegje
  • Posted: 26 December 2009 11:20 AM

I was talking about the C++ version :)

I’m looking up the MFnAttribute of the shader node, like so:

// Custom Hardware Shader found!
 
if(srcnode.hasFn(MFn::kPluginHwShaderNode))
 {
 MFnDependencyNode shader(srcnode)
 MFnTypedAttribute typedAttr(shader
.attribute("s"))

// ... etc

However, I can’t seem to find the functions to get the VALUE of the attribute. It does find it, but what I need is the file name of a custom hardware shader that the user added. I can’t seem to find the function that I need.



Replies: 1
/userdata/avatar/m24b74v2v_yacht6.jpg

Oh..in that case...I have no idea...:)

Author: geofffox

Replied: 26 December 2009 12:10 PM  
avatar
  • wiegje
  • Posted: 26 December 2009 12:18 PM

Who makes this crap up?

MFnDependencyNode shader(srcnode)
MPlug shaderplug(srcnode, shader.attribute("s"))
MString shaderstring;
shaderplug.getValue(shaderstring)

So for everyone else getting suicidal over the API:
1. Create a dependency node from your node that you’re traversing.
2. Create a “plug” (seriously guys… what the hell)
3. Plug the “plug” “into” the node and the attribute you got out of the dependency node…
4. Get the value from the “plug”

REALLY? What ever happened to: shader.attribute("s").getValue(outString)



Replies: 0