Ejemplo n.º 1
0
    # A workspace is defined by a (x, y, z) tuple of available positions
    # in positional grid units.

    ws = (1, 5, 2)

    # For now, we define corresponding Bitblox of interest explicitly, though this
    # could easily be done automatically later. It is simply a list of Bitblox object
    # pairs directly corresponding to the netlist format.

    bb = [
        bat,
        but1,
        led1,
    ]

    cbb = [
        (but1, led1),
        (bat, but1),
    ]

    cn = [
        ('B1', 'LED'),
        ('PWR', 'B2'),
    ]

    # Call the solver, which positions the Bitblox correctly.

    solve(ws, bb, cbb, cn)

    # Draw the assembly resulting from the solution.
    drawBB(assemble(bb), grid = True, gridRadius = 3)
import pdb, traceback

if __name__ == '__main__':

    try:

        # A simple case study for the solver: two buttons sharing a net.
        ws = (2, 2, 2)
        problem = schematic(ws, name="Two Buttons")

        butA = But('Button 1', color=(0, 0, 1))
        butB = But('Button 2', color=(1, 0, 0))

        problem.addConnection(butA, 'B1', butB, 'B1')

        # Fixed Button 1 at the origin with default orientation, as example.
        problem.fix((butA, 0, 0, 0, 0))

        # Call the solver, which positions the Bitblox correctly.

        solve(problem)

        # Draw the assembly resulting from the solution.

        problem.showSolution()

    except Exception, e:

        traceback.print_exc()
        pdb.post_mortem()