Example #1
0
 def seg(x, z):
     middle = geom.wireFromPrim(
         [Part.LineSegment(Vector(x, 200, pos.z), Vector(x, -200, pos.z))])
     place(middle, pos, angle)
     section = geom.sectionSegment(contour, middle)
     if section:
         return geom.wireFromPrim([section])
Example #2
0
def getDefaultTopTransition(contour, pos, defaultTransitionLength):
    """Generate default transitionEnd if no custom reference is provided"""
    line = geom.wireFromPrim(
        Part.LineSegment(Vector(pos.x + defaultTransitionLength, -150, pos.z),
                         Vector(pos.x + defaultTransitionLength, 150, pos.z)))
    (d, vs, es) = line.Shape.distToShape(contour.Shape)
    if d < 1e-5 and len(vs) > 1:
        return Part.Wire(Part.Shape([Part.LineSegment(vs[0][0], vs[1][0])]))
Example #3
0
def getTransitionStart(pos, profile, offset):
    """Generate the first profile"""
    profile = profile.wireAt(abs(pos.x - offset), pos + Vector(-offset, 0, 0))
    curve = profile.Edges[0]
    c1, c2, c3 = geom.bspDiscretize(curve.Curve, 3)
    return geom.wireFromPrim([
        c1, c2, c3,
        Part.LineSegment(Vector(profile.Edges[1].Vertexes[0].Point),
                         Vector(profile.Edges[1].Vertexes[1].Point))
    ])
Example #4
0
def getDefaultTop(pos, width, length, profile, angle, transitionLength):
    """Generate default contour and transitionEnd if no custom reference is provided"""
    startWidth = profile.widthAt(pos.x)
    a = Vector(pos.x, pos.y - startWidth / 2, pos.z)
    b = Vector(pos.x, pos.y + startWidth / 2, pos.z)
    c = Vector(b.x + transitionLength, b.y, b.z)
    d = Vector(c.x, pos.y + width / 2, c.z)
    e = Vector(d.x + length, d.y, d.z)
    f = Vector(e.x, e.y - width, e.z)
    g = Vector(f.x - length, f.y, f.z)
    h = Vector(g.x, a.y, g.z)
    l1 = Part.LineSegment(a, b)
    c2 = Part.BSplineCurve([b, c, d])
    l3 = Part.LineSegment(d, e)
    l4 = Part.LineSegment(e, f)
    l5 = Part.LineSegment(f, g)
    c6 = Part.BSplineCurve([g, h, a])
    contour = geom.wireFromPrim([l1, c2, l3, l4, l5, c6])
    transition = geom.wireFromPrim([Part.LineSegment(g, d)])
    return (place(contour, pos, angle), place(transition, pos, angle))
Example #5
0
def getTransitionEnd(trans, height, profile, tip):
    """Generate last profile"""

    height = height + trans.Length / 2
    a = trans.Vertexes[0].Point
    b = trans.Vertexes[1].Point
    l1 = Part.LineSegment(Vector(a), Vector(a.x, a.y, a.z - height))
    l2 = Part.LineSegment(Vector(b.x, b.y, b.z - height), Vector(b))
    l3 = Part.LineSegment(Vector(b), Vector(a))
    lX = geom.wireFromPrim([
        Part.LineSegment(Vector(a.x, a.y, a.z - height),
                         Vector(b.x, b.y, b.z - height))
    ])
    center = lX.CenterOfMass
    length = lX.Length
    arc = Part.Arc(Vector(a.x, a.y, a.z - height),
                   Vector(center.x, center.y, center.z - length / 2),
                   Vector(b.x, b.y, b.z - height))
    wire = geom.wireFromPrim([l1, arc, l2, l3])
    return wire
Example #6
0
def angledTopCut(pos, angle, voluteOffset):
    """Create solid to cleanup the top surface"""
    a = Vector(pos)
    c = Vector(a.x + 300 * math.cos(angle), a.y, a.z - 300 * math.sin(angle))
    d = Vector(c.x, c.y, abs(c.z))
    e = Vector(a.x - voluteOffset - 5, a.y, d.z)
    f = Vector(e.x, e.y, a.z)
    l1 = Part.LineSegment(a, c)
    l2 = Part.LineSegment(c, d)
    l3 = Part.LineSegment(d, e)
    l4 = Part.LineSegment(e, f)
    l5 = Part.LineSegment(f, a)
    wire = geom.wireFromPrim([l1, l2, l3, l4, l5])
    wire.translate(Vector(0, -150, 0))
    solid = Part.Face(wire).extrude(Vector(0, 300, 0))
    return solid
Example #7
0
def voluteCutFlat(pos, thickness, depth, angle, voluteOffset):
    """Generate solid to cut from the bottom of the construction"""
    width = 150
    length = 300
    pol = Part.makePolygon([
        Vector(pos.x - voluteOffset, -width, pos.z),
        Vector(pos.x - voluteOffset, width, pos.z),
        Vector(pos.x + length * math.cos(angle), width,
               pos.z - length * math.sin(angle)),
        Vector(pos.x + length * math.cos(angle), -width,
               pos.z - length * math.sin(angle)),
        Vector(pos.x - voluteOffset, -width, pos.z)
    ])
    height = (thickness + (0 if angle > 0 else depth)) * math.cos(angle)
    height = height - voluteOffset * math.sin(angle)
    pol.translate(Vector(0, 0, -height))
    wire = geom.wireFromPrim(pol)
    solid = Part.Face(wire).extrude(Vector(0, 0, -400))
    return solid
Example #8
0
def flatTopCut(pos, depth, transitionLength, voluteOffset):
    """Create solid to cleanup the top surface"""
    a = Vector(pos)
    b = Vector(a.x + transitionLength + depth, a.y, a.z - depth)
    c = Vector(a.x + 300, b.y, b.z)
    d = Vector(c.x, c.y, c.z + 2 * depth)
    e = Vector(a.x - voluteOffset - 5, a.y, d.z)
    f = Vector(e.x, e.y, a.z)
    curve = Part.BSplineCurve([
        a,
        Vector(a.x + transitionLength / 2, a.x, a.z),
        Vector(a.x + transitionLength / 2, a.x, a.z - depth), b
    ])
    l1 = Part.LineSegment(b, c)
    l2 = Part.LineSegment(c, d)
    l3 = Part.LineSegment(d, e)
    l4 = Part.LineSegment(e, f)
    l5 = Part.LineSegment(f, a)
    wire = geom.wireFromPrim([curve, l1, l2, l3, l4, l5])
    wire.translate(Vector(0, -150, 0))
    wire = Part.Face(wire).extrude(Vector(0, 300, 0))
    return wire