Boolean Operation Fail (solid union)

Boolean Operation Fail (solid union)

Anonymous
Not applicable
2,242 Views
2 Replies
Message 1 of 3

Boolean Operation Fail (solid union)

Anonymous
Not applicable

Hello.

 

There was an error joining the solids.

 

“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.”

 

private Solid SolidUnion(Solid solid, Solid union)
{
★ return BooleanOperationsUtils.ExecuteBooleanOperation(solid, union, BooleanOperationsType.Union);
}
private Solid GetSolid(Element element)
        {
            Solid solid = null;
            var geometryElement = element.get_Geometry(new Options { IncludeNonVisibleObjects = true } );

            if (geometryElement != null)
            {
                foreach (var geometryObject in geometryElement)
                {
                    // Solid 추출
                    if (geometryObject is Solid geometrySolid && geometrySolid.Faces.Size > 0 && geometrySolid.Edges.Size > 0)
                    {
                        if(solid == null)
                        {
                            solid = geometrySolid;
                        }
                        else
                        {
                            solid = SolidUnion(solid, geometrySolid);
                        }
                    }
                    // Solid 변경
                    else if (geometryObject is GeometryInstance geometryInstance)
                    {
                        if (geometryInstance.GetSymbolGeometry() is GeometryElement instanceGeometryElement &&
                           geometryInstance.IsElementGeometry && geometryInstance.Transform.IsConformal)
                        {
                            foreach (var instanceGeometryObject in instanceGeometryElement)
                            {
                                if (instanceGeometryObject is Solid instanceGeometrySolid && instanceGeometrySolid.Faces.Size > 0 && instanceGeometrySolid.Edges.Size > 0)
                                {
                                    if (solid == null)
                                    {
                                        solid = instanceGeometrySolid;
                                    }
                                    else
                                    {
                                        solid = SolidUnion(solid, instanceGeometrySolid);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return solid;
        }

 

wall.png

Please refer to the above source and attached file.

 

The red, orange, and yellow lines are different objects and are joined together.

 

However, an error occurs when only the orange Element is initially loaded. Is there a solution?

 

The reason for solid union was to try to perform an interference test because of the complex family, but this error appeared.

 

I don't know if there are any other categories other than walls with these symptoms.

Thanks.

0 Likes
Accepted solutions (1)
2,243 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Accepted solution

I solved it myself.

All solids were received as a list and compared.

 

It is unsafe, so it is recommended not to use BooleanOperationsUtils.ExecuteBooleanOperation.

 

 

0 Likes
Message 3 of 3

guanshijie14
Explorer
Explorer

Can you provide some sample code to show how to solve this problem?

0 Likes