from freecad import part

This commit is contained in:
looooo
2024-01-02 23:24:31 +01:00
parent 5231798cad
commit d8034c0a86
15 changed files with 113 additions and 113 deletions

View File

@@ -178,11 +178,11 @@
"5. erstellen einer B-Spline Kurve welche durch die Kinematik T transformiert wird\n",
"\n",
"```python\n",
"c_1 = Part.BSplineCurve()\n",
"c_1 = part.BSplineCurve()\n",
"c_1.interpolate(Points=xyz_1)\n",
"c_1 = c_1.toShape()\n",
"\n",
"Part.show(c_1.transformShape(T))\n",
"part.show(c_1.transformShape(T))\n",
"```\n",
"\n",
"6. Loft anwenden auf die erstellten BSpline Kurven\n",

View File

@@ -20,7 +20,7 @@ import os
import sys
from freecad import app
import Part
from freecad import part
import numpy as np
import math
@@ -142,7 +142,7 @@ class BaseGear(object):
def part_arc_from_points_and_center(p_1, p_2, m):
p_1, p_12, p_2 = arc_from_points_and_center(p_1, p_2, m)
return Part.Arc(
return part.Arc(
app.Vector(*p_1, 0.0), app.Vector(*p_12, 0.0), app.Vector(*p_2, 0.0)
)
@@ -161,19 +161,19 @@ def helicalextrusion(face, height, angle, double_helix=False):
cone_angle = 0
direction = bool(angle < 0)
if double_helix:
spine = Part.makeHelix(pitch, height / 2.0, radius, cone_angle, direction)
spine = part.makeHelix(pitch, height / 2.0, radius, cone_angle, direction)
spine.translate(app.Vector(0, 0, height / 2.0))
face = face.translated(
app.Vector(0, 0, height / 2.0)
) # don't transform our argument
else:
spine = Part.makeHelix(pitch, height, radius, cone_angle, direction)
spine = part.makeHelix(pitch, height, radius, cone_angle, direction)
def make_pipe(path, profile):
"""
returns (shell, last_wire)
"""
mkPS = Part.BRepOffsetAPI.MakePipeShell(path)
mkPS = part.BRepOffsetAPI.MakePipeShell(path)
mkPS.setFrenetMode(
True
) # otherwise, the profile's normal would follow the path
@@ -187,7 +187,7 @@ def helicalextrusion(face, height, angle, double_helix=False):
pipe_shell, top_wire = make_pipe(spine, wire)
shell_faces.extend(pipe_shell.Faces)
top_wires.append(top_wire)
top_face = Part.Face(top_wires)
top_face = part.Face(top_wires)
shell_faces.append(top_face)
if double_helix:
origin = app.Vector(0, 0, height / 2.0)
@@ -197,34 +197,34 @@ def helicalextrusion(face, height, angle, double_helix=False):
shell_faces.extend(bottom_faces)
# TODO: why the heck is makeShell from this empty after mirroring?
# ... and why the heck does it work when making an intermediate compound???
hacky_intermediate_compound = Part.makeCompound(shell_faces)
hacky_intermediate_compound = part.makeCompound(shell_faces)
shell_faces = hacky_intermediate_compound.Faces
else:
shell_faces.append(face) # the bottom is what we extruded
shell = Part.makeShell(shell_faces)
shell = part.makeShell(shell_faces)
# shell.sewShape() # fill gaps that may result from accumulated tolerances. Needed?
# shell = shell.removeSplitter() # refine. Needed?
return Part.makeSolid(shell)
return part.makeSolid(shell)
def make_face(edge1, edge2):
v1, v2 = edge1.Vertexes
v3, v4 = edge2.Vertexes
e1 = Part.Wire(edge1)
e2 = Part.LineSegment(v1.Point, v3.Point).toShape().Edges[0]
e1 = part.Wire(edge1)
e2 = part.LineSegment(v1.Point, v3.Point).toShape().Edges[0]
e3 = edge2
e4 = Part.LineSegment(v4.Point, v2.Point).toShape().Edges[0]
w = Part.Wire([e3, e4, e1, e2])
return Part.Face(w)
e4 = part.LineSegment(v4.Point, v2.Point).toShape().Edges[0]
w = part.Wire([e3, e4, e1, e2])
return part.Face(w)
def make_bspline_wire(pts):
wi = []
for i in pts:
out = Part.BSplineCurve()
out = part.BSplineCurve()
out.interpolate(list(map(fcvec, i)))
wi.append(out.toShape())
return Part.Wire(wi)
return part.Wire(wi)
def points_to_wire(pts):
@@ -232,12 +232,12 @@ def points_to_wire(pts):
for i in pts:
if len(i) == 2:
# straight edge
out = Part.LineSegment(*list(map(fcvec, i)))
out = part.LineSegment(*list(map(fcvec, i)))
else:
out = Part.BSplineCurve()
out = part.BSplineCurve()
out.interpolate(list(map(fcvec, i)))
wire.append(out.toShape())
return Part.Wire(wire)
return part.Wire(wire)
def rotate_tooth(base_tooth, num_teeth):
@@ -246,7 +246,7 @@ def rotate_tooth(base_tooth, num_teeth):
flat_shape = [base_tooth]
for t in range(num_teeth - 1):
flat_shape.append(flat_shape[-1].transformGeometry(rot))
return Part.Wire(flat_shape)
return part.Wire(flat_shape)
def fillet_between_edges(edge_1, edge_2, radius):
@@ -268,12 +268,12 @@ def fillet_between_edges(edge_1, edge_2, radius):
t1 = p2 - p1
t2 = p4 - p3
n = t1.cross(t2)
pln = Part.Plane(edge_1.valueAt(edge_1.FirstParameter), n)
pln = part.Plane(edge_1.valueAt(edge_1.FirstParameter), n)
api.init(edge_1, edge_2, pln)
if api.perform(radius) > 0:
p0 = (p2 + p3) / 2
fillet, e1, e2 = api.result(p0)
return Part.Wire([e1, fillet, e2]).Edges
return part.Wire([e1, fillet, e2]).Edges
else:
return None

View File

@@ -17,7 +17,7 @@
# ***************************************************************************
from freecad import app
import Part
from freecad import part
import numpy as np
from pygears.bevel_tooth import BevelTooth
@@ -156,7 +156,7 @@ class BevelGear(BaseGear):
for pt in pts
]
wires.append(make_bspline_wire(points))
shape = Part.makeLoft(wires, True)
shape = part.makeLoft(wires, True)
if fp.reset_origin:
mat = app.Matrix()
mat.A33 = -1
@@ -196,10 +196,10 @@ class BevelGear(BaseGear):
surfs = []
w_t = zip(*w)
for i in w_t:
b = Part.BSplineSurface()
b = part.BSplineSurface()
b.interpolate(i)
surfs.append(b)
return Part.Shape(surfs)
return part.Shape(surfs)
def spherical_rot(self, point, phi):
new_phi = np.sqrt(np.linalg.norm(point)) * phi

