API 2.0 and Dynamic attribute

135 views
Skip to first unread message

miarmy

unread,
Apr 29, 2018, 4:21:18 AM4/29/18
to Python Programming for Autodesk Maya
Hi...I couldn't create a dynamic attributes in api 2.0.
In the api 1.0 we can use this code :
OpenMaya.MPxNode.addAttribute(createdAttribute, OpenMaya.MFnDependencyNode.kLocalDynamicAttr)


justin hidair

unread,
Apr 29, 2018, 1:13:16 PM4/29/18
to Python Programming for Autodesk Maya

I have never used dynamic attributes , but from what I saw in the devkit (example on dynamic attributes), it is fairly simple , all you need is to overload setDependentsDirty() and predict what attributes are going to pop

Marcus Ottosson

unread,
Apr 30, 2018, 12:12:27 AM4/30/18
to python_in...@googlegroups.com

This works for me.

from maya.api import OpenMaya as om

fn = om.MFnDagNode()
mobj = fn.create("transform", "MyTransform")

fna = om.MFnNumericAttribute(mobj)
attr = fna.create("longName", "shortName", om.MFnNumericData.kDouble, 1.0)
fna.storable = True
fna.writable = True
fna.readable = True
fna.keyable = True
fn.addAttribute(attr)

On 30 April 2018 at 02:13, justin hidair <justin...@gmail.com> wrote:

I have never used dynamic attributes , but from what I saw in the devkit (example on dynamic attributes), it is fairly simple , all you need is to overload setDependentsDirty() and predict what attributes are going to pop

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/1ba158b4-da55-451c-866d-96150afbdbfc%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages