My plugin operation time is long and maybe boring for users so I wish to show steps of operation as an animation. Following is a sample code for it.
grp = Sketchup.active_model.active_entities.add_group
for i in 0...10
cp = [0, i, i]
cir = grp.entities.add_circle cp, [0, 0, 1], (1)
face1 = grp.entities.add_face(cir)
face1.reverse! if face1.normal == [0, 0, -1]
Sketchup.active_model.active_view.refresh
sleep 0.1
# Sketchup.active_model.active_view.invalidate
end
As you can check view.invalidate doesn’t work and in this case, I have to use view.refresh.
API has following explanation about refresh.
Note:
This method might impact performance and if used incorrectly cause instability or crashes. Don’t use this unless you have verified that you cannot use #invalidate instead.
When I used refresh in my plugin caused crashes. Following you can see code and crashes.
code:
p @pt
Sketchup.active_model.active_view.refresh
p "----"
p @pt
result:
[Point3d(47.2441, 0, 5.90551), [48.818897637795274, 11.811023622047244, 43.30708661417323], [50.39370078740158, 23.62204724409449, 49.21259842519685], [51.96850393700788, 35.43307086614173, 55.118110236220474], [53.54330708661418, 47.24409448818898, 61.023622047244096], [53.54330708661418, 47.24409448818898, 5.905511811023622]]
“----”
[Point3d(47.2441, 0, 5.90551), [47.24409448818898, 0.0, 5.905511811023622], [48.818897637795274, 11.811023622047244, 5.905511811023622], [50.39370078740158, 23.62204724409449, 5.905511811023622], [51.96850393700788, 35.43307086614173, 5.905511811023622], [53.54330708661418, 47.24409448818898, 5.905511811023622]]
As you can see my data changed after a refresh.
How can I solve my problem. Your help will be highly appreciated.