Freezing cooking while manipulating the network with Python

   3783   4   1
User Avatar
Member
98 posts
Joined: Sept. 2008
Offline
Dear All,

I'm running into some problems I do not know how to figure out, and perhaps you can help me, as you usually do. I'm trying to “optimize” my code, disabling all re-computations while I'm manipulating the obj network from Python (inside the Python shell). The “manipulations” I'm referring to include node additions/deletions and/or paramtere changes. so, the idea is to “freeze” Houdini from cooking during a moment, re-shape (manipulate) the network, and after that unfreeze Houdini and let it do its usual work and build the geometry. However, I also need to have timings of the diferent stages. Basically, I need two fundamental timings the graph manipulation stage and the time it took Houdini to re-cook everything.

I've tried with hou.setUpdateMode(hou.updateMode.Manual) to “freeze” and hou.setUpdateMode(hou.updateMode.AutoUpdate) to “unfreeze”, and the time library to show the timings (with time.clock or time.time depending on the OS). However, the results for the cooking step seem unrealistic I get just 1.07 seconds while I've seen Houdini cooking for at least 30 seconds or more (and I may have re-computations that take up to 20 minutes!!!). My feeling is that it is not the time library, but Houdini returning control to the library even when it is still cooking… are they separate threads?

So… any ideas? How can I get precise timings for these two stages? Am I correctly freezing Houdini, or am I wrong with respect to this, too?

any help will be GREATLY appreciated!

thanks a lot

dagush.-
————————-
* skylineEngine project coordinator
* buildingEngine module developer
http//ggg.udg.edu/skylineEngine
User Avatar
Member
7743 posts
Joined: July 2005
Offline
When running your Python code, UI events are probably not getting a chance to be processed. So, it's probably not recooking until *after* your python script finishes, when the viewport receives the UI event to refresh its contents. So try calling hou.ui.triggerUpdate().
User Avatar
Member
98 posts
Joined: Sept. 2008
Offline
Hi,

Thanks for the answer!
I've tested it and it seems to run really fine, so this is a fantastic solution for the “freezing/unfreezing” part.

Now, I still have the timings problem how can I, from Python, know the time that a given step in the process took (in my case, network pre-processing and final cook). As I've mentioned, it seems to me that Houdini runs the Python shell in a separate thread, as the times I'm getting are clearly unrealistic (less than one second for a 35-second cook!).
Any ideas on this part?

Anyway, thanks for the answer! It's THE solution for that part of my problem!

thanks

dagush.-
————————-
* skylineEngine project coordinator
* buildingEngine module developer
http//ggg.udg.edu/skylineEngine
User Avatar
Member
7743 posts
Joined: July 2005
Offline
Actually, try looking at using the “hdefereval” module. You can try using hdefereval.executeDeferred(waitUntilProcessed) where waitUtilProcessed is a function that gets called after Houdini has done processing the queued UI events.
User Avatar
Member
98 posts
Joined: Sept. 2008
Offline
Dear Edward,

Than you very much! I'll look at that module as soon as possible, but it looks as the PERFECT solution!

Thanks!

dagush.-
————————-
* skylineEngine project coordinator
* buildingEngine module developer
http//ggg.udg.edu/skylineEngine
  • Quick Links