Use the Ruby API to control the rotation of multiple plane components, loop a given rotation angle using Geom:transformation.new rotate plane elements, when the number of components is too large, the effect is very poor, can ruby API use multi-threading to improve efficiency? Thank you.
The Ruby API can only be used from the main thread.
Rotating (transforming) instance isn’t something I’d expect to be particularly slow though. Do you have an example scenario that demonstrate the bottleneck you are experiencing?
Sometimes there are other solutions that multithreading to speed things up.
(Btw, have you tried to run your code in the profiler? GitHub - SketchUp/speedup: Profiling tool for SketchUp Ruby extensions.)
Thanks for the answer, I didn’t make it clear, here’s what I’m going to do：Use the Ruby API to control the rotation of multiple plane components, loop a given rotation angle using Geom:transformation.new rotate plane elements, when the number of components is too large, the effect is very poor, can ruby API use multi-threading to improve efficiency?
Are you talking about this:
CPUs and Multithreading - SketchUp - SketchUp Community
Will the rotation angle be the same for each iteration through the loop ?
Will the “multiple components” be rotated with the same transformation ?
And if so, (as Thomas asked,) will the “multiple components” be within a group instance?
(If they are in the same geometric context, and the answer to 2 is yes, then they can all be temporarily grouped, rotated, and then the group exploded when the rotation is done.)
Lastly, are you using a fast style ?
Speeding Up Rendering with Fast Styles | SketchUp Help
No, multi-threading is not supported when interacting the the SketchUp Ruby API…
If you have some example code to demonstrate the issue we might offer some other advice. In many cases we usually find some other way around it (which yield better results than just throwing extra threads at the problem.)
Before going the route of temporary groups and exploding I’d make sure to apply the transformation in bulk instead of one-by-one if possible.
But, without some example code we’re getting ahead of ourselves. With it comes to performance only profiling will gives us a real clue to what is going on.
Which is what questions 1 and 2 is aimed at … and why they come before 3.