Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple 'cut' of two a Box and a Sphere creates unusable object #1584

Open
fleiner opened this issue May 8, 2024 · 3 comments
Open

Simple 'cut' of two a Box and a Sphere creates unusable object #1584

fleiner opened this issue May 8, 2024 · 3 comments

Comments

@fleiner
Copy link

fleiner commented May 8, 2024

This very simple script creates a box and cuts out part of it with a sphere. It confuses cq-editor (instead of a cut one gets a hole to look into the cube), and creates a completely unusable stl file with over 1000 open edges, (the equivalent translate() call instead of transformGeometry() is slightly better with only 4 open edges). Is there any workaround? Thanks

import cadquery as cq

res=cq.Solid.makeBox(10,10,10)
sphere=cq.Solid.makeSphere(4,angleDegrees1=-90)

m=[[1,0,0,10],[0,1,0,0],[0,0,1,5],[0,0,0,1]]
res=res.cut(sphere.transformGeometry(cq.Matrix(m)))
#res=res.cut(sphere.translate([10,0,5]))

ass = cq.Assembly()
ass.add(res, color=cq.Color("red"))

cq.exporters.export(cq.Workplane("XY").add(res), 'mesh.stl')
show_object(ass)

image

@adam-urbanczyk
Copy link
Member

The workaround would be to perturb the position of the sphere: res=res.cut(sphere.translate([10,1e-3,5]))

@fleiner
Copy link
Author

fleiner commented May 8, 2024

That does solve the cq-editor problem, but it does not solve the stl code. For the latter I have to perturb all three axis.

@jmwright
Copy link
Member

The following code using the fluent API works fine for me (the STL imports and slices without any errors).

import cadquery as cq

# Box
box = cq.Workplane().box(10, 10, 10)

# Sphere
sp = cq.Workplane().sphere(4)
sp = sp.translate((5, 5, 0))

# Resulting object
res = box.cut(sp)

show_object(res)

cq.exporters.export(res, "/home/jwright/Downloads/cut_obj.stl")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants