Author Topic: Failed Boolean operations  (Read 1640 times)

0 Members and 1 Guest are viewing this topic.

rogue

  • Guest
Failed Boolean operations
« on: June 19, 2008, 06:45:05 AM »
It's a simple enough project - take some rectangular solids that have had some machining done to them, recreate the original, rectangular solid in the same place, and do a boolean subtract, the result of which gives me the machining only .. a "negative" of the machined solid, in a way.

The code loops thru an entire assembly of these solids, in effect showing an entire product in this fashion. It works perfectly - 95% of the time. When it works perfectly, every single solid in the assembly comes back with only the machining showing. But ocasionally, it fails, and every single solid in the assembly comes back as a rectangular slab - the boolean subtract operation is failing on every single solid in the product.

When it fails, it fails always on the same product, and on every part in that same product. When it works, it always works on every single part in the product. The products it works on, it always seems to work on. The products it doesnt work on, it always doesnt work on. Except, occasionally, every few days, one that failed previously, would now work.

Ive checked the origins of each solid, the original vs the new clone. relative to each other. They seem to be exact, or at least to 6 decimal places. I would think that even being slightly off would give me a subtract result showing .001 of an entire face, etc... but it doesnt. After the routine fails, I can manually go back and do the subtract operation successfully.

I spent the last 2 days trimming down something to post here - I trimmed down the drawing to 2 assemblies, one of which works, and one of which didnt - and then started removing modules in the code, etc, to get something easier for you guys to follow. And I made sure that, while I was doing this, that one assembly still failed, and one still worked - until this morning. Now  both assemblies work - in both the trimmed down code, and the original code. In the original drawing, the original code still fails on the same assmbly of solids. (I cant run the trimmed down code on the original drawing, but I dont think thats the issue.)

WTF? This is driving me nuts! Is there something in the process of boolean subtraction that can generate a failure? There is no return code for the subtraction operation? For whats its worth, here is the process I use:

1) Loop thru the assembly of solids and add each one to a collection. (works successfully)
2) Take the collection and do a copyobjects. ( I dont want to modify the original solids)  (works successfully)
3) Loop the copied objects and store the handles.   (works successfully)
4) Then, for each individual copied object, do the following:
    4a) create another solid in the same place    (works successfully)
    4b) do a subtraction operation on the new, rectangular solid, and the copy of the machined solid. (sometimes fails)
    4c) drop the copied solid into a blockref (works, even with the failed rectangular slab)
    4d) start a new document, and do a copyobject from the source, to the destination, document (always works)
    4e) delete the original blockref from the source document (always works)

Any ideas on where i can even *start* to look, to find this bug?

thanks, guys ...

Jeff_M

  • King Gator
  • Posts: 4048
  • C3D user & customizer
Re: Failed Boolean operations
« Reply #1 on: June 19, 2008, 11:08:48 AM »
without code or sample drawing, the only thing I can think of is to remove any On Error Resume Next lines you may have used. Let it error and that should point you to the problem area.

rogue

  • Guest
Re: Failed Boolean operations
« Reply #2 on: June 23, 2008, 05:58:34 AM »
Update:

I've narrowed it down a bit; it seems that the copyobjects comand, when run and a large amount of obects are copied from a collection, will successfully return an array of copied objects, but it seems that the location of each copied object within the returned array is not necessarily in the same location as the parent collection; ie, if I copy a collection of 50 solids named Solid1, Solid2 ... Solid49, Solid50, the returned collection may have the copied solids starting with Solid2,Solid3 ... Solid50, Solid1. So I was trying to do a subraction operation with the wrong copied part.

Why this behaviour is sometimes happening, I am not sure; for now, I am using a workaround of not using the copyobjects command and using the individual object.copy method.