api.OpenMaya.MDGContext error 2020

54 views
Skip to first unread message

juan c

unread,
Jul 28, 2021, 6:17:52 PM7/28/21
to Python Programming for Autodesk Maya
hi
i am trying to get some value at time:

from maya.api import OpenMaya
time = OpenMaya.MTime(20)
context = OpenMaya.MDGContext(time)
node_obj = OpenMaya.MSelectionList().add('persp').getDependNode(0)
node = OpenMaya.MFnDependencyNode(node_obj)
plug = node.findPlug('tx', False)
value = plug.asMDistance(context)


this freezes maya for a second or two and spits out this error:

# sys:1: DeprecationWarning: Call MPlug::asType() instead. If needed, use MDGContextGuard switch context.

it works fine on older maya versions, and using the old api.

any ideas?
cheers!

vince touache

unread,
Jul 28, 2021, 9:23:48 PM7/28/21
to Python Programming for Autodesk Maya
super weird, it seems to work fine on 2022, meaning it might not be an actual deprecation warning. Any chance you can try it with a newer version of maya ?
mdgcontext.JPG

juan c

unread,
Aug 1, 2021, 6:21:45 PM8/1/21
to Python Programming for Autodesk Maya
i have only got 2020 unfortunately. api version 20200405.
i suppose it's good news that it's not happening on 2022, but i would be curious to get some ideas on why it's failing here.
i am resorting to checking maya version and setting the context as current, in case it's 2020... which is less than ideal.
thanks for checking!
Reply all
Reply to author
Forward
0 new messages