Interesting.  I should note, the callback is an assumption on my part.
There's no connection on the dependency graph, so there has to be an
internal system evaluating the handle, else it wouldn't work.  Glad you
found a workaround though, I'll have to have a play with that.

On Fri, 17 Aug 2018 at 20:19 Marcus Ottosson <konstrukt...@gmail.com> wrote:

> Oh, I should have added, this also applies to querying attributes via the
> API and the MDGContext
> <http://help.autodesk.com/view/MAYAUL/2017/ENU/?guid=__py_ref_class_open_maya_1_1_m_d_g_context_html>.
> Phew!
>
> On Fri, 17 Aug 2018 at 09:17, Marcus Ottosson <konstrukt...@gmail.com>
> wrote:
>
>> Ok, I’ve got a workaround.
>>
>>    - Whenever you query an attribute at a given time, query it at time -
>>    1 first
>>
>> Now the result is always correct, with or without IK, at the expense of
>> one more query.
>>
>> *Example*
>>
>> One quick way of achieving the effect is wrapping any call to getAttr
>> with this.
>>
>> def getAttr(attr, time):
>>     cmds.getAttr(attr, time=time - 1)
>>     return cmds.getAttr(attr, time=time)
>>
>> *Full working example*
>>
>> from maya import cmds
>> # Build Scene# o     o#  \   /#   \ /#    o#
>> cmds.file(new=True, force=True)
>> a = cmds.joint(name="Root", position=(0, 0, 20))
>> b = cmds.joint(position=(0, 0, 0), relative=False)
>> c = cmds.joint(position=(0, 10, -20), relative=False)
>> handle, eff = cmds.ikHandle(
>>     solver="ikRPsolver",
>>     startJoint=a,
>>     endEffector=c,
>> )
>> def getAttr(attr, time):
>>     cmds.getAttr(attr, time=time - 1)
>>     return cmds.getAttr(attr, time=time)
>> assert cmds.getAttr(a + ".rx") == 0.0assert cmds.getAttr(a + ".rx", time=1) 
>> == 0.0
>> # Move handle
>> cmds.move(0, 15, -10, "|ikHandle1")
>> assert round(cmds.getAttr(a + ".rx"), 0) == -14.0assert round(getAttr(a + 
>> ".rx", time=1), 0) == -14.0
>> # The above call also enables this other node to evaluate properly# Which 
>> means we only need to call the special function once# per IK node.assert 
>> round(cmds.getAttr(b + ".rx", time=1), 0) == 49.0
>>
>> cmds.move(0, 15, -15, "|ikHandle1")
>> assert round(getAttr(a + ".rx", time=1), 0) == -4.0
>>
>> This (luckily) works consistently across all current versions of Maya.
>>
>>    - https://github.com/mottosso/maya-test/pull/1/files
>>    - https://travis-ci.org/mottosso/maya-test/builds/416763142
>>    
>> <https://travis-ci.org/mottosso/maya-test/builds/416763142?utm_source=github_status&utm_medium=notification>
>>
>> It doesn’t quite jive with my understanding of IK and what Joe mentioned,
>> that it uses this internal callback. This workaround *shouldn’t* work,
>> so I’m a little weary still. Finally, I found that the Cycle Warning only
>> happens on Maya 2018, no other version; not even 2019. So I’m tempted to
>> just ignore it.
>>
>> On Wed, 15 Aug 2018 at 07:43, Marcus Ottosson <konstrukt...@gmail.com>
>> wrote:
>>
>>> Thanks Joe, that confirms my own research into this. I'm seeing traces
>>> of this all the way back in Maya 6.0, and not just related to IK, but
>>> time-related queries in general.
>>>
>>> - http://forums.cgsociety.org/archive/index.php?t-188420.html
>>> -
>>> https://forum.highend3d.com/t/non-correct-result-in-mdgcontext/38047/12
>>>
>>> Challenging, to say the least..
>>>
>> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAQpKQaB8FxFKkQpMup5qhu4KnoU5ATHT-_w%2BT1%3DT7TjA%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAQpKQaB8FxFKkQpMup5qhu4KnoU5ATHT-_w%2BT1%3DT7TjA%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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAM33%3Da6YmeXBz%3DNT_Usr7gpUxKsjNsMXbsuaGrXxM-n0JMtKvQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to