
Tue, 01/16/2024 - 16:32
Forums:
Hi everyone,
I have 2 breps and i would like to get their intersection (see image attatched). The shapes are valid closed solids and they do intersect. However the result is a topods_compound that does not contain any geometry. Does anyone have any tips how to fix this?
The report says "BOPAlgo_AlertBadPositioning", but I could not find any info on how to fix that. I also attatch both shapes as step files (to upload them i had to change their extention to .txt, but they work the same)
Here is my code:
from OCC.Extend.DataExchange import read_step_file
from OCC.Core.BRepAlgoAPI import BRepAlgoAPI_Common
from OCC.Core.BRepCheck import BRepCheck_Analyzer
from OCC.Core.ShapeAnalysis import ShapeAnalysis_FreeBounds
bottomBrep = read_step_file('export/BRepAlgoAPI_Common/20240116_114252_emptyCompound_bottomBrep.txt')
topBrep = read_step_file('export/BRepAlgoAPI_Common/20240116_114252_emptyCompound_topBrep.txt')
commonFunction = BRepAlgoAPI_Common(bottomBrep, topBrep)
commonFunction.Build()
common = commonFunction.Shape()
#ckecking
print(f'Has Generated: {commonFunction.HasGenerated()}')
print(f'HasErrors(): {commonFunction.HasErrors()}')
print(f'GetReport().DumpToString(): {commonFunction.GetReport().DumpToString()}')
analyzer = BRepCheck_Analyzer(bottomBrep)
print('bottomValid: ', analyzer.IsValid())
analyzer = BRepCheck_Analyzer(topBrep)
print('topValid: ', analyzer.IsValid())
free_bounds = ShapeAnalysis_FreeBounds(bottomBrep)
print('bottomBrep has free edges: ', not free_bounds.GetClosedWires().IsNull())
free_bounds = ShapeAnalysis_FreeBounds(topBrep)
print('topBrep has free edges: ', not free_bounds.GetClosedWires().IsNull())
The printed results of checking:
Has Generated: False
HasErrors(): False
GetReport().DumpToString(): BOPAlgo_AlertBadPositioning
BOPAlgo_AlertBadPositioning
BOPAlgo_AlertBadPositioning
BOPAlgo_AlertBadPositioning
BOPAlgo_AlertBadPositioning
BOPAlgo_AlertBadPositioning
BOPAlgo_AlertBadPositioning
BOPAlgo_AlertBadPositioning
BOPAlgo_AlertBadPositioning
BOPAlgo_AlertBadPositioning
BOPAlgo_AlertBadPositioning
BOPAlgo_AlertBadPositioning
bottomValid: True
topValid: True
bottomBrep has free edges: False
topBrep has free edges: False
Attachments:
Mon, 04/14/2025 - 14:44
Hey, I have been having a similar problem lately. It occurs when I try to do a common operation between a box and a custom mesh (a staircase) that I built with a list of triangles, the BRepBuilderAPI_MakePolygon, BRepBuilderAPI_MakeFace, BRep_Builder.MakeShell(shell) and BRepBuilderAPI_MakeSolid.
My custom mesh seems fine when I used it alone. However, I lose a lot of triangles when I try to do a common operation with a cube which is just as big a the mesh.
Did you ever find a solution to your problem?
Best regards.
Mon, 04/14/2025 - 19:42
Daiva Daiva wrote:
Your shapes have touching faces, which are known to be problematic within Boolean operations. For such use case, Fuzzy Boolean Operations might make operations more robust. For this, you need to specify fuzzy value to
BRepAlgoAPI_Common::SetFuzzyValue()
, something like:in your code. Within Draw Harness it helps to get result on your input shapes.