Temporary drawing elements vs. invisible objects
-
When I skim through other plugins I see that some create temporary drawing elements (ie. circle, etc. or with followme), take the Points3d and delete the temporary geometry again. This can be easier to write (and maybe also faster because it does the calculations in SU's core instead of Ruby??).
The alternative is to do all calculations with invisible Ruby objects like points, vectors and transformations (what I often prefered with no specific reason).Does the addition of new drawing elements have a bigger impact on SketchUp compared to creating any other (invisible) objects, or does it not matter as long as the entities are deleted again before SketchUp redraws the view?
-
Creating entities in SketchUp is slow! Very slow and it gets slower the more entities you have in the context. It also triggers all kinds of observers etc. If possible, avoid any kind of calculations without temp geometry. ( Some times you have to, like when you want to trigger SU's merge feature to make sure things heal up properly. Or if you need to get the current user axis - then you need to create two dummy groups.)
And yes, using the built in methods of SU for calculations is much faster than trying to do it in Ruby. Make use of the Geom module for all it's worth. For Vertex Tools I even ported the method that calculated soft selection to a C extension because in Ruby it was slow as a sleeping snail. Any calculation, even simple 2 + 2 operations eat time in Ruby - which you notice quickly when you do it in a look.
But the biggest bottleneck is adding entities in SU, and that's not much you can work around other than trying to use the bulk methods whenever possible.
Advertisement