Referring to attr values inside node class



I’m currently trying to print the value of an attribute during compute:

loc = dataBlock.inputValue(ADANode.location).asString()
 print loc

But I’m getting some weird hex stuff being printed to the console:

How do I get the value of the attribute in a form I can use? is there a way I can convert the output?

Furthermore, within the node class init I am simply declaring:

self.tloc = ""

But when I try to concatenate I get:
TypeError: print ( "Old location: " + self.tloc): cannot concatenate ‘str’ and ‘PySwigObject’ objects

This really confuses me. Is Maya doing something to my datatypes that I don’t want it to? How can I fix this?



when you create instances of an object, printing the object just prints the objects memory address. (I think that’s what that hex is anyway :slight_smile: )

those hex address you’ve shown tell you the object type is an MString object, so to print the “value” of it, you need to access the method or attribute of that object (or use another class) that prints or stores the value, but I’m not that familiar with the API classes, so you’d have to check the API docs for MString. (or wait for someone else to answer! :smiley: )



After a lot of searching I found an old forum post with the answer. Solution was to do this:

dataHandle = dataBlock.inputValue( ADANode.location )
data =
loc = om.MFnStringData(data).string()


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.