CadQuery / cadquery

A python parametric CAD scripting framework based on OCCT
https://cadquery.readthedocs.io
Other
3.21k stars 291 forks source link

The model exported ( as .STEP file ) has some broken surface #1416

Open shishunyoung opened 1 year ago

shishunyoung commented 1 year ago

My code use a complex surface to cut&split a box

step-1: use param_surface() to define a complex&irregular surface

param_surface = cq.Workplane().parametricSurface(Bsurface, N=400, start=-0.1, stop=100+0.1, tol=1e-4,\
                                                 minDeg=1, maxDeg=1, smoothing=None)

step-2:use this surface to cut&split a simple box

shape = cq.Workplane().center(50, 50).box(100,100,30).split(param_surface).solids('>Z')

step-3:export shape as a .step file & a .stl file

shape.val().exportStep(step_name_xxx, write_pcurves=False, precision_mode=0)
cq.exporters.export(shape, stl_name_xxx, tolerance=1e-3, angularTolerance=1e-2)

The problem is because param_surface is very complex,my .step file is very large ( ~12MB ). It's so so so slow when i want to open it as solid with SolidWorks 2022. And SolidWorks diagnosis show my model have some broken surface (and report surface error), but .stl file seems OK.

I dont understand why these broken surface exist ? Does cadquery have API to check&fix such broken surface?

adam-urbanczyk commented 1 year ago

You could try cq.Shape.isValid and cq.Shape.fix. What is exactly the error that is reported ?