can you share the parameters for the gear?
FC Gears: Feedback thread
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
Re: FC Gears: Feedback thread
Re: FC Gears: Feedback thread
Hello.
First of all many thanks for the WB.
I have a problem.
I need to have the shape for a worm gear, like those in the image on GitHub page:
https://github.com/looooo/freecad.gears ... m-gear.png
What parameters I have to pass to the function?
This is a try to obtain a TopoShape, as I've found some difficult to obtain a gear without having a DocumentObject created.
As the gear shape will be used a base for further transformations, like adding holes, and such things, creating a DocumentObject ionly to obtain the shape could lead to some memory problems if gear are many.
There is an alternative way to obtain the TopoShape?
I have done a similar job for the InvoluteGear() in:
https://forum.freecadweb.org/viewtopic.php?f=22&t=67476
TIA and Regards
Carlo D.
PS: I know that there is 0.20 final efforts this times, so a simple answer will suffice. I will wait for further discussion when you have more time.
First of all many thanks for the WB.
I have a problem.
I need to have the shape for a worm gear, like those in the image on GitHub page:
https://github.com/looooo/freecad.gears ... m-gear.png
What parameters I have to pass to the function?
Code: Select all
"""test_gear.py
This code was written as an sample code
for "FreeCAD Forum"
Author: Carlo Dormeletti
Copyright: 2020
Licence: CC BY-NC-ND 4.0
"""
import FreeCAD
from FreeCAD import Base, Vector
import Part
from math import pi, sin, cos, tan
import numpy as np
import DraftGeomUtils
from pygears.involute_tooth import InvoluteTooth, InvoluteRack
# check if needed
from pygears._functions import rotation3D, rotation, reflection, arc_from_points_and_center
from freecad.gears.features import helicalextrusion, points_to_wire, insert_fillet, rotate_tooth
DOC_NAME = "test_gear"
def activate_doc():
"""activate document"""
FreeCAD.setActiveDocument(DOC_NAME)
FreeCAD.ActiveDocument = FreeCAD.getDocument(DOC_NAME)
FreeCADGui.ActiveDocument = FreeCADGui.getDocument(DOC_NAME)
print("{0} activated".format(DOC_NAME))
def setview():
"""Rearrange View"""
DOC.recompute()
VIEW.viewAxometric()
VIEW.setAxisCross(True)
VIEW.fitAll()
def clear_doc():
"""Clear the active document deleting all the objects"""
for obj in DOC.Objects:
DOC.removeObject(obj.Name)
if FreeCAD.ActiveDocument is None:
FreeCAD.newDocument(DOC_NAME)
print("Document: {0} Created".format(DOC_NAME))
# test if there is an active document with a "proper" name
if FreeCAD.ActiveDocument.Name == DOC_NAME:
print("DOC_NAME exist")
else:
print("DOC_NAME is not active")
# test if there is a document with a "proper" name
try:
FreeCAD.getDocument(DOC_NAME)
except NameError:
print("No Document: {0}".format(DOC_NAME))
FreeCAD.newDocument(DOC_NAME)
print("Document Created".format(DOC_NAME))
DOC = FreeCAD.getDocument(DOC_NAME)
GUI = FreeCADGui.getDocument(DOC_NAME)
VIEW = GUI.ActiveView
#print("DOC : {0} GUI : {1}".format(DOC, GUI))
activate_doc()
#print(FreeCAD.ActiveDocument.Name)
clear_doc()
# copied from fcgear/freecad/gears/features.py as it is not exposed explicitly
def fcvec(x):
if len(x) == 2:
return(Vector(x[0], x[1], 0))
else:
return(Vector(x[0], x[1], x[2]))
worm_data = {
"teeth": 3,
"module": 1.0,
"pressure_angle": 20,
"height": 5.0,
"diameter": 5.0,
"clearance": 0.25,
"head": 0.0,
"reverse_pitch": 0, # [0 = False, 1 = True]
}
def worm_gear_shape(data):
m = data["module"]
d = data["diameter"]
t = data["teeth"]
h = data["height"]
gear = InvoluteRack()
clearance = data["clearance"]
head = data["head"]
alpha = data["pressure_angle"]
beta = np.arctan(m * t / d)
gear.beta = np.rad2deg(beta)
beta = -(data["reverse_pitch"] * 2 - 1) * (np.pi / 2 - beta)
r_1 = (d - (2 + 2 * clearance) * m) / 2
r_2 = (d + (2 + 2 * head) * m) / 2
z_a = (2 + head + clearance) * m * np.tan(np.deg2rad(alpha))
z_b = (m * np.pi - 4 * m * np.tan(np.deg2rad(alpha))) / 2
z_0 = clearance * m * np.tan(np.deg2rad(alpha))
z_1 = z_b - z_0
z_2 = z_1 + z_a
z_3 = z_2 + z_b - 2 * head * m * np.tan(np.deg2rad(alpha))
z_4 = z_3 + z_a
def helical_projection(r, z):
phi = 2 * z / m / t
x = r * np.cos(phi)
y = r * np.sin(phi)
z = 0 * y
return np.array([x, y, z]). T
# create a circle from phi=0 to phi_1 with r_1
phi_0 = 2 * z_0 / m / t
phi_1 = 2 * z_1 / m / t
c1 = Part.makeCircle(r_1, Vector(0, 0, 0),
Vector(0, 0, 1), np.rad2deg(phi_0), np.rad2deg(phi_1))
# create first bspline
z_values = np.linspace(z_1, z_2, 10)
r_values = np.linspace(r_1, r_2, 10)
points = helical_projection(r_values, z_values)
bsp1 = Part.BSplineCurve()
bsp1.interpolate(list(map(fcvec, points)))
bsp1 = bsp1.toShape()
# create circle from phi_2 to phi_3
phi_2 = 2 * z_2 / m / t
phi_3 = 2 * z_3 / m / t
c2 = Part.makeCircle(r_2, Vector(0, 0, 0), Vector(
0, 0, 1), np.rad2deg(phi_2), np.rad2deg(phi_3))
# create second bspline
z_values = np.linspace(z_3, z_4, 10)
r_values = np.linspace(r_2, r_1, 10)
points = helical_projection(r_values, z_values)
bsp2 = Part.BSplineCurve()
bsp2.interpolate(list(map(fcvec, points)))
bsp2 = bsp2.toShape()
wire = Part.Wire([c1, bsp1, c2, bsp2])
w_all = [wire]
rot = FreeCAD.Matrix()
rot.rotateZ(2 * np.pi / t)
for i in range(1, t):
w_all.append(w_all[-1].transformGeometry(rot))
full_wire = Part.Wire(Part.Wire(w_all))
if h == 0:
return full_wire
else:
shape = helicalextrusion(Part.Face(full_wire),
h,
h * np.tan(beta) * 2 / d)
return shape
# Script code
wgshape = worm_gear_shape(worm_data)
Part.show(wgshape, "worm_gear")
setview()
As the gear shape will be used a base for further transformations, like adding holes, and such things, creating a DocumentObject ionly to obtain the shape could lead to some memory problems if gear are many.
There is an alternative way to obtain the TopoShape?
I have done a similar job for the InvoluteGear() in:
https://forum.freecadweb.org/viewtopic.php?f=22&t=67476
TIA and Regards
Carlo D.
PS: I know that there is 0.20 final efforts this times, so a simple answer will suffice. I will wait for further discussion when you have more time.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: FC Gears: Feedback thread
Hi,
I'm creating involute gear with FC Gears, but actually teeth are not curved, but built by lines. I want 3D print gears, so I need real involute curve.
Any way to do this?
I'm creating involute gear with FC Gears, but actually teeth are not curved, but built by lines. I want 3D print gears, so I need real involute curve.
Any way to do this?
Re: FC Gears: Feedback thread
The edge is in fact curved. Just change the Deviation (on the View tab of the Property editor) to a lower value.
Re: FC Gears: Feedback thread
And you will print an STL file that is a bunch if triangle with a 3d printer that has discrete xyz movement and not a linear move that can do circles.
Probably you don't know very much your printing chain, or use an exotic 3d printing chain as hobby printer and many of FFF printers are not able do "real curves" as steps are not linear and do ever interpolations, some 3d printer don't have a G02, G03 command so you are limited to lines.
Or I'm being too much technical, see maybe STL specifications and inspect a GCODE file to see this thing.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: FC Gears: Feedback thread
It's 0.5 and can't be set lower.
I know this, but the same curve could be represented by 3 lines, or by 10, or by 20, thus producing better approximation.
Re: FC Gears: Feedback thread
Why not?
Besides, that's in the first place a display issue and is respected only if you export directly from the file menu. You have better control over the tesselation using Mesh workbench.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: FC Gears: Feedback thread
Who knows ))). Angular deviation minimum is limited to 50, and deviation to 0.5
That seems to be better! The main thing not to leave too detailed mesh setting, otherwise export of bigger objects will be affected.
Re: FC Gears: Feedback thread
Please elaborate: add your FreeCAD infos and describe how you change it.
What do you see as Angular deflection/Deviation in the attached file? I have set them to 20 and 0.4 respectively.
- Attachments
-
- cylinderTess.FCStd
- (3.09 KiB) Downloaded 30 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.