Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gear generator classes #19

Merged
merged 42 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
c77e1ca
Create gear_generator.py
Jojain Mar 21, 2021
39dd06b
Add bevel gear
Jojain Mar 21, 2021
257c409
Update gear_generator.py
Jojain Mar 21, 2021
387743a
Update gear_generator.py
Jojain Mar 21, 2021
73fef2f
Update gear_generator.py
Jojain Mar 21, 2021
e447ff2
add crown gear
Jojain Mar 21, 2021
6aaa39e
Create rack_gear.py
Jojain Mar 22, 2021
1fd4cf4
add docstring, improve organisation
Jojain Mar 25, 2021
ca3f373
changed imports
Jojain Mar 25, 2021
b6da683
add readme and setup files
Jojain Mar 25, 2021
ce9837d
minor corrections
Jojain Mar 25, 2021
b9f8b6d
moved to module dir structure
Jojain Mar 25, 2021
3a5c0f4
update functions calls
Jojain Mar 27, 2021
02b6935
Update __init__.py
Jojain Mar 27, 2021
83845f4
testing import solutions
Jojain Mar 27, 2021
36829b1
Update main.py
Jojain Mar 27, 2021
b4bdb4a
made plugin functions work
Jojain Mar 27, 2021
83978c6
setup test functions
Jojain Mar 27, 2021
69d89db
push
Jojain Mar 27, 2021
b45c856
Update .gitignore
Jojain Mar 27, 2021
63aba81
add working tests
Jojain Mar 27, 2021
78102b3
add auto link of methods in __init__
Jojain Mar 27, 2021
7b46b37
change function names
Jojain Mar 27, 2021
cc92cad
Update cutter_objects.py
Jojain Mar 27, 2021
ea6e4c6
add register fct to modules
Jojain Mar 27, 2021
ef86b88
add imgs for readme
Jojain Mar 27, 2021
c4b05ab
finalize PR version
Jojain Mar 27, 2021
0e7c2ce
Update README.md
Jojain Mar 27, 2021
713933d
Update test_gear_generator.py
Jojain Mar 27, 2021
66ad25a
Merge branch 'dev-gear-generator' of https://github.com/Jojain/cadque…
Jojain Mar 27, 2021
ac4c56e
Rewrote the plugin in OOP
Jojain Apr 22, 2021
8c6a7e9
Update bevel_gear.PNG
Jojain Apr 22, 2021
44e5fd6
Update README.md
Jojain Apr 22, 2021
264e2c0
Update main.py
Jojain Apr 22, 2021
9ef78ff
correction of error in rotation angle
Jojain Apr 24, 2021
c291f58
Update test_gear_generator.py
Jojain Apr 24, 2021
8600584
clean up
marcus7070 Apr 30, 2021
a2a9725
Merge branch 'main' into jojain/gears
marcus7070 Apr 30, 2021
c00d69c
Update test_gear_generator.py
Jojain May 2, 2021
fe27f47
Merge branch 'gear-generator-classes' of https://github.com/Jojain/ca…
Jojain May 2, 2021
a37287b
Trying hacky stuff
Jojain May 12, 2021
308e8fd
Revert "Trying hacky stuff"
Jojain May 12, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,5 @@ dmypy.json

# Pyre type checker
.pyre/
*.ipynb
marcus7070 marked this conversation as resolved.
Show resolved Hide resolved
plugins/gear_generator/src/gear-generator/
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.pythonPath": "D:\\Programmes\\miniconda\\envs\\cq\\python.exe"
}
73 changes: 73 additions & 0 deletions plugins/gear_generator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Gear generator

This plugin provide classes to create various gears.
As for now you can create these gears (all the gears are involutes):
* Spur gear

<img src="images/straight_gear.PNG" width="600"/>

* Helical gear

<img src="images/helical_gear.PNG" width="600"/>

* Bevel gear (straight and helical)

<img src="images/bevel_gear.PNG" width="600"/>

* Bevel gear system (straight and helical)

<img src="images/bevel_gear_system.PNG" width="600"/>


## Installation

To install this plugin, the following line should be used.

```
pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=gear_generator&subdirectory=plugins/gear_generator"
```


## Dependencies

This plugin has no dependencies other than the cadquery library.

## Usage

To use this plugin after it has been installed, import it and create Gear objects
```python
import cadquery as cq
import gear_generator

module = 2
nb_teeth = 12
width = 8
gear = Gear(module, nb_teeth, width).build() #Instantiate a gear object and call it's build method to get the gear in a cq.Workplane
```
<img src="images/readme_example.PNG" width="300"/>

Below is the list of implemented gear classes :
```python
Gear(args)
jmwright marked this conversation as resolved.
Show resolved Hide resolved
BevelGear(args)
BevelGearSystem(args)

#You can get info about the parameters by running
help(BevelGear)

Help on class Gear in module gear_generator.main:

class Gear(BaseGear)
| Gear(m: float, z: int, b: float, alpha: float = 20, helix_angle: float = 0, raw: bool = False)
|
| Base gear class
| This class stores attributes that are shared by any types of gear
| Other gear classes inherit from this class
|
| Attributes :
| m : gear modulus
| b : gear tooth facewidth
| z : gear number of teeth
| p : gear pitch
-- Suite --
jmwright marked this conversation as resolved.
Show resolved Hide resolved
```
1 change: 1 addition & 0 deletions plugins/gear_generator/gear_generator/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .main import *
48 changes: 48 additions & 0 deletions plugins/gear_generator/gear_generator/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from math import cos, sin, radians, acos
import cadquery as cq

def involute(r: float, sign: int = 1):
"""
Defines an involute curve to create the flanks of the involute gears

Args:
r : Radius of the involute (for a gear it's the pitch radius)
sign : 1 or -1 , to draw the involute in positive or negative direction

Returns:
x,y -> tuple() : 2-tuple of x and y coordinates in space
"""
def curve(t):
x = r*(cos(t) + t*sin(t))
y = r*(sin(t) - t*cos(t))
return x,sign*y
return curve

def spherical_involute(delta, delta_b, R):
"""
Equation of the spherical involute that lies on a sphere

Args:
delta : the function variable, goes from the gear root cone angle to the gear tip cone angle
delta_b : angle of the base cone
R : radius of the associated sphere

Returns:
x,y,z -> tuple() : 3-tuple of x and y and z coordinates in space
"""
theta = acos(cos(delta)/cos(delta_b))/sin(delta_b)
x = R*cos(theta*sin(delta_b))*sin(delta_b)*cos(theta) - R*sin(theta*sin(delta_b))* - sin(theta)
y = R*cos(theta*sin(delta_b))*sin(delta_b)*sin(theta) - R*sin(theta*sin(delta_b))* cos(theta)
z = R*cos(theta*sin(delta_b))*cos(delta_b)
return x,y,z



def rotate_vector_2D(vector: cq.Vector, angle: float):
"""
Rotates a 2D cq.Vector `vector`by an angle of `angle` in degrees
"""
angle = radians(angle)
x = cos(angle)*vector.x - sin(angle)*vector.y
y = sin(angle)*vector.x + cos(angle)*vector.y
return cq.Vector((x,y))
Loading