I want to subtract 4 cylinders from a hemisphere. The four cylinders are aligned to (1,0,0), (-1,0,0), (0,1,0), (0,-1,0) and do intersect.
When intersecting one part won't be subtracted!
Whit non-intersecting cones i get the following as expected!
In case I use cylinders instead of cones everything works fine.
Here is my code:
import math
import cadquery as cq
from ocp_vscode import show_object, reset_show, set_defaults
def align(obj, dir):
l = math.sqrt(dir[0]**2+dir[1]**2+dir[2]**2); ## radial distance
b = math.degrees(math.acos(dir[2]/l)); ## inclination angle
c = math.degrees(math.atan2(dir[1],dir[0])); ## azimuthal angle
return obj.rotate((0,0,0),(1,0,0),0).rotate((0,0,0),(0,1,0),b).rotate((0,0,0),(0,0,1),c)
def cone(height, angle):
radius = height*math.tan(math.radians(angle))
cone = cq.Solid.makeCone(0, radius, height)
return cone
def cylinder(height, angle):
radius = height*math.tan(math.radians(angle))
cylinder = cq.Solid.makeCylinder(radius, height)
return cylinder
# BUILD
# ----------------------------------------------------------------
reset_show()
angle = 30
def piece(listCone):
## construct general parts
shellOuter = cq.Solid.makeSphere(10).cut(cq.Solid.makeSphere(8))
pieceOuter = shellOuter
## generate the piece
for element in listCone:
## outer shell
obj = cone(10.01,angle)
obj = align(obj, element)
pieceOuter = pieceOuter.cut(obj)
return pieceOuter
center = piece([
(0,1,0),
(0,-1,0),
(1,0,0),
(-1,0,0)
])
show_object(center, options=dict(alpha=0.5,color='red'))
Maybe you can help me out :)
The solution I came up with has the following fixes:
Many thanks to Jeremy Wright, who helped me in the CadQuery Discussion Group.