Thank you so much, Marcus

It's working excellently and I appreciate your time too.
I have been following you for very long :)

Thanks again!



On Sunday, October 20, 2024 at 8:22:16 PM UTC+5:30 Marcus Ottosson wrote:

> Try calling these before and after the function.
>
> cmds.undoInfo(chunkName="myFunction", openChunk=True)
> my_function()
> cmds.undoInfo(chunkName="myFunction", closeChunk=True)
>
> This will cause all undoable calls to maya.cmds to be grouped together 
> into a "chunk". It's important to call closeChunk after, as it could 
> otherwise make Maya and undoing unstable. To make it more safe, you could 
> use something like a context manager.
>
> @contextlib.contextmanagerdef undo_chunk(name):
>     try:
>         cmds.undoInfo(chunkName=name, openChunk=True)
>         yield
>     finally:
>         cmds.undoInfo(chunkName=name, closeChunk=True)
> with undo_chunk("myFunction"):
>    my_function()
>
> That way, even if your function fails or throws an exception, the chunk 
> will still be closed.
>
>
> On Sun, 20 Oct 2024 at 11:11, Shaikh Anas <shaikha...@gmail.com> wrote:
>
>> Hello everyone, I am creating a tween machine just for my educational 
>> purpose and to understand the logic of it.
>>
>> *I am facing multiple undo issues.*
>>
>> I am attaching two images, where the function is the same, the difference 
>> is one, I am running independently to check if is it working fine and 2nd 
>> is running through a signal.
>>
>> So the issue is when a single calls this function it runs perfectly but 
>> If I want to undo the changes it will undo every single attribute one by 
>> one which takes lots of undo to change.
>>
>> If I run the script indecently ( screenshot_3.png ) and undo that, it 
>> simply takes one undo to change the entire action.
>>
>> Thanks and Regards,
>> Shaikh Mohammad Anas
>>
>>
>> -- 
>> 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_m...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/python_inside_maya/82d3cfa9-1d1f-4eb9-b372-ac7ba89b8bbfn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/python_inside_maya/82d3cfa9-1d1f-4eb9-b372-ac7ba89b8bbfn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/033ab050-bcb6-48b6-9f9d-c7c24e19b110n%40googlegroups.com.

Reply via email to