Workplane confusion

25 views
Skip to first unread message

Monty Zukowski

unread,
Mar 23, 2026, 5:10:17 PM (2 days ago) Mar 23
to CadQuery
I can do this to get a cylinder with a chamfered edge:

c = cq.Workplane("XY").cylinder(cylinder_OD-wall_thickness,thickness).edges(">Z").chamfer(4)

And that's great, but I was constructing an object with a script like this:


t = torus(cylinder_OD-wall_thickness/2.0,wall_thickness/2.0)
b = box(cylinder_OD,fin_thickness,thickness/2.0)+box(fin_thickness,cylinder_OD,thickness/2.0)
c = cylinder(cylinder_OD-wall_thickness,thickness)
c = c.translate((0,0,-thickness/2.0))
d = (cylinder(die_OD,thickness) - cylinder(cylinder_OD,thickness)).translate((0,0,-thickness/2.0))
result = b-t+c+d

And that works fine, but if I try to get that cylinder to have the chamfered edge, I get this error:


t = torus(cylinder_OD-wall_thickness/2.0,wall_thickness/2.0)
b = box(cylinder_OD,fin_thickness,thickness/2.0)+box(fin_thickness,cylinder_OD,thickness/2.0)
c = cylinder(cylinder_OD-wall_thickness,thickness)
c = c.translate((0,0,-thickness/2.0))
d = (cylinder(die_OD,thickness) - cylinder(cylinder_OD,thickness)).translate((0,0,-thickness/2.0))
result = b-t+c+d

I don't quite understand what is going wrong. Also, I couldn't figure out how to make the torus from a workplane object. 

Thanks,

Monty

Adam Urbanczyk

unread,
Mar 24, 2026, 3:51:49 AM (yesterday) Mar 24
to CadQuery
You did not post the error, nor did you post a MRE (i.e. what are the values of your parameter, I don't want to spend time guessing) including chamfering. If you need to chamfer a cylinder: cf = chamfer(c, c.edges('>Z'), 0.1). You can get anything out of Workplane using the val() or vals() method

Monty Zukowski

unread,
Mar 24, 2026, 11:27:52 AM (yesterday) Mar 24
to CadQuery
My apologies for leaving out the error message and MRE. Just for completeness here is the error:


File "/home/monty/code/extruder-cad/cylinder.py", line 23, in <module>
c = cylinder(cylinder_OD-wall_thickness,thickness).edges(">Z").chamfer(4)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Edge' object has no attribute 'chamfer'

And a complete example:

import cadquery as cq
from cadquery.func import torus,box, cylinder
from ocp_vscode import *


# measurements are in mm, hence the *25.4
die_OD = 4.2/2.0*25.4 # Radius of the plate
thickness = 1.0*25.4 # Thickness of the plate
wall_thickness = 3/8*25.4
fin_thickness = 1/8*25.4
cylinder_OD = 4.0/2.0*25.4 # Radius of extruded cylinder


t = torus(cylinder_OD-wall_thickness/2.0,wall_thickness/2.0)
b = box(cylinder_OD,fin_thickness,thickness/2.0)+box(fin_thickness,cylinder_OD,thickness/2.0)
c = cylinder(cylinder_OD-wall_thickness,thickness).edges(">Z").chamfer(4)

c = c.translate((0,0,-thickness/2.0))
d = (cylinder(die_OD,thickness) - cylinder(cylinder_OD,thickness)).translate((0,0,-thickness/2.0))
# result = b-t+c+d

show(b-t)



And with your suggestion, this works:


import cadquery as cq
from cadquery.func import torus,box, cylinder, chamfer
from ocp_vscode import *

# measurements are in mm, hence the *25.4
die_OD = 4.2/2.0*25.4 # Radius of the plate
thickness = 1.0*25.4 # Thickness of the plate
wall_thickness = 3/8*25.4
fin_thickness = 1/8*25.4
cylinder_OD = 4.0/2.0*25.4 # Radius of extruded cylinder


t = torus(cylinder_OD-wall_thickness/2.0,wall_thickness/2.0)
b = box(cylinder_OD,fin_thickness,thickness/2.0)+box(fin_thickness,cylinder_OD,thickness/2.0)
c = cylinder(cylinder_OD-wall_thickness,thickness).translate((0,0,-thickness/2.0))#.edges(">Z").chamfer(4)
cf = chamfer(c, c.edges('>Z'), 4)

d = (cylinder(die_OD,thickness) - cylinder(cylinder_OD,thickness)).translate((0,0,-thickness/2.0))
result = b-t+cf+d

show(result)
Reply all
Reply to author
Forward
0 new messages