CadQuery / cadquery

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

Can't cut a workplane from another workplane #1292

Closed niSeRdiSeR closed 1 year ago

niSeRdiSeR commented 1 year ago

Hey, maybe some of you guys know what I am doing wrong here, but for me the following behaviour isn't really plausible:

Based on the given code snippet, loading 2 differently sized boxes from a DXF file using 2 import statements and cutting the inner from the outer box should lead to some kind of hollow shape IMO.

When I view the file in Paint3D though, it still looks like a filled box. I can tell that there are some kind of lined borders, as if the inner box actually got seperated but not really excluded. Thus I think I am not missing that much really.

import cadquery as cq

thickness = 500

inner_box = cq.importers.importDXF("model.dxf", include=["Layer1"]).wires().toPending().extrude(thickness+10)
outer_box = cq.importers.importDXF("model.dxf", include=["Layer2"]).wires().toPending().extrude(thickness)    

result = outer_box.cut(inner_box)

cq.exporters.export(result, "cq.stl")

Would appreciate any input or hints! Ty guys in advance

lorenzncode commented 1 year ago

The code looks fine. You can do similar with Sketch without the 3D cut.

import cadquery as cq

thickness = 500

s = (
    cq.Sketch()
    .importDXF("model.dxf", include=["Layer2"])
    .importDXF("model.dxf", include=["Layer1"], mode="s")
)

result = cq.Workplane().placeSketch(s).extrude(thickness)

cq.exporters.export(result, "cq.stl")

The result will depend on the contents of the DXF. Can you upload the DXF file?

adam-urbanczyk commented 1 year ago

No answer form the OP.