Notifications
Clear all

[Closed] [Python] Not blocking the main thread

I need to get the following code working in Maya, Max and Motion Builder.

Get all the objects in the scene.
Move all objects
Get New position

This is a simplified version so id prefer if I not explain why im doing everything.

The problem I am encountering is that when I move all the objects in the scene, they are not actually moved until my code inside the script editor is done executing. I imagine this is because it is blocking the main thread as long as its running.

For example if you had something like
MoveAllObjectsBy50InX()
time.sleep(50)

None of the objects would actually get moved for 50 seconds. Until you have stopped running code in the script editor.

I can solve the problem in Maya by starting a new thread and waiting a second for the code to finish executing then check the position. Threading crashes max and mobu though.

Is there anyway to force max to update before continuing in my code? Or threading that works in Max?