Multi-threading inside SketchUp
-
I have tried threads from a Ruby script in SU and found that the thread only gets executed when other Ruby commands are executed. Create your thread and then run some other Ruby commands (like a loop that prints out stuff) and you'll see that your thread will actually get executed. I don't think Ruby is actually creating a real thread, its just handling the time slices itself- which means you have to be giving the Ruby interpreter CPU time to do its business.
-
So after creating the threads, you have to start a loop that runs until your threads complete? And that means you can't do anything else in SU while the threads execute?
-
@thomthom said:
So after creating the threads, you have to start a loop that runs until your threads complete? And that means you can't do anything else in SU while the threads execute?
That's what I found, but this solution wouldn't work for me because I needed the thread to always run.
-
@thomthom said:
So after creating the threads, you have to start a loop that runs until your threads complete?
NO... use Thread.join instead of a loop.
` th1 = Thread.new {code
}
th1.join`
Suggest always have an exit condition inside thread. Not like example in first post (ie, it's an endless loop.) -
@dan rathbun said:
... Suggest ...
Dan,
I've played a lot with threads in SketchUp Ruby and have zero useful results. Could you post a small example that actually works?
-
This gets the best results for me so far. It's really slow, but it seems to be executing on a regular basis.
def testThread(times) timer = UI.start_timer(0,true){Sketchup.active_model.entities} thread = Thread.new{(0...times).each{|num| addBox};UI.stop_timer(timer)} end def addBox group = Sketchup.active_model.entities.add_group face = group.entities.add_face([0,0,0],[1,0,0],[1,1,0],[0,1,0]) face.pushpull(-1) group.transformation = Geom;;Transformation.new([rand(500),rand(500),rand(500)]) end
-
I need 64 bit support
-
-
@aidus said:
I need 64 bit support
This topic is about using Ruby "Green" threads, not native OS threads (which can run on several CPU cores.)
Ruby ver 2.0 "may" have native thread support, but current estimates of the work to be done, has 2.0 needing 17 years more work.
-
@dan rathbun said:
@aidus said:
I need 64 bit support
This topic is about using Ruby "Green" threads, not native OS threads (which can run on several CPU cores.)
Ruby ver 2.0 "may" have native thread support, but current estimates of the work to be done, has 2.0 needing 17 years more work.
I thought 1.9 had basic support for native threads, but Sketchup can't connect to its hooks.
-
@cjthompson said:
I thought 1.9 had basic support for native threads, but Sketchup can't connect to its hooks.
Might be.. (I'd like to know for sure if you can post a link.)
However Sketchup cannot currently load the 1.9.x interpreter DLL (... I've tried, and get an "entry point not found error." There seems to be some kind of difference between the 1.8.x and the 1.9.x DLLS, which I'd also like to know why this is. )
Also, "basic support" I read as "beta" (and likely error prone.)
-
I'm working with very large textures and I think su offten crashes because of that reason. It just can't work with very large files. You can operate inside sketchup but forget the export. Well that's just my guess. At home I have x64 bit os and there are no such problems - not so offten.
Advertisement