Closed MarcWeber closed 1 year ago
Here is your objected as I intended cq_warehouse.threads to be used:
import cadquery as cq
from cq_warehouse.fastener import IsoThread
import cq_warehouse.extensions
height, D, cap_D, recess_width = 50, 12, 8, 7
ext = IsoThread(major_diameter=D, pitch=1, length=5)
int = IsoThread(major_diameter=cap_D, pitch=1, length=5, external=False)
outer_radius = ext.min_radius + 10
profile = (
cq.Sketch()
.push([(outer_radius / 2, height / 2)])
.rect(outer_radius, height)
.push(
[
(ext.min_radius + recess_width / 2, ext.length / 2),
(ext.min_radius + recess_width / 2, height - ext.length / 2),
]
)
.rect(recess_width, ext.length, mode="s")
.push([(int.min_radius / 2, height - int.length / 2)])
.rect(int.min_radius, int.length, mode="s")
.clean()
)
cyl = (
cq.Workplane("XZ")
.placeSketch(profile)
.revolve()
.add(
[
ext.cq_object,
ext.cq_object.moved(cq.Location(cq.Vector(0, 0, height - ext.length))),
int.cq_object.moved(cq.Location(cq.Vector(0, 0, height - int.length))),
]
)
)
show_object(cyl, "cyl")
show_object(profile, "profile")
.. shouldn't have used int
as a variable name..
I had a use case pencil like thing with protection cap I wanted to do with screws This is what I came up with with gumyr's help. And it works :-) The question is whether / how to integrate such features into core library only requiring threads no head no nuts etc.
The idea here is to have the workplane with a location and using that (and it's orientation) to build the screw with some 'gaps' cutting from original cylinder so that it just works. The external/internal ThreadCuttings thus build a cylinder to be cutted to then add the threads. However cutting from an object which has a thread added doesn't work well. Thus the cylinders to be cutted can be applied first, then all threads get added.
So this example illustrates how to move a thread using fastener.locate and building the cylinder to be cutted from workplane. Probably there are better ways but it works.