Example #1
0
 def EndPolyline():
     global Entities, Vertices
     count = len(Entities) - 1
     part = curve.PolyLine(Vertices).setProp(count)
     part.dxftype = 'Polyline'
     Entities[-1] = part
     Vertices = []
Example #2
0
def run():
    linewidth(2)
    clear()
    flat()
    draw(origin())
    draw(F, color=blue)
    drawNumbers(F, color=blue)
    draw(PL, color=red)
    draw(PL.coords, color=red)
    drawNumbers(PL.coords, color=red)
    return

    if ack("Spread point evenly?"):
        at = PL.atLength(PL.nparts)
        X = PL.pointsAt(at)
        PL2 = curve.PolyLine(X)
        clear()
        draw(PL2, color=blue)
        draw(PL2.coords, color=blue)
Example #3
0
def show():
    """Accept the data and draw according to them"""
    clear()
    dialog.acceptData()
    globals().update(dialog.results)

    PL = createSpiralCurve(turns, nmod)
    drawSpiralCurves(PL, nwires, red, blue)

    if spread:
        at = PL.atLength(PL.nparts)
        X = PL.pointsAt(at)
        PL = curve.PolyLine(X)
        clear()
        drawSpiralCurves(PL, nwires, blue, red)

    if sweep:

        CS = createCrossSection()
        draw(CS)

        draw(CS)
        wait()
        structure = CS.sweep(PL,
                             normal=[1., 0., 0.],
                             upvector=eval(cross_upvector),
                             avgdir=True)
        clear()
        smoothwire()
        draw(structure, color='red', bkcolor='cyan')

        if nwires > 1:
            structure = structure.toFormex().rosette(nwires,
                                                     360. / nwires).toMesh()
            draw(structure, color='orange')

    if flyalong:
        flyAlong(PL.scale(1.1).trl([0.0, 0.0, 0.2]),
                 upvector=[0., 0., 1.],
                 sleeptime=0.1)

        view('front')
Example #4
0
def createSpiralCurve(turns, nmod):
    F = Formex(origin()).replic(nmod, 1., 0).scale(turns * 2 * pi / nmod)
    a, b, c = coeffs
    rfunc_defs = {
        'constant': lambda x: a,
        'linear (Archimedes)': lambda x: a + b * x,
        'quadratic': lambda x: a + b * x + c * x * x,
        'exponential (equi-angular)': lambda x: a + b * exp(c * x),
        #        'custom' :                     lambda x: a + b * sqrt(c*x),
    }

    rf = rfunc_defs[rfunc]
    if spiral3d:
        zf = lambda x: spiral3d * rf(x)
    else:
        zf = lambda x: 0.0

    S = spiral(F.coords, [0, 1, 2], rf, zf)

    PL = curve.PolyLine(S[:, 0, :])

    return PL
Example #5
0

nwires = 6

phi = 30.
alpha2 = 70.
c = 1.
a = c * tand(phi)
b = tand(phi) / tand(alpha2)

zf = lambda x: c * exp(b * x)
rf = lambda x: a * exp(b * x)

S = spiral(F.coords, [0, 1, 2], rf)  #.rosette(nwires,360./nwires)

PL = curve.PolyLine(S[:, 0, :])


def run():
    linewidth(2)
    clear()
    flat()
    draw(origin())
    draw(F, color=blue)
    drawNumbers(F, color=blue)
    draw(PL, color=red)
    draw(PL.coords, color=red)
    drawNumbers(PL.coords, color=red)
    return

    if ack("Spread point evenly?"):