View File

@@ -20,7 +20,7 @@ import os
import sys
from freecad import app
import Part
from freecad import part
import numpy as np
@@ -108,10 +108,10 @@ class CrownGear(BaseGear):
def generate_gear_shape(self, fp):
inner_diameter = fp.module.Value * fp.teeth
outer_diameter = inner_diameter + fp.height.Value * 2
inner_circle = Part.Wire(Part.makeCircle(inner_diameter / 2.0))
outer_circle = Part.Wire(Part.makeCircle(outer_diameter / 2.0))
inner_circle = part.Wire(part.makeCircle(inner_diameter / 2.0))
outer_circle = part.Wire(part.makeCircle(outer_diameter / 2.0))
inner_circle.reverse()
face = Part.Face([outer_circle, inner_circle])
face = part.Face([outer_circle, inner_circle])
solid = face.extrude(app.Vector([0.0, 0.0, -fp.thickness.Value]))
if fp.preview_mode:
return solid
@@ -131,9 +131,9 @@ class CrownGear(BaseGear):
polies = []
for r_i in np.linspace(r0, r1, fp.num_profiles):
pts = self.profile(m, r_i, rm, t_c, t_i, alpha_w, y0, y1, y2)
poly = Part.Wire(Part.makePolygon(list(map(fcvec, pts))))
poly = part.Wire(part.makePolygon(list(map(fcvec, pts))))
polies.append(poly)
loft = Part.makeLoft(polies, True)
loft = part.makeLoft(polies, True)
rot = app.Matrix()
rot.rotateZ(2 * np.pi / t)
cut_shapes = []

