hehe thanks, still cool to have new feedbacks anyway =] I actually gave up 
on this one. So the final solution was kind of a 'hack', as described in 
the link I posted above. I'm still a bit frustrated that I didn't find a 
'maya friendly' solution ^^


Le jeudi 16 février 2017 19:10:54 UTC-8, Michael Boon a écrit :
>
> I don't know where you're calling this code from, but I agree with your 
> guess: calling plug.getValue causes your code to be run again.
>
> The reason that would cause an infinite loop when you call it twice and 
> not when you call it once, is that Maya short-circuits if you call it twice 
> with the same frame. So if you call it with MTime(10.), that in turn calls 
> it again with MTime(10.) and Maya is smart enough to stop. But if you call 
> it with MTime(10.) and then with MTime(11.), that in turn goes back to the 
> start, which Maya can't short circuit, and thus you're in an infinite loop.
>
> Seems like you either need to avoid doing this calculation where you're 
> doing it, or set up a system that caches the results.
>
> (Or more likely, you figured this out yourself months ago.)
>
>
> On Friday, 4 November 2016 10:42:51 UTC+11, fruity wrote:
>>
>> So still stuck with that annoying problem =[
>> I found this interesting page (
>> http://theorangeduck.com/page/maya-velocity-node), talking about the 
>> same issue, more or less. But firstly, it's not *exactly *the same, and 
>> secondly it uses a callback to fix it, while I'm not sure this is the only 
>> solution in my case.
>> I tried tons of different workarounds, but nothing worked at this point.
>>
>> I progressed a bit, though ! I know that it's not because of the loop 
>> itself, just because i query the mplug value twice.
>> In other word, to stick to my previous example :
>>
>> MDGContext ctx( MTime(10.) );
>> plug.getValue(oInput, ctx );
>> *will work*
>>
>> MDGContext ctx( MTime(11.) );
>> plug.getValue(oInput, ctx );
>> *will work*
>>
>> but 
>> MDGContext ctx1( MTime(10.) );
>> plug.getValue(oInput, ctx1 );
>> MDGContext ctx2( MTime(11.) );
>> plug.getValue(oInput, ctx2 );
>> *will put me in an infinite loop.*
>>
>> Any help, suggestion or anything would be more than welcome, i'm really 
>> stuck with that !
>> Many thanks !
>>
>>
>>
>>
>> Le dimanche 23 octobre 2016 10:48:16 UTC-7, fruity a écrit :
>>>
>>> Hi there, 
>>>
>>> I'm working on an MPxLocatorNode, and i have to get the value of a plug 
>>> at a given time. I can do it, using an MContext, and it works perfectly :
>>> MTime t( 10. );
>>> MDGContext ctx( t );
>>> plug.getValue( oInput, ctx );
>>>
>>> However, when i'm doing it in a loop (i.e. with a dynamic time), Maya 
>>> will run indefinitely, even after the draw() has been done : 
>>> for (double i=0.; i < 2.; i += 1.)
>>> {
>>>
>>> MTime t( i );
>>> MDGContext ctx( t );
>>> plug.getValue( oInput, ctx );
>>>
>>> }
>>> // this will never stop being evaluated.
>>>
>>> I'm assuming it's because even though i'm using a MContext, a redraw of 
>>> my locator is triggered, somehow. Then, because this redraw is triggered, 
>>> my draw method gets run again, causing another redraw, and so on ? 
>>> But then, why it's not happening if i'm not using a loop ? And then, how 
>>> can i query a plug at a given time, in a loop ? Is there some hack, based 
>>> on a setDirty or setClean call ? Is it reliable ?
>>> Any help would be much appreciated, as i couldn't find lots of 
>>> information about it online =[
>>> Many thanks !
>>>
>>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/0ab97e9f-3439-4c16-95ed-e30a81e8b3d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to