jstevenson
(Jason Stevenson)
December 4, 2017, 10:08pm
1
Is there a recommended pattern, or code, to have Rhino cancel a call to Brep.CreateBooleanDifference() when it isn’t working well?
We have some “bad designs” that hang at this call for nearly 20 minutes before moving past it.
Just wondering if there is a design pattern you all use or recommend when trying to get past a failing boolean.
Thanks,
Jason
stevebaer
(Steve Baer)
December 5, 2017, 2:36pm
2
We have a GetCancel class in V6 that lets you run a task while The main Rhino UI thread watches for the user to press esc (which triggers a cancel on the task)
1 Like
Hi @jstevenson
To avoid the boolean operation hang problem I usually create a Thread as a global variable:
Thread _myThread;
Brep[] _boolResult;
private void MyFunction()
{
_myThread = new Thread(() =>
{
_boolResult = Brep.CreateBooleanUnion(objsToJoin, TOLERANCE);
});
}
Run it:
_myThread .Start();
Next join it to the current thread if you want to wait for the operation to end:
_myThread .Join();
//Do some stuff
return;
By other hand, start a timer which will check if _myThread.IsAlive()
after some time (2, minutes, 5 minutes…) and if so just call
_myThread.Abort().
For Rhino 5, this is the best solution I found to this problem.
Best Regards
2 Likes
dale
(Dale Fugier)
December 5, 2017, 5:29pm
4
Hi @jstevenson ,
Do you have some geometry that is taking forever to Boolean that you can share?
– Dale