Hi Martin,
> My simple test script, boolean diffs two cylinders and then another one from the result.
> Unfortunately the second boolean diff doesn't work therefore I assume object variables
> generated by sweep or boolean diff must be extracted differently.
It's a "race condition" / timing problem - certain factories (including booleans and sweeps) do asynchronous updates. That means that when a script calls .update() on it, what actually happens is the update is only queued up to be processed on a worker process and will be completed some time in the future. Then .update() returns and the script continues on, so in these cases that you're running into here the actual calculation done by the factory has not happened yet at the time that the script calls .getCreatedObjects(), and so it gets back no created objects.
Factories that may take a while to finish their calculations are set up with this asynchronous mechanism, it's the thing that makes the "Calculating..." message display on long calculations and prevents MoI from just looking like it is frozen while some big calculation is crunching away.
For these async factories it won't work right now to use the .update() and then .getCreatedObjects() method, you'll have to use factory.calculate() instead which is synchronous.
But I will tune this up for the next v3 beta - I've modified .getCreatedObjects() to make it automatically pause there and wait inside that function if there is an async update currently in progress for that factory. So in the next v3 beta your script there will run ok. But to make it work in the current build you'll need to use .calculate() instead.
I'll also add a factory.waitForAsyncUpdate() method as well that you can call to make a script pause until any async update for that factory is finished.
In general I'd like to try and hide the asynchronous mechanism from scripting so that it appears to the script that things are just happening in sequence by adding in built-in waiting in strategic areas like inside .getCreatedObjects() . That one just hasn't been used much so it's still in the process of working out the kinks like this. Thanks for reporting the problem, someday these things will end up working smoothly maybe.... ;)
- Michael
|