Dovetail, how to round the edge

29 views
Skip to first unread message

Khoroshyy Petro

unread,
Nov 11, 2024, 9:27:04 AM11/11/24
to CadQuery
Hi 
At the end of the email ther is a code for dovetail adapter of Zeiss Jena microscope.
I wander how can I roundup the dovetail edge, not to be so "sharp"
More like here, indicated by the R1 radius.
Thanks.
Petro.
image.png

0-----------
import cadquery as cq
from cadquery import exporters

# Parameters
Dlow = 41.8  # Lower diameter
Dup = 37.8   # Upper diameter
Din_m39 = 30.0  # Inner diameter m39 thread
H = 5.0      # Height

D_upper_cylinder = 56.0 # Upper cylinder diameter
D_internal_upper_cylinder = 36.0 # Inner diameter for upper cylinder (M36 thread)
H_upper_cylinder = 6.0 # Height of the upper cylinder

D_top_cylinder = 42.0 # Top cylinder diameter ready for m42x1 thread
H_top_cylinder = 5.0  # Height of the top cylinder

def dovetail(Dlow, Dup, Din_m39, H, D_upper_cylinder, D_internal_upper_cylinder, H_upper_cylinder, D_top_cylinder, H_top_cylinder):
    # Create the dovetail shape
    dovetail_part = (
        cq.Workplane("XY")
        .circle(Dlow / 2.0)  # Starting with the lower diameter
        .workplane(offset=H)  # Move up the height
        .circle(Dup / 2.0)  # Create the upper diameter
        .loft()  # Connect the two circles to create the outer surface of the dovetail
        #.faces(">Z")
        #.workplane()
        #.circle(Din_m39 / 2.0)  # Draw the inner diameter on the upper face
        #.pushPoints([(0, 0)])  # Specify the point where the circle is to be located
        #.circle(Din_m39 / 2.0)  # Draw another circle for the inner diameter at the base
        #.loft(combine=True)  # Create the inner surface of the dovetail
        #.cutThruAll()  # Cut the inside from the outside, leaving the hollow dovetail shape
    )
    #upper_cylinder_cut = (
    #    dovetail_part
    #    .faces(">Z")
    #    .workplane()
    #    .circle((Dup / 2.0)-1)
    #    .workplane(offset=1)
    #    .circle((Dup / 2.0)-1)
    #    .loft()
        #.faces(">Z")
        #.workplane()
        #.circle(D_internal_upper_cylinder / 2.0) # The inner diameter ready for the M36 thread
        #.loft(combine=True)
        #.cutThruAll()
    #)
   
    # Add the upper cylinder
    upper_cylinder = (
        dovetail_part
        #upper_cylinder_cut
        .faces(">Z")
        .workplane()
        .circle(D_upper_cylinder / 2.0)
        .workplane(offset=H_upper_cylinder)
        .circle(D_upper_cylinder / 2.0)
        .loft()
        #.faces(">Z")
        #.workplane()
        #.circle(D_internal_upper_cylinder / 2.0) # The inner diameter ready for the M36 thread
        #.loft(combine=True)
        #.cutThruAll()
    )

    # Add the top cylinder for m42x1 thread
    top_cylinder = (
        upper_cylinder
        .faces(">Z")
        .workplane()
        .circle(D_top_cylinder / 2.0)
        .workplane(offset=H_top_cylinder)
        .circle(D_top_cylinder / 2.0)
        .loft()
    )
#
    return top_cylinder

# Call the function and save the result
result = dovetail(Dlow, Dup, Din_m39, H, D_upper_cylinder, D_internal_upper_cylinder, H_upper_cylinder, D_top_cylinder, H_upper_cylinder, )
result = result.faces(">Z").workplane().hole(35)

exporters.export(result, 'dovetail_adapter.step')
exporters.export(result, 'dovetail_adapter.svg')
result

--
______________________________
Petro Khoroshyy

Lorenz

unread,
Nov 11, 2024, 10:53:22 AM11/11/24
to CadQuery
Try RadiusNthSelector(-1) to select the largest radius (of the two <Z edges)

result = result.edges("<Z").edges(cq.selectors.RadiusNthSelector(-1)).fillet(0.5)


Another approach is to sketch the profile and use revolve:

import cadquery as cq


# Parameters
Dlow = 41.8  # Lower diameter
Dup = 37.8  # Upper diameter
Din_m39 = 30.0  # Inner diameter m39 thread
H = 5.0  # Height

D_upper_cylinder = 56.0  # Upper cylinder diameter
D_internal_upper_cylinder = 36.0  # Inner diameter for upper cylinder (M36 thread)
H_upper_cylinder = 6.0  # Height of the upper cylinder

D_top_cylinder = 42.0  # Top cylinder diameter ready for m42x1 thread
H_top_cylinder = 5.0  # Height of the top cylinder
D_hole = 35

pts = [
    (D_hole / 2, 0),
    (Dlow / 2, 0),
    (Dup / 2, H),
    (D_upper_cylinder / 2, H),
    (D_upper_cylinder / 2, H + H_upper_cylinder),
    (D_top_cylinder / 2, H + H_upper_cylinder),
    (D_top_cylinder / 2, H + H_upper_cylinder + H_top_cylinder),
    (D_hole / 2, H + H_upper_cylinder + H_top_cylinder),
]


sk1 = cq.Sketch().polygon(pts).vertices("<Y").vertices(">X").fillet(0.5)

result = cq.Workplane("XZ").placeSketch(sk1).revolve(360, (0, 0, 0), (0, 1, 0))

Petro

unread,
Nov 12, 2024, 4:06:18 AM11/12/24
to CadQuery
Thanks a lot.
Petro.
Reply all
Reply to author
Forward
0 new messages