-
Notifications
You must be signed in to change notification settings - Fork 15
Gear generator classes #19
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
Merged
Merged
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 39dd06b
Add bevel gear
Jojain 257c409
Update gear_generator.py
Jojain 387743a
Update gear_generator.py
Jojain 73fef2f
Update gear_generator.py
Jojain e447ff2
add crown gear
Jojain 6aaa39e
Create rack_gear.py
Jojain 1fd4cf4
add docstring, improve organisation
Jojain ca3f373
changed imports
Jojain b6da683
add readme and setup files
Jojain ce9837d
minor corrections
Jojain b9f8b6d
moved to module dir structure
Jojain 3a5c0f4
update functions calls
Jojain 02b6935
Update __init__.py
Jojain 83845f4
testing import solutions
Jojain 36829b1
Update main.py
Jojain b4bdb4a
made plugin functions work
Jojain 83978c6
setup test functions
Jojain 69d89db
push
Jojain b45c856
Update .gitignore
Jojain 63aba81
add working tests
Jojain 78102b3
add auto link of methods in __init__
Jojain 7b46b37
change function names
Jojain cc92cad
Update cutter_objects.py
Jojain ea6e4c6
add register fct to modules
Jojain ef86b88
add imgs for readme
Jojain c4b05ab
finalize PR version
Jojain 0e7c2ce
Update README.md
Jojain 713933d
Update test_gear_generator.py
Jojain 66ad25a
Merge branch 'dev-gear-generator' of https://github.com/Jojain/cadque…
Jojain ac4c56e
Rewrote the plugin in OOP
Jojain 8c6a7e9
Update bevel_gear.PNG
Jojain 44e5fd6
Update README.md
Jojain 264e2c0
Update main.py
Jojain 9ef78ff
correction of error in rotation angle
Jojain c291f58
Update test_gear_generator.py
Jojain 8600584
clean up
marcus7070 a2a9725
Merge branch 'main' into jojain/gears
marcus7070 c00d69c
Update test_gear_generator.py
Jojain fe27f47
Merge branch 'gear-generator-classes' of https://github.com/Jojain/ca…
Jojain a37287b
Trying hacky stuff
Jojain 308e8fd
Revert "Trying hacky stuff"
Jojain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,3 +127,5 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
*.ipynb | ||
plugins/gear_generator/src/gear-generator/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"python.pythonPath": "D:\\Programmes\\miniconda\\envs\\cq\\python.exe" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
|
||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .main import * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.