View File

@@ -17,7 +17,7 @@
# ***************************************************************************
from freecad import app
import Part
from freecad import part
import numpy as np
from pygears.cycloid_tooth import CycloidTooth
@@ -178,12 +178,12 @@ class CycloidGear(BaseGear):
edges = edges[edge_range[0] : edge_range[1]]
edges = [e for e in edges if e is not None]
tooth = Part.Wire(edges)
tooth = part.Wire(edges)
profile = rotate_tooth(tooth, fp.teeth)
if fp.height.Value == 0:
return profile
base = Part.Face(profile)
base = part.Face(profile)
if fp.beta.Value == 0:
return base.extrude(app.Vector(0, 0, fp.height.Value))
else:

View File

@@ -20,7 +20,7 @@ import os
import sys
from freecad import app
import Part
from freecad import part
import numpy as np
@@ -174,7 +174,7 @@ class CycloidGearRack(BaseGear):
p_start = np.array(tooth_edges[1].firstVertex().Point[:-1])
p_start += np.array([0, np.pi * m])
edge = points_to_wire([[p_end, p_start]]).Edges
tooth = Part.Wire(tooth_edges[1:-1] + edge)
tooth = part.Wire(tooth_edges[1:-1] + edge)
teeth = [tooth]
for i in range(obj.teeth - 1):
@@ -182,13 +182,13 @@ class CycloidGearRack(BaseGear):
tooth.translate(app.Vector(0, np.pi * m, 0))
teeth.append(tooth)
teeth[-1] = Part.Wire(teeth[-1].Edges[:-1])
teeth[-1] = part.Wire(teeth[-1].Edges[:-1])
if obj.add_endings:
teeth = [Part.Wire(tooth_edges[0])] + teeth
teeth = [part.Wire(tooth_edges[0])] + teeth
last_edge = tooth_edges[-1]
last_edge.translate(app.Vector(0, np.pi * m * (obj.teeth - 1), 0))
teeth = teeth + [Part.Wire(last_edge)]
teeth = teeth + [part.Wire(last_edge)]
p_start = np.array(teeth[0].Edges[0].firstVertex().Point[:-1])
p_end = np.array(teeth[-1].Edges[-1].lastVertex().Point[:-1])
@@ -201,29 +201,29 @@ class CycloidGearRack(BaseGear):
bottom = points_to_wire([line6, line7, line8])
pol = Part.Wire([bottom] + teeth)
pol = part.Wire([bottom] + teeth)
if obj.height.Value == 0:
return pol
elif obj.beta.Value == 0:
face = Part.Face(Part.Wire(pol))
face = part.Face(part.Wire(pol))
return face.extrude(fcvec([0.0, 0.0, obj.height.Value]))
elif obj.double_helix:
beta = obj.beta.Value * np.pi / 180.0
pol2 = Part.Wire(pol)
pol2 = part.Wire(pol)
pol2.translate(
fcvec([0.0, np.tan(beta) * obj.height.Value / 2, obj.height.Value / 2])
)
pol3 = Part.Wire(pol)
pol3 = part.Wire(pol)
pol3.translate(fcvec([0.0, 0.0, obj.height.Value]))
return Part.makeLoft([pol, pol2, pol3], True, True)
return part.makeLoft([pol, pol2, pol3], True, True)
else:
beta = obj.beta.Value * np.pi / 180.0
pol2 = Part.Wire(pol)
pol2 = part.Wire(pol)
pol2.translate(
fcvec([0.0, np.tan(beta) * obj.height.Value, obj.height.Value])
)
return Part.makeLoft([pol, pol2], True)
return part.makeLoft([pol, pol2], True)
def __getstate__(self):
return None

