Can we use thread concept in sketchup ruby api ? Once when I tried so, it wasn’t working as expected. Any suggestions ?
The SketchUp API can only be called from the main thread. SketchUp itself isn’t thread safe at this point.
Further more, Ruby threads in SketchUp isn’t working entirely correctly. It appear that the threads aren’t processing unless the main thread is also busy (which usually defeats the purpose of using threads). Not sure why, seems like Ruby is doing some management of its threads that is tied to the main thread which doesn’t jive well with being embedded into an application like SketchUp. Since the SU API cannot be used from threads it hasn’t been high on the priority list to find the root cause of this.
Do we have any alternatives if so ?
What do you want to use them for? As @tt_su mentioned, the SU API can’t be used in them, but other tasks might benefit.
If you aren’t planning on interacting with the SketchUp API then you could use native threads from a Ruby C extension.