How to detect changes in a model between two sessions
-
(I have posted this also on the new forums.sketchup.com ... Not sure if this is considered cross-posting?)
Hi,
I'm using SU to perform radiation calculations in large developments. As part of the workflow I would like to be able to analyse different scenarios. My workflow at the moment is the following:
1 - calculate a 'shading mask' for the points of interest. This shading mask contains also information about the surfaces that cast the shades such transparency, temperature, etc.
2 - the shading mask information is all contained in an object. I use ruby marshal to dump this object on a file.
3 - perform radiation calculations for a specified time interval
4 - if I close sketchup and open it again because I need to analyse a different period, I load the marshal file and perform just the radiation calculation because the geometry information is already in the file
5 - however, if I have to analyse a different scenario, because I have added shading, or I have changed the properties of some surfaces, I need to re-run the geometry calculation again. This can take even a few hours.
It would be great if I could detect only the elements that have changed in the model and use this information to avoid having to rerun everything every time.
Is there a way to do this?
Thanks!
-
How about adding an attribute to every object [group/component/face?] you'll need to work with - this is added AFTER you first add or later change it ?
This 'tid' becomes part of each object you work with.
You'll include that tid float in the data-set file you export.
It should be a unique 'time_stamp' code.
e.g.object.set_attribute('RGuida', 'tid', Time.now.to_f)
Then when you next come to analyze the model you go through its objects and look for the matching entry in your data-set file.
object.get_attribute('RGuida', 'tid', 0.0)
If there is an entry and the tids match, then it has not been updated and so it is ignored.
If there is an entry and the tids do not match, then it has been updated and earmarked for re-analysis...
If there is no entry for that object [container?] then that object is 'new' and it is analyzed [with its brand-new tid].
That way only objects newly added or consciously marked for re-analysis are processed.
Exporting the data-set to the file then uses either preexisting or updated values... -
Thanks TIG.
I like this solution. It should work in principle for the objects whose properties I am going to change. I think I have to change the way I store the objects though. Let me explain.
The goal is to produce an insolation contour across the development (at ground level). To do this I do the following:
1 - mesh the surface that represents the interstitial space between buildings
2 - for each grid node I cast rays to cover the whole hemisphere
3 - for each ray I use raytest to verify whether I see the sky or I see an obstruction (this obstruction can be transparent or it can have an assigned temperature)Each Ray is an object with properties: direction, shaded_state, temperature, transparency and so on (there is no reference to Sketchup objects)
Each grid node is represented by grid_node object with properties: coordinates and an array of Rays
In order to implement your solution I think I will need to store the reference to the actual object that the Ray sees (if it does). I am not sure I can store a reference to a SketchUp object? Would the search in the datafile be faster than the re-calculation? I will test.
Your proposed solution will not help though for the impact that a NEW object can have on specific grid nodes. My idea for this case was to replace the raytest with an intersection test between the new object (this is usually some form of local shading such trees, canopies, etc.) and the various rays for each grid node. I guess that the intersection test should be faster than raytest.
Thanks again.
Advertisement