Getting model to fix itself
-
About a year ago I had a problem where a model would "re glue" its components when it did a save. I discovered something I called to get the model to check, update, validate (or something) itself after I performed an operation - such as moving a component - so it would reglue things.
I remember posting the problem and the solution on the SketchUp ruby forum, but that forum is gone now and I cannot find it.
Can anyone remember what operation you pass in Ruby to get SketchUp to repair the model after an edit
and/or
does anyone know if the ruby forum posts are archived anywhere>
-
Al,
Some 30 pages of the ruby forums have been transferred to the new, Google Pro Groups:
http://groups.google.com/group/Ruby-API/topicsIt seems there's something wrong with the GGroups software (or just the board settings) there for on the index page it looks as if it were empty.
The internal links haven't been fixed (transferred) though so they does not work.
-
Thanks Gai. I searched there and could not find what I was looking for. But it is good to know that it is there.
I remembered what we had to do (finally).
If, during execution of ruby, you change the model, (even just adding an attribute), then all smoothing normals are lost. They get restored when the ruby exits. But you cannot use them -- for instance when exporting faces from Ruby -- unless you let the ruby routine (and any routines which called it), exit first.
We get around this by altering the drawing, and then executing the next function with a 0 length timer. This causes the second function to get executed after the first function completes.
This code will not work because the normals do not get recalculated.
def do_export Sketchup.active_model.active_entities.set_attribute("t1","t2","t3") export_data # calls another ruby to export faces and normals # normals are not recalculated properly after the model was changed... end#def def export_data #export the data end#def
This code, which sets the attribute and then uses a time to execute "export_data", will work properly.
def do_export Sketchup.active_model.active_entities.set_attribute("t1","t2","t3") # use time to run second routine after model cleanup UI.start_timer(0, false) {UI.stop_timer(id); export_data} end#def def export_data #export the data end#def
I seem to remember that there is some command you can issue to get SketchUp to clean up or repair the model, but I can't remember what it is. If anyone remembers, let me know!
Advertisement