Boolean Operation Fail

marcelo_quevedo
Contributor
Contributor

Boolean Operation Fail

marcelo_quevedo
Contributor
Contributor

Hello,

The core of our application works with solid operations between solids, and we constantly faced Boolean operation issues by using the ExecuteBooleanOperation() API method. It throws the next exception that doesn’t allow to do the Boolean operation.

 

“Failed to perform the Boolean operation for the two solids. This may be due to geometric inaccuracies in the solids, such as slightly misaligned faces or edges. If so, eliminating the inaccuracies by making sure the solids are accurately aligned may solve the problem. This also may be due to one or both solids having complexities such as more than two faces geometrically meeting along a single edge, or two coincident edges, etc. Eliminating such conditions, or performing a sequence of Boolean operations in an order that avoids such conditions, may solve the problem.”

 

I created a simple C# sample with a command that allows to do a Boolean operation between two solids. Also, I have attached two Revit files. Each file contains two intersected directShape objects. Using the C# sample and those files you could reproduce the issue by trying to do a Boolean operation between the two objects.

 

We will be very grateful if you could help us with some directions to solve the issue, and it would be great if you take into consideration this API issue for the future Revit APIs.

 

Thanks a lot, in advance!

Marcelo

 

Reply
8,295 Views
47 Replies
Replies (47)

tommy.stromhaug
Contributor
Contributor

Yes, this is a neverending tail. As I see it you have two low hanging options. 

In 2025 revit can export step files. If this can be done with the api it would be great.Have not checked it yet.

But I am planning of making a simple small application(.exe) with OpenCascade(https://dev.opencascade.org/) and automatically running the boolean operations there and then reopen the resulting Step into Revit.

If not using 2025 of Revit you have to make your own export and then converting the geometry to Open Cascade geometry entites. For most of the geometry in Revit this is quite simple. Revits Hermite splines have to be approximated to Open Cascades B-splines. Open Cascade has functionality for this. 

Happy coding!

ankofl
Advocate
Advocate

Do you have good experience in C++ and experience working with OpenCascade? Once I tried to turn something like this around - it turned into a living hell 

As a result, for my current project, we managed to achieve the necessary results using a Boolean operation not on Solid, but on Face, although for this we also have to upload geometry to json, upload it to Unity, and use two third-party libraries and 3D transformations to perform Boolean operations in 2D, and then return the result back to 3D.

0 Likes

tommy.stromhaug
Contributor
Contributor

I agree. C++ can be a living hell 🙂 I have another option using OpenCascade with c#, but if I remeber correctly I had to build OpenCascade myself. Check this git repo : https://github.com/Macad3D/Macad3D.

He has made a c# wrapper for most of the OpenCascade. His main project is a cad application but he has made a c

# wrapper himself. It is possible to build the whole project and only using the wrapper. I did that a few years ago.

Maybe the OpenCascade dll files are included in the project.

 

 

jeremy_tammik
Autodesk
Autodesk

The development team analysed the issues reported in REVIT-122714 [Boolean Operation Fail - case 13578517] and say:

  

This item is really a group of issues.

  

The Subtraction_error is solved by the user more carefully aligning the elements, and that is what they did. The request is that Revit do this alignment for them.

  

The items DoABooleanOperation 1 and 2 have some solids that can't be selected for cut or join. They are structural framing members with no type properties - I guess they were made through API. At any rate they are not very useful for debugging. Clearly this is another case of booleans needing to be "better" but we have many of those.

  

Is there any meat in this burger?

  

This requires more analysis...

    

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open

tommy.stromhaug
Contributor
Contributor

Hi. As follow up i want to report that i made a small test library in Revit 2025 and a c++/cli project in c++ using Open Cascade. Exporting elements as step require that you either isolate(hide all other) the element in the current view or make a temporary view with the element in question. Then you call the code in c++ from the c++/cli code to do the actual boolean operation. After that the result is written to a .step file for the Revit addin to import an place in the project. At this point i have not tested various algorithms in Open Cascade like using the fuzzy logic. I have also not been doing any "hard" problems testing in Revit(Problems files I know fails in Revit) yet. The Booleans in Open Cascade is said to be quite robust, but remember that the problem of boolean operations is difficult as a whole and it is an active research field. Currently we have customers that require some boolean operations on ship hulls and that forced me to rethink the whole work-flow. Anyway, the export of step files in Revit 2025 also made it possible to use any functions of the cad-kernel(Open Cascade) with some simple c++ functions. Communication between Open Cascade and Revit addin is step files and that could make a problem if there are hundreds of operations. Hope this can help others that is having problems with boolean operations. When I get time to test this properly i will be happy to share some code snippets.

jeremy_tammik
Autodesk
Autodesk

Thank you for the very interesting report. Good luck moving forward with this, and looking forward to your future progress!

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes

ghxc
New Member
New Member

I agree with you.I suggest Autodesk to tell us which part is "geometric inaccuracies" at least,then I can avoid this problem.

0 Likes

tommy.stromhaug
Contributor
Contributor

I do not think it is that simple. Even the most robust cad kernels do have problems in some situations. Revit have problems in many situations and can not be considered robust. Here are a list of possible problems situations :

 

Short edges and sliver faces

Huge tolerant entities and collapsed features

Improper intersections

Near-coincident entities

Near-tangent interactions

Complicated intersections

 

It is almost impossible to avoid all the elements in the list.

0 Likes