View File

@@ -19,8 +19,8 @@
# this file is only for backwards compatibility, and will be deleted in the future
from warnings import warn
warn('This file is deprecated and will be deleted in the future', DeprecationWarning, stacklevel=2)
from freecad import app
app.Console.PrintWarning("This file is deprecated, this warning is a very bad sign ;)")
from .timinggear_t import TimingGearT
from .involutegear import InvoluteGear

View File

@@ -21,7 +21,7 @@ import math
import numpy as np
from freecad import app
import Part
from freecad import part
from pygears.bevel_tooth import BevelTooth
from pygears._functions import rotation
@@ -194,8 +194,8 @@ class HypoCycloidGear(BaseGear):
minRadius = self.calc_pressure_limit(p, d, e, n, minAngle * math.pi / 180.0)
maxRadius = self.calc_pressure_limit(p, d, e, n, maxAngle * math.pi / 180.0)
# unused
# Part.Wire(Part.makeCircle(minRadius, app.Vector(-e, 0, 0)))
# Part.Wire(Part.makeCircle(maxRadius, app.Vector(-e, 0, 0)))
# part.Wire(part.makeCircle(minRadius, app.Vector(-e, 0, 0)))
# part.Wire(part.makeCircle(maxRadius, app.Vector(-e, 0, 0)))
app.Console.PrintMessage("Generating cam disk\r\n")
# generate the cam profile - note: shifted in -x by eccentricicy amount
@@ -220,11 +220,11 @@ class HypoCycloidGear(BaseGear):
wi = wi.transformGeometry(mat)
wires.append(wi)
cam = Part.Face(Part.Wire(wires))
cam = part.Face(part.Wire(wires))
# add a circle in the center of the cam
if fp.hole_radius.Value:
centerCircle = Part.Face(
Part.Wire(Part.makeCircle(fp.hole_radius.Value, app.Vector(-e, 0, 0)))
centerCircle = part.Face(
part.Wire(part.makeCircle(fp.hole_radius.Value, app.Vector(-e, 0, 0)))
)
cam = cam.cut(centerCircle)
@@ -260,9 +260,9 @@ class HypoCycloidGear(BaseGear):
for i in range(0, n + 1):
x = p * n * math.cos(2 * math.pi / (n + 1) * i)
y = p * n * math.sin(2 * math.pi / (n + 1) * i)
pins.append(Part.Wire(Part.makeCircle(d / 2, app.Vector(x, y, 0))))
pins.append(part.Wire(part.makeCircle(d / 2, app.Vector(x, y, 0))))
pins = Part.Face(pins)
pins = part.Face(pins)
z_offset = -fp.pin_height.Value / 2
if fp.center_pins == True:
@@ -279,4 +279,4 @@ class HypoCycloidGear(BaseGear):
to_be_fused.append(pins)
if to_be_fused:
return Part.makeCompound(to_be_fused)
return part.makeCompound(to_be_fused)

View File

@@ -19,7 +19,7 @@
import numpy as np
from freecad import app
import Part
from freecad import part
from pygears.involute_tooth import InvoluteTooth
from pygears._functions import rotation
@@ -191,7 +191,7 @@ class InternalInvoluteGear(BaseGear):
fp.da = "{}mm".format(fp.gear.df) # swap addednum and dedendum for "internal"
fp.df = "{}mm".format(fp.gear.da) # swap addednum and dedendum for "internal"
outer_circle = Part.Wire(Part.makeCircle(fp.outside_diameter / 2.0))
outer_circle = part.Wire(part.makeCircle(fp.outside_diameter / 2.0))
outer_circle.reverse()
if not fp.simple:
# head-fillet:
@@ -230,11 +230,11 @@ class InternalInvoluteGear(BaseGear):
edges = edges[edge_range[0] : edge_range[1]]
edges = [e for e in edges if e is not None]
tooth = Part.Wire(edges)
tooth = part.Wire(edges)
profile = rotate_tooth(tooth, fp.teeth)
if fp.height.Value == 0:
return Part.makeCompound([outer_circle, profile])
base = Part.Face([outer_circle, profile])
return part.makeCompound([outer_circle, profile])
base = part.Face([outer_circle, profile])
if fp.beta.Value == 0:
return base.extrude(app.Vector(0, 0, fp.height.Value))
else:
@@ -243,7 +243,7 @@ class InternalInvoluteGear(BaseGear):
base, fp.height.Value, twist_angle, fp.double_helix
)
else:
inner_circle = Part.Wire(Part.makeCircle(fp.dw / 2.0))
inner_circle = part.Wire(part.makeCircle(fp.dw / 2.0))
inner_circle.reverse()
base = Part.Face([outer_circle, inner_circle])
base = part.Face([outer_circle, inner_circle])
return base.extrude(app.Vector(0, 0, fp.height.Value))

