Discussion:
[Maya-Python] MPlug.isKeyable isn't saved with the scene
Marcus Ottosson
2018-07-17 18:11:08 UTC
Permalink
Hi all,

Hiding an attribute from the channel box can be done with..

from maya import cmds

node = cmds.createNode("transform")
cmds.setAttr(node + ".translateX", keyable=False)

And the equivalent from the API..

from maya.api import OpenMaya as om

fn = om.MFnDagNode()
mobj = fn.create("transform")
mplug = fn.findPlug("translateX", False)
mplug.isKeyable = False

But! Upon saving and reopening the scene, the hidden state persist with
cmds.setAttr, but not with isKeyable = False. Tested in Maya 2015, SP6.

Any idea how I can have it be saved with the scene?

Best,
Marcus
​
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCiE65wDA8CiB2mUVhhqOf2rbyAd%2BkKH8fCn4UimW-gVw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Justin Israel
2018-07-17 19:46:47 UTC
Permalink
Post by Marcus Ottosson
Hi all,
Hiding an attribute from the channel box can be done with..
from maya import cmds
node = cmds.createNode("transform")
cmds.setAttr(node + ".translateX", keyable=False)
And the equivalent from the API..
from maya.api import OpenMaya as om
fn = om.MFnDagNode()
mobj = fn.create("transform")
mplug = fn.findPlug("translateX", False)
mplug.isKeyable = False
But! Upon saving and reopening the scene, the hidden state persist with
cmds.setAttr, but not with isKeyable = False. Tested in Maya 2015, SP6.
Does "mplug.isChannelBox = False" be have the same way with not saving the
state with the scene?
Post by Marcus Ottosson
Any idea how I can have it be saved with the scene?
Best,
Marcus
​
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCiE65wDA8CiB2mUVhhqOf2rbyAd%2BkKH8fCn4UimW-gVw%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCiE65wDA8CiB2mUVhhqOf2rbyAd%2BkKH8fCn4UimW-gVw%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3ADbdXjPz6MJNnYjgX_FWh1Hhb9B2Cio5drywD2M91LA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Marcus Ottosson
2018-07-17 21:24:10 UTC
Permalink
Some further investigation, it looks like this only happens on *dynamic*
attributes, which is where I originally had the probelm, and doesn’t
actually happen in my example of translateX (which isn’t dynamic).

Here’s a reproducible.

from maya.api import OpenMaya as om

cmds.file(new=True, force=True)

fn = om.MFnDagNode()
mobj = fn.create("transform", "myName")
cmds.addAttr("myName", ln="size", keyable=True, at="float")
mplug = fn.findPlug("size", False)
mplug.isKeyable = False

cmds.file(rename="temp.ma")
cmds.file(save=True, type="mayaAscii")
cmds.file("temp.ma", open=True, force=True)

Following this, you should find a transform node myName with a size
attribute in the Channel Box. However, if you replace isKeyable with setAttr,
it’s hidden as expected.

from maya.api import OpenMaya as om

cmds.file(new=True, force=True)

fn = om.MFnDagNode()
mobj = fn.create("transform", "myName")
cmds.addAttr("myName", ln="size", keyable=True, at="float")
cmds.setAttr("myName.size", keyable=False)

cmds.file(rename="temp.ma")
cmds.file(save=True, type="mayaAscii")
cmds.file("temp.ma", open=True, force=True)

You can also see in the resulting .ma file that when setting isKeyable on
translateX, it makes an entry involving setAttr -k off. However, when
setting it for a dynamic attribute like size, it doesn’t make that.

What’s interesting is that, what *does* happen for a dynamic attribute is
that when calling setAttr(keyable=False) it modifies the original addAttr
command, from..

createNode transform -n "myName";
addAttr -ci true -k true -sn "size" -ln "size" -at "float";

To..

createNode transform -n "myName";
addAttr -ci true -sn "size" -ln "size" -at "float";

See the missing -k true? So even though I passed keyable=True to the
original addAttr from Maya, Maya is “smart” enough to know that if you also
change the keyable state with an additional setAttr command, it edits the
one previously added.

Setting isKeyable = False doesn’t affect the resulting ascii file at all.

Smells like a bug.
​
Post by Justin Israel
Post by Marcus Ottosson
Hi all,
Hiding an attribute from the channel box can be done with..
from maya import cmds
node = cmds.createNode("transform")
cmds.setAttr(node + ".translateX", keyable=False)
And the equivalent from the API..
from maya.api import OpenMaya as om
fn = om.MFnDagNode()
mobj = fn.create("transform")
mplug = fn.findPlug("translateX", False)
mplug.isKeyable = False
But! Upon saving and reopening the scene, the hidden state persist with
cmds.setAttr, but not with isKeyable = False. Tested in Maya 2015, SP6.
Does "mplug.isChannelBox = False" be have the same way with not saving the
state with the scene?
Post by Marcus Ottosson
Any idea how I can have it be saved with the scene?
Best,
Marcus
​
--
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
To view this discussion on the web visit https://groups.google.com/d/
msgid/python_inside_maya/CAFRtmOCiE65wDA8CiB2mUVhhqOf2r
byAd%2BkKH8fCn4UimW-gVw%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCiE65wDA8CiB2mUVhhqOf2rbyAd%2BkKH8fCn4UimW-gVw%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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
To view this discussion on the web visit https://groups.google.com/d/
msgid/python_inside_maya/CAPGFgA3ADbdXjPz6MJNnYjgX_
FWh1Hhb9B2Cio5drywD2M91LA%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3ADbdXjPz6MJNnYjgX_FWh1Hhb9B2Cio5drywD2M91LA%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODiSfsDEG%3DSm%3DcbpfrFb3_po7hSwM%3DfytxoXhnQE6S6yw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...