cqparts_fasteners.solidtypes.threads package¶
Submodules¶
cqparts_fasteners.solidtypes.threads.ball_screw module¶
-
class
cqparts_fasteners.solidtypes.threads.ball_screw.BallScrewThread(*args, **kwargs)¶ Bases:
cqparts_fasteners.solidtypes.threads.base.ThreadParametricObjectconstructor parameters:Parameters: - ball_radius (
float) – ball’s radius - diameter (
float) – thread’s diameter - inner (
bool) – if True, thread is to be cut from a solid to form an inner thread - lefthand (
bool) – if True, thread is spun in the opposite direction - length (
float) – thread’s length - min_vertices (
intor list(int)) – minimum vertices used cross-section’s wire - pilothole_radius (
float) – explicitly set pilothole radius, overridespilothole_ratio - pilothole_ratio (
float) – sets thread’s pilot hole using inner and outer thread radii: \(radius = inner + ratio \times (outer-inner)\) - pitch (
float) – thread’s pitch - start_count (
int) – number of thread starts
Search Criteria:
This object can be found with
find()andsearch()using the following search criteria.Key Value modulecqparts_fasteners.solidtypes.threads.basenameball_screw
-
build_profile()¶
-
get_radii()¶
- ball_radius (
cqparts_fasteners.solidtypes.threads.base module¶
-
class
cqparts_fasteners.solidtypes.threads.base.MinVerticiesParam(default=None, doc=None)¶ Bases:
cqparts.params.parameter.Parameter-
type(value)¶
-
-
class
cqparts_fasteners.solidtypes.threads.base.Thread(*args, **kwargs)¶ Bases:
cqparts.part.PartParametricObjectconstructor parameters:Parameters: - diameter (
float) – thread’s diameter - inner (
bool) – if True, thread is to be cut from a solid to form an inner thread - lefthand (
bool) – if True, thread is spun in the opposite direction - length (
float) – thread’s length - min_vertices (
intor list(int)) – minimum vertices used cross-section’s wire - pilothole_radius (
float) – explicitly set pilothole radius, overridespilothole_ratio - pilothole_ratio (
float) – sets thread’s pilot hole using inner and outer thread radii: \(radius = inner + ratio \times (outer-inner)\) - pitch (
float) – thread’s pitch - start_count (
int) – number of thread starts
-
build_profile()¶ Build the thread’s profile in a cadquery.Workplace as a wire on the \(XZ\) plane.
It will be used as an input to
profile_to_cross_sectionNote
This function must be overridden by the inheriting class in order to construct a thread.
Without overriding, this function rases a
NotImplementedErrorexception.example implementation:
import cadquery from cqparts.solidtypes.threads.base import Thread class MyThread(Thread): def build_profile(self): points = [ (2, 0), (3, 0.5), (3, 1), (2, 1.5), (2, 2) ] profile = cadquery.Workplane("XZ") \ .moveTo(*points[0]).polyline(points[1:]) return profile.wire() # .wire() is mandatory
Returns: thread profile as a wire on the XZ plane Return type: cadquery.WorkplaneWarning
Wire must be built on the \(XZ\) plane (as shown in the example). If it is not, the thread may not be generated correctly.
-
get_radii()¶ Get the inner and outer radii of the thread.
Returns: (<inner radius>, <outer radius>) Return type: tupleNote
Ideally this method is overridden in inheriting classes to mathematically determine the radii.
Default action is to generate the profile, then use the bounding box to determine min & max radii. However this method is prone to small numeric error.
-
make()¶
-
make_pilothole_cutter()¶ Make a solid to subtract from an interfacing solid to bore a pilot-hole.
-
make_simple()¶ Return a cylinder with the thread’s average radius & length.
\(radius = (inner_radius + outer_radius) / 2\)
-
profile¶ Buffered result of
build_profile()
- diameter (
-
cqparts_fasteners.solidtypes.threads.base.helical_path(pitch, length, radius, angle=0, lefthand=False)¶
-
cqparts_fasteners.solidtypes.threads.base.profile_to_cross_section(profile, lefthand=False, start_count=1, min_vertices=20)¶ Converts a thread profile to it’s equivalent cross-section.
Profile:
The thread profile contains a single wire along the XZ plane (note: wire will be projected onto the XZ plane; Y-coords will be ignored). The profile is expected to be of 1 thread rotation, so it’s height (along the Z-axis) is the thread’s “pitch”. If start_count > 1, then the profile will effectively be duplicated. The resulting cross-section is designed to be swept along a helical path with a pitch of the thread’s “lead” (which is {the height of the given profile} * start_count)
Method:
Each edge of the profile is converted to a bezier spline, aproximating its polar plot equivalent.
Resolution: (via min_vertices parameter)
Increasing the number of vertices used to define the bezier will increase the resulting thread’s accuracy, but cost more to render.
min_vertices may also be expressed as a list to set the number of vertices to set for each wire. where: len(min_vertices) == number of edges in profile
Example
import cadquery from cqparts_fasteners.solidtypes.threads.base import profile_to_cross_section from Helpers import show profile = cadquery.Workplane("XZ") \ .moveTo(1, 0) \ .lineTo(2, 1).lineTo(1, 2) \ .wire() cross_section = profile_to_cross_section(profile) show(profile) show(cross_section)
Will result in:
Parameters: - profile (
cadquery.Workplane) – workplane containing wire of thread profile. - lefthand (
bool) – if True, cross-section is made backwards. - start_count (
int) – profile is duplicated this many times. - min_vertices (
intortuple) – int or tuple of the desired resolution.
Returns: workplane with a face ready to be swept into a thread.
Return type: Raises: - TypeError – if a problem is found with the given parameters.
- ValueError – if
min_verticesis a list with elements not equal to the numbmer of wire edges.
- profile (
cqparts_fasteners.solidtypes.threads.iso68 module¶
-
class
cqparts_fasteners.solidtypes.threads.iso68.ISO68Thread(*args, **kwargs)¶ Bases:
cqparts_fasteners.solidtypes.threads.base.ThreadParametricObjectconstructor parameters:Parameters: - diameter (
float) – thread’s diameter - inner (
bool) – if True, thread is to be cut from a solid to form an inner thread - lefthand (
bool) – if True, thread is spun in the opposite direction - length (
float) – thread’s length - min_vertices (
intor list(int)) – minimum vertices used cross-section’s wire - pilothole_radius (
float) – explicitly set pilothole radius, overridespilothole_ratio - pilothole_ratio (
float) – sets thread’s pilot hole using inner and outer thread radii: \(radius = inner + ratio \times (outer-inner)\) - pitch (
float) – thread’s pitch - rounding_ratio (
float) – [no description] - start_count (
int) – number of thread starts
Search Criteria:
This object can be found with
find()andsearch()using the following search criteria.Key Value modulecqparts_fasteners.solidtypes.threads.basenameiso68
-
build_profile()¶ Build a thread profile in specified by ISO 68
-
get_radii()¶
- diameter (
cqparts_fasteners.solidtypes.threads.triangular module¶
-
class
cqparts_fasteners.solidtypes.threads.triangular.TriangularThread(*args, **kwargs)¶ Bases:
cqparts_fasteners.solidtypes.threads.base.ThreadParametricObjectconstructor parameters:Parameters: - angle (
float) – pressure angle of thread - diameter (
float) – thread’s diameter - diameter_core (
float) – diamter of core - inner (
bool) – if True, thread is to be cut from a solid to form an inner thread - lefthand (
bool) – if True, thread is spun in the opposite direction - length (
float) – thread’s length - min_vertices (
intor list(int)) – minimum vertices used cross-section’s wire - pilothole_radius (
float) – explicitly set pilothole radius, overridespilothole_ratio - pilothole_ratio (
float) – sets thread’s pilot hole using inner and outer thread radii: \(radius = inner + ratio \times (outer-inner)\) - pitch (
float) – thread’s pitch - start_count (
int) – number of thread starts
Search Criteria:
This object can be found with
find()andsearch()using the following search criteria.Key Value modulecqparts_fasteners.solidtypes.threads.basenametriangular
-
build_profile()¶
-
get_radii()¶
-
initialize_parameters()¶
- angle (
Module contents¶
-
class
cqparts_fasteners.solidtypes.threads.Thread(*args, **kwargs)¶ Bases:
cqparts.part.PartParametricObjectconstructor parameters:Parameters: - diameter (
float) – thread’s diameter - inner (
bool) – if True, thread is to be cut from a solid to form an inner thread - lefthand (
bool) – if True, thread is spun in the opposite direction - length (
float) – thread’s length - min_vertices (
intor list(int)) – minimum vertices used cross-section’s wire - pilothole_radius (
float) – explicitly set pilothole radius, overridespilothole_ratio - pilothole_ratio (
float) – sets thread’s pilot hole using inner and outer thread radii: \(radius = inner + ratio \times (outer-inner)\) - pitch (
float) – thread’s pitch - start_count (
int) – number of thread starts
-
build_profile()¶ Build the thread’s profile in a cadquery.Workplace as a wire on the \(XZ\) plane.
It will be used as an input to
profile_to_cross_sectionNote
This function must be overridden by the inheriting class in order to construct a thread.
Without overriding, this function rases a
NotImplementedErrorexception.example implementation:
import cadquery from cqparts.solidtypes.threads.base import Thread class MyThread(Thread): def build_profile(self): points = [ (2, 0), (3, 0.5), (3, 1), (2, 1.5), (2, 2) ] profile = cadquery.Workplane("XZ") \ .moveTo(*points[0]).polyline(points[1:]) return profile.wire() # .wire() is mandatory
Returns: thread profile as a wire on the XZ plane Return type: cadquery.WorkplaneWarning
Wire must be built on the \(XZ\) plane (as shown in the example). If it is not, the thread may not be generated correctly.
-
get_radii()¶ Get the inner and outer radii of the thread.
Returns: (<inner radius>, <outer radius>) Return type: tupleNote
Ideally this method is overridden in inheriting classes to mathematically determine the radii.
Default action is to generate the profile, then use the bounding box to determine min & max radii. However this method is prone to small numeric error.
-
make()¶
-
make_pilothole_cutter()¶ Make a solid to subtract from an interfacing solid to bore a pilot-hole.
-
make_simple()¶ Return a cylinder with the thread’s average radius & length.
\(radius = (inner_radius + outer_radius) / 2\)
-
profile¶ Buffered result of
build_profile()
- diameter (
-
cqparts_fasteners.solidtypes.threads.register(*args, **kwargs)¶
-
cqparts_fasteners.solidtypes.threads.find(*args, **kwargs)¶
-
cqparts_fasteners.solidtypes.threads.search(*args, **kwargs)¶