View File

@@ -19,7 +19,7 @@
import numpy as np
from freecad import app
import Part
from freecad import part
from pygears.involute_tooth import InvoluteTooth
from pygears._functions import rotation
@@ -247,12 +247,12 @@ class InvoluteGear(BaseGear):
edges = edges[edge_range[0] : edge_range[1]]
edges = [e for e in edges if e is not None]
tooth = Part.Wire(edges)
tooth = part.Wire(edges)
profile = rotate_tooth(tooth, obj.teeth)
if obj.height.Value == 0:
return profile
base = Part.Face(profile)
base = part.Face(profile)
if obj.beta.Value == 0:
return base.extrude(app.Vector(0, 0, obj.height.Value))
else:
@@ -262,4 +262,4 @@ class InvoluteGear(BaseGear):
)
else:
rw = obj.gear.dw / 2
return Part.makeCylinder(rw, obj.height.Value)
return part.makeCylinder(rw, obj.height.Value)

View File

@@ -19,7 +19,7 @@
import numpy as np
from freecad import app
import Part
from freecad import part
from pygears.involute_tooth import InvoluteRack
from .basegear import BaseGear, fcvec, points_to_wire, insert_fillet
@@ -173,7 +173,7 @@ class InvoluteGearRack(BaseGear):
line3 = [p3, p4]
line4 = [p4, p5]
line5 = [p5, p6]
tooth = Part.Wire(points_to_wire([line1, line2, line3, line4, line5]))
tooth = part.Wire(points_to_wire([line1, line2, line3, line4, line5]))
edges = tooth.Edges
edges = insert_fillet(edges, 0, m * root_fillet)
@@ -186,7 +186,7 @@ class InvoluteGearRack(BaseGear):
p_start = np.array(tooth_edges[1].firstVertex().Point[:-1])
p_start += np.array([0, np.pi * m])
edge = points_to_wire([[p_end, p_start]]).Edges
tooth = Part.Wire(tooth_edges[1:-1] + edge)
tooth = part.Wire(tooth_edges[1:-1] + edge)
teeth = [tooth]
for i in range(obj.teeth - 1):
@@ -194,13 +194,13 @@ class InvoluteGearRack(BaseGear):
tooth.translate(app.Vector(0, np.pi * m, 0))
teeth.append(tooth)
teeth[-1] = Part.Wire(teeth[-1].Edges[:-1])
teeth[-1] = part.Wire(teeth[-1].Edges[:-1])
if obj.add_endings:
teeth = [Part.Wire(tooth_edges[0])] + teeth
teeth = [part.Wire(tooth_edges[0])] + teeth
last_edge = tooth_edges[-1]
last_edge.translate(app.Vector(0, np.pi * m * (obj.teeth - 1), 0))
teeth = teeth + [Part.Wire(last_edge)]
teeth = teeth + [part.Wire(last_edge)]
p_start = np.array(teeth[0].Edges[0].firstVertex().Point[:-1])
p_end = np.array(teeth[-1].Edges[-1].lastVertex().Point[:-1])
@@ -213,26 +213,26 @@ class InvoluteGearRack(BaseGear):
bottom = points_to_wire([line6, line7, line8])
pol = Part.Wire([bottom] + teeth)
pol = part.Wire([bottom] + teeth)
if obj.height.Value == 0:
return pol
elif obj.beta.Value == 0:
face = Part.Face(Part.Wire(pol))
face = part.Face(part.Wire(pol))
return face.extrude(fcvec([0.0, 0.0, obj.height.Value]))
elif obj.double_helix:
beta = obj.beta.Value * np.pi / 180.0
pol2 = Part.Wire(pol)
pol2 = part.Wire(pol)
pol2.translate(
fcvec([0.0, np.tan(beta) * obj.height.Value / 2, obj.height.Value / 2])
)
pol3 = Part.Wire(pol)
pol3 = part.Wire(pol)
pol3.translate(fcvec([0.0, 0.0, obj.height.Value]))
return Part.makeLoft([pol, pol2, pol3], True, True)
return part.makeLoft([pol, pol2, pol3], True, True)
else:
beta = obj.beta.Value * np.pi / 180.0
pol2 = Part.Wire(pol)
pol2 = part.Wire(pol)
pol2.translate(
fcvec([0.0, np.tan(beta) * obj.height.Value, obj.height.Value])
)
return Part.makeLoft([pol, pol2], True)
return part.makeLoft([pol, pol2], True)

