cadquery icon indicating copy to clipboard operation
cadquery copied to clipboard

Planar surface

Open OmarZaki96 opened this issue 1 year ago • 1 comments
trafficstars

I have a simple code that generate a box

rectangular_prism = cq.Workplane("XY").box(1, 1, 1)

I want to add a rectangular planar selectable surface at the top face, with dimensions 0.5x0.5.

How can I create planar surfaces (or zero thickness surface) in CadQuery?

OmarZaki96 avatar May 23 '24 22:05 OmarZaki96

I'll plug the free function API here (you'll have to be on master):

from cadquery.occ_impl.shapes import *

# start with a box
b = box(1,1,1)

# split int top face and others
f_top = b.faces('>Z')
f_rest = b.faces('not >Z')

# create the new top face
f_new = f_top + plane(0.5,0.5).moved(f_top.Center())

# assemble into a solid
res = solid(f_rest,f_new)

show_object(res)

afbeelding

adam-urbanczyk avatar May 25 '24 19:05 adam-urbanczyk