Multi-thread script


#1

Hi to everyone!
I’m doing a script in Python. I have a windows form in a second thread and I need to call the rs.GetObjects() method. When i call the method show me an error. I think is because the method is called in a thread that is different from the main. Is it possible? How can I fix it?
Thanks!
Daniele


(Steve Baer) #2

Why is your form running on a second thread? This is not very typical.


#3

Because I’ve got the error: Unable to load a new message on a single thread. I use the Application.run(mainform) method to load the form.
Anyway I’ve changed the approach and I use the ShowDialog() method. When i run the rs.GetObjects() method I can’t select the ojects in the viewport.
A friend of mine suggest to me it is because the forms are in a modal type. It can be?
Thanks Steve!


(Steve Baer) #4

I would never recommend creating dialogs on separate threads (it is very rare that this is needed)

When you run rs.GetObjects() you should close your dialog first. Another approach is to use Rhino.UI.Dialogs.PushPickButton
http://4.rhino3d.com/5/rhinocommon/html/M_Rhino_UI_Dialogs_PushPickButton.htm