View File

@@ -20,7 +20,7 @@ import numpy as np
import scipy as sp
from freecad import app
import Part
from freecad import part
from pygears.bevel_tooth import BevelTooth
from pygears._functions import rotation
@@ -95,30 +95,30 @@ class LanternGear(BaseGear):
xy1 = np.array([x, y]).T
p_1 = xy1[0]
p_1_end = xy1[-1]
bsp_1 = Part.BSplineCurve()
bsp_1 = part.BSplineCurve()
bsp_1.interpolate(list(map(fcvec, xy1)))
w_1 = bsp_1.toShape()
xy2 = xy1 * np.array([1.0, -1.0])
p_2 = xy2[0]
p_2_end = xy2[-1]
bsp_2 = Part.BSplineCurve()
bsp_2 = part.BSplineCurve()
bsp_2.interpolate(list(map(fcvec, xy2)))
w_2 = bsp_2.toShape()
p_12 = np.array([r_0 - r_r, 0.0])
arc = Part.Arc(
arc = part.Arc(
app.Vector(*p_1, 0.0), app.Vector(*p_12, 0.0), app.Vector(*p_2, 0.0)
).toShape()
rot = rotation(-np.pi * 2 / teeth)
p_3 = rot(np.array([p_2_end]))[0]
# l = Part.LineSegment(fcvec(p_1_end), fcvec(p_3)).toShape()
# l = part.LineSegment(fcvec(p_1_end), fcvec(p_3)).toShape()
l = part_arc_from_points_and_center(
p_1_end, p_3, np.array([0.0, 0.0])
).toShape()
w = Part.Wire([w_2, arc, w_1, l])
w = part.Wire([w_2, arc, w_1, l])
wires = [w]
rot = app.Matrix()
@@ -126,8 +126,8 @@ class LanternGear(BaseGear):
rot.rotateZ(np.pi * 2 / teeth)
wires.append(w.transformGeometry(rot))
wi = Part.Wire(wires)
wi = part.Wire(wires)
if fp.height.Value == 0:
return wi
else:
return Part.Face(wi).extrude(app.Vector(0, 0, fp.height))
return part.Face(wi).extrude(app.Vector(0, 0, fp.height))

View File

@@ -19,7 +19,7 @@
import numpy as np
from freecad import app
import Part
from freecad import part
from pygears._functions import reflection
@@ -176,7 +176,7 @@ class TimingGear(BaseGear):
arcs.append(part_arc_from_points_and_center(xn4, xn2, mn_34).toShape())
arcs.append(
Part.Arc(
part.Arc(
app.Vector(*xn2, 0.0),
app.Vector(0, rp - h, 0.0),
app.Vector(*x2, 0.0),
@@ -271,7 +271,7 @@ class TimingGear(BaseGear):
part_arc_from_points_and_center(x4, x6, np.array([0.0, 0.0])).toShape()
)
wire = Part.Wire(arcs)
wire = part.Wire(arcs)
wires = [wire]
rot = app.Matrix()
rot.rotateZ(np.pi * 2 / fp.teeth)
@@ -279,8 +279,8 @@ class TimingGear(BaseGear):
wire = wire.transformGeometry(rot)
wires.append(wire)
wi = Part.Wire(wires)
wi = part.Wire(wires)
if fp.height.Value == 0:
return wi
else:
return Part.Face(wi).extrude(app.Vector(0, 0, fp.height))
return part.Face(wi).extrude(app.Vector(0, 0, fp.height))

View File

@@ -21,7 +21,7 @@ import numpy as np
import scipy as sp
from freecad import app
import Part
from freecad import part
from pygears._functions import rotation, reflection
@@ -96,11 +96,11 @@ class TimingGearT(BaseGear):
rot = rotation(-gamma_0) # why is the rotation in wrong direction ???
p_5 = rot(np.array([p_1]))[0] # the rotation expects a list of points
l1 = Part.LineSegment(fcvec(p_1), fcvec(p_2)).toShape()
l2 = Part.LineSegment(fcvec(p_2), fcvec(p_3)).toShape()
l3 = Part.LineSegment(fcvec(p_3), fcvec(p_4)).toShape()
l4 = Part.LineSegment(fcvec(p_4), fcvec(p_5)).toShape()
w = Part.Wire([l1, l2, l3, l4])
l1 = part.LineSegment(fcvec(p_1), fcvec(p_2)).toShape()
l2 = part.LineSegment(fcvec(p_2), fcvec(p_3)).toShape()
l3 = part.LineSegment(fcvec(p_3), fcvec(p_4)).toShape()
l4 = part.LineSegment(fcvec(p_4), fcvec(p_5)).toShape()
w = part.Wire([l1, l2, l3, l4])
# now using a FreeCAD Matrix (this will turn in the right direction)
rot = app.Matrix()
@@ -109,9 +109,9 @@ class TimingGearT(BaseGear):
for i in range(teeth):
w = w.transformGeometry(rot)
wires.append(w.copy())
contour = Part.Wire(wires)
contour = part.Wire(wires)
if height == 0:
return contour
else:
face = Part.Face(Part.Wire(wires))
face = part.Face(part.Wire(wires))
return face.extrude(app.Vector(0.0, 0.0, height))

View File

@@ -19,7 +19,7 @@
import numpy as np
from freecad import app
import Part
from freecad import part
from pygears.involute_tooth import InvoluteTooth
from pygears._functions import rotation
@@ -101,7 +101,7 @@ class WormGear(BaseGear):
# 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(
c1 = part.makeCircle(
r_1,
app.Vector(0, 0, 0),
app.Vector(0, 0, 1),
@@ -113,14 +113,14 @@ class WormGear(BaseGear):
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 = 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(
c2 = part.makeCircle(
r_2,
app.Vector(0, 0, 0),
app.Vector(0, 0, 1),
@@ -132,11 +132,11 @@ class WormGear(BaseGear):
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 = part.BSplineCurve()
bsp2.interpolate(list(map(fcvec, points)))
bsp2 = bsp2.toShape()
wire = Part.Wire([c1, bsp1, c2, bsp2])
wire = part.Wire([c1, bsp1, c2, bsp2])
w_all = [wire]
rot = app.Matrix()
@@ -144,9 +144,9 @@ class WormGear(BaseGear):
for i in range(1, t):
w_all.append(w_all[-1].transformGeometry(rot))
full_wire = Part.Wire(w_all)
full_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)
shape = helicalextrusion(part.Face(full_wire), h, h * np.tan(beta) * 2 / d)
return shape