visibility attribute is using stepped tangent when I code it to use linear

12 views
Skip to first unread message

likage

unread,
Jun 24, 2019, 2:41:18 PM6/24/19
to Python Programming for Autodesk Maya
Hi everyone, I am trying to set some keyframes on the attributes pythonically but noticed that only the "visibility" attribute is touched upon, both the `inTagentType` and `outTagentType` are not factored into account.

Eg. in my code, I have sent them to be keyframed with linear tangents, but for the visibility attribute, it comes out as stepped.
Here is a snippet of my code:

from maya import cmds
loc = cmds.spaceLocator(name="test")
loc_tx = "{0}.translateX".format(loc[0])
loc_vis = "{0}.visibility".format(loc[0])

# At Frame 1
cmds.currentTime(1)
cmds.setKeyframe(loc_tx, inTangentType="linear", outTangentType="linear")
cmds.setKeyframe(loc_vis, inTangentType="linear", outTangentType="linear")

# At Frame 10
cmds.currentTime(10)
cmds.setAttr(loc_tx, 10)
cmds.setKeyframe(loc_tx, inTangentType="linear", outTangentType="linear")
cmds.setAttr(loc_vis, 0)
cmds.setKeyframe(loc_vis, inTangentType="linear", outTangentType="linear") # This will still returns me in stepped tangent

The only method that I can conform the visibility curve to use linear tangent is to run the following line after the above code block:
(it is almost the same code when I uses `setKeyframe`)
cmds.keyTangent(loc_vis, edit=True, inTangentType='linear', outTangentType='linear')

Am I missing something in my code? Or how can I enforce it to use `linear` as the in/outTangentType whenever I am setting a keyframe...

Michael Boon

unread,
Jun 27, 2019, 12:46:41 AM6/27/19
to Python Programming for Autodesk Maya
I wouldn't be surprised if visibility is forced to be stepped by Maya. Objects are either visible or not. If you want an object to fade from opaque to transparent, you would need to use a different approach.
Reply all
Reply to author
Forward
0 new messages