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!