Pause a script for half a second.
Hi,
I am having a weird issue.
I am rotating and rendering an image via script.
When I rotate the image manually and render it, everything works great. When I use the script the skin pokes through the clothes.
When I adjust the rotation manually, the skin pokes through for a moment, but then Daz3D seems to fix it and the render seems to support that idea.
When I rotate the scene via script I don't think Daz3D has enough time to process everything before it begins to render.
What I'd like to try is putting a sleep() or setTimeout() function in there to give the GUI a chance to catch up, but it doesn't look like Daz has an equivalent method. I tried using processEvents() but that didn't do anything.
Any help would be appreciated.
Thanks,
james
Comments
I don't know for sure, but perhaps try Scene.update() after rotation and before rendering:
void DzScene::update ( )
Recursively updates all nodes in the scene.
Hi algovincian,
Thanks for the reply, I will check it out. I figured out how to delay the script which allowed the Mesh Smoothing to be applied.
It's janky but it works. When I call showProgress i get a couple seconds, which is what I needed.
I got the code from here.
Thanks again,
james
Ironically enough, in my own work, I now need to do exactly what you needed to do! I was hoping (before) that the Scene.update() call would be asynchronous and not return until the updating was done (including the smoothing modifiers). This does not seem to be the case.
I'm guessing this might be done with signal/slots, but am still looking for documentation/examples on this. I'll post again if/when I am able to figure something out.
- Greg
One of the problems with the smoothing modifiers is that how long it takes depends on how many items and how many iterations each item has. So there could be more than one smoothing modifier updating and if it has a larger number of iterations, it could take longer. Plus I'm not even sure if they are running concurrently or sequentially. Machine speed and memory also play a role, so a fixed wait time won't really work. Maybe a simple scene with only one or two smoothed items that have a low number of smoothing iterations would work with a fixed time, but anything more complex would probably still not be finished.
It's these things like how. exactly the smoothing modifiers update, that aren't documented anywhere I can find, that lead me to abandon my scripting projects...or at least shelve them for the time being.
Can anybody from DAZ chime in: What is the proper way to check if all mesh smoothing in a scene is complete before starting a render via script?
Thanks in advance for any info anybody can provide.
- Greg
in mcjTeleBlender's case i had a similar problem, the .obj export
of the scene was exporting scenes with poke-through
so i told users to turn “Interactive Update” ON for figures that use smoothing
http://www.daz3d.com/forums/index.php?&ACT=50&fid=41&aid=58036_TcRt4umbPyVv4iwgB2Ll&board_id=1
http://www.daz3d.com/forums/discussion/2877/P225
Thanks for taking the time to respond, Casual. I'll give it a go on my next multi-pass render.
- Greg
Starting with build 4.8.0.46, a new global sleep( Number milliseconds ) function has been added. Under the hood, this function starts a single-shot timer in a temporary event loop - pausing the invoking script's execution. While the script is in this 'temporarily paused' state, the main application event loop is still being processed. And when said timer times out, the temporary event loop dies and the script proceeds. Thus, this new function is 'semi-blocking' - blocking in the sense that it prevents further execution of the invoking script until the prescribed duration has transpired, but also non-blocking in the sense that the application is allowed to continue carrying out its normal tasks.
In the meantime, one approach would be to use a DzTimer, as demonstrated in the [recently added] Single-Shot Timeout sample.
Another approach, more directly related to the original question, would be to enter into a 'busy loop' if the background progress is active (the smoothing modifier is applied in the background) and break out of that loop when the background progress is no longer active - demonstrated in the [recently added] Wait For Background Progress sample.
-Rob
(delayed response = I've been 'a little busy')