Esempio n. 1
0
def make_face(edge1, edge2):
    v1, v2 = edge1.Vertexes
    v3, v4 = edge2.Vertexes
    e1 = Wire(edge1)
    e2 = Line(v1.Point, v3.Point).toShape().Edges[0]
    e3 = edge2
    e4 = Line(v4.Point, v2.Point).toShape().Edges[0]
    w = Wire([e3, e4, e1, e2])
    return(Face(w))
Esempio n. 2
0
 def getPrincipalAx(self, ax='Z'):
     self.deleteArrow()
     from Part import Edge, Line
     O = FreeCAD.Vector()
     l = Line(O, FreeCAD.Vector(0, 0, 1000))
     if ax == 'X':
         l = Line(O, FreeCAD.Vector(1000, 0, 0))
     elif ax == 'Y':
         l = Line(O, FreeCAD.Vector(0, 1000, 0))
     self.Axis = Edge(l)
     self.form.lab1.setText("Principal: " + ax)
Esempio n. 3
0
 def selectAction(self):
     edged = [
         objex for objex in FreeCADGui.Selection.getSelectionEx()
         if frameCmd.edges([objex])
     ]
     if edged:
         self.Axis = frameCmd.edges([edged[0]])[0]
         self.deleteArrow()
         from polarUtilsCmd import arrow
         where = FreeCAD.Placement()
         where.Base = self.Axis.valueAt(self.Axis.LastParameter)
         where.Rotation = FreeCAD.Rotation(
             FreeCAD.Vector(0, 0, 1),
             self.Axis.tangentAt(self.Axis.LastParameter))
         size = [
             self.Axis.Length / 20.0, self.Axis.Length / 10.0,
             self.Axis.Length / 20.0
         ]
         self.arrow = arrow(pl=where,
                            scale=size,
                            offset=self.Axis.Length / 10.0)
         if self.Axis.curvatureAt(0):
             O = self.Axis.centerOfCurvatureAt(0)
             n = self.Axis.tangentAt(0).cross(self.Axis.normalAt(0))
             from Part import Edge, Line
             self.Axis = (Edge(
                 Line(FreeCAD.Vector(O), FreeCAD.Vector(O + n))))
         self.form.lab1.setText(edged[0].Object.Label + ": edge")
Esempio n. 4
0
def helicalextrusion(wire, height, angle):
    face_a = Face(wire)
    face_b = face_a.copy()
    face_transform = App.Matrix()
    face_transform.rotateZ(angle)
    face_transform.move(App.Vector(0, 0, height))
    face_b.transformShape(face_transform)
    spine = Wire(Line(fcvec([0., 0, 0]), fcvec([0, 0, height])).toShape())
    auxspine = makeHelix(height * 2 * pi / abs(angle), height, 10., 0,
                         bool(angle < 0))
    faces = [face_a, face_b]
    pipeshell = BRepOffsetAPI.MakePipeShell(spine)
    pipeshell.setSpineSupport(spine)
    pipeshell.add(wire)
    pipeshell.setAuxiliarySpine(auxspine, True, False)
    assert (pipeshell.isReady())
    pipeshell.build()
    faces.extend(pipeshell.shape().Faces)

    fullshell = Shell(faces)
    solid = Solid(fullshell)
    if solid.Volume < 0:
        solid.reverse()
    assert (solid.Volume >= 0)
    return (solid)
Esempio n. 5
0
 def selectAction(self):
     edged = [
         objex for objex in FreeCADGui.Selection.getSelectionEx()
         if fCmd.edges([objex])
     ]
     if edged:
         self.Axis = fCmd.edges([edged[0]])[0]
         self.deleteArrow()
         from uCmd import arrow
         where = FreeCAD.Placement()
         where.Base = self.Axis.valueAt(self.Axis.LastParameter)
         where.Rotation = FreeCAD.Rotation(
             FreeCAD.Vector(0, 0, 1),
             self.Axis.tangentAt(self.Axis.LastParameter))
         obj = edged[
             0].Object  #TARGET [solved]: make "where" deal with App::Parts
         if fCmd.isPartOfPart(obj):
             part = fCmd.isPartOfPart(obj)
             where = part.Placement.multiply(where)
         size = [
             self.Axis.Length / 20.0, self.Axis.Length / 10.0,
             self.Axis.Length / 20.0
         ]
         self.arrow = arrow(pl=where,
                            scale=size,
                            offset=self.Axis.Length / 10.0)
         if self.Axis.curvatureAt(0):
             O = self.Axis.centerOfCurvatureAt(0)
             n = self.Axis.tangentAt(0).cross(self.Axis.normalAt(0))
             from Part import Edge, Line
             self.Axis = (Edge(
                 Line(FreeCAD.Vector(O), FreeCAD.Vector(O + n))))
         self.form.lab1.setText(edged[0].Object.Label + ": edge")
Esempio n. 6
0
 def create_teeth(self, pts, pos, teeth):
     w1 = []
     pts = [pt * pos for pt in pts]
     rotated_pts = scaled_points
     rot = rotation3D(-2 * i * pi / teeth)
     for i in range(teeth - 1):
         rotated_pts = map(rot, rotated_pts)
         pts.append(numpy.array([pts[-1][-1], rotated_pts[0][0]]))
         pts += rotated_pts
     s = Wire(Shape(w1).Edges)
     wi = []
     for i in range(teeth):
         rot = App.Matrix()
         rot.rotateZ(2 * i * pi / teeth)
         tooth_rot = s.transformGeometry(rot)
         if i != 0:
             pt_0 = wi[-1].Edges[-1].Vertexes[0].Point
             pt_1 = tooth_rot.Edges[0].Vertexes[-1].Point
             wi.append(Wire([Line(pt_0, pt_1).toShape()]))
         wi.append(tooth_rot)
     pt_0 = wi[-1].Edges[-1].Vertexes[0].Point
     pt_1 = wi[0].Edges[0].Vertexes[-1].Point
     wi.append(Wire([Line(pt_0, pt_1).toShape()]))
     return (Wire(wi))
Esempio n. 7
0
def helicalextrusion(wire, height, angle):
    spine = Wire(Line(fcvec([0., 0, 0]), fcvec([0, 0, height])).toShape())
    auxspine = makeHelix(height * 2 * pi / abs(angle), height, 10., 0,
                         bool(angle < 0))
    solid = auxspine.makePipeShell([wire], True, True)
    return solid