PATH = os.path.join(DATA, 'stack.json')

# load assembly

assembly = Assembly.from_json(PATH)

# compute interface forces

compute_interface_forces_cvx(assembly, solver='CPLEX', verbose=True)

# serialise

assembly.to_json(PATH)

# visualise

R = Rotation.from_axis_and_angle([1.0, 0.0, 0.0], -pi / 2)
assembly_transform(assembly, R)

plotter = AssemblyPlotter(assembly, figsize=(10, 7))

plotter.draw_vertices(text={key: str(key) for key in assembly.vertices()})
plotter.draw_edges()

plotter.draw_blocks(facecolor={
    key: (255, 0, 0)
    for key in assembly.vertices_where({'is_support': True})
})

plotter.show()
from compas_assembly.datastructures import assembly_transform
from compas_assembly.plotter import AssemblyPlotter

HERE = os.path.dirname(__file__)
DATA = os.path.join(HERE, '../data')
PATH = os.path.join(DATA, '08_wall_interfaces.json')

# load an assembly from JSON

assembly = Assembly.from_json(PATH)

# visualise

R = Rotation.from_axis_and_angle([1.0, 0, 0], -pi / 2)
assembly_transform(assembly, R)

plotter = AssemblyPlotter(assembly, figsize=(16, 6))

supports = list(assembly.vertices_where({'is_support': True}))

edgecolor = {key: '#444444' for key in assembly.vertices()}
edgecolor.update({key: '#ff0000' for key in supports})

edgewidth = {key: 0.5 for key in assembly.vertices()}
edgewidth.update({key: 3.0 for key in supports})

plotter.draw_vertices(radius=0.01)
plotter.draw_edges()
plotter.draw_blocks(edgecolor=edgecolor, edgewidth=edgewidth)
plotter.show()
Example #3
0
from compas_assembly.plotter import AssemblyPlotter

# load assembly

assembly = Assembly.from_json(compas_assembly.get('stack.json'))

# compute interface forces

compute_interface_forces_cvx(assembly, solver='CVXOPT', verbose=True)

# serialise

assembly.to_json(compas_assembly.get('stack.json'))

# visualise

R = Rotation.from_axis_and_angle([1.0, 0, 0], -pi / 2)
assembly_transform(assembly, R)

plotter = AssemblyPlotter(assembly, tight=True)

plotter.draw_vertices(
    text={key: str(key)
          for key, attr in assembly.vertices(True)})
plotter.draw_edges()
plotter.draw_blocks(facecolor={
    key: '#ff0000'
    for key in assembly.vertices_where({'is_support': True})
})
plotter.show()
    facecolor.update({
        key: i_to_red((index - i_min) / i_spn)
        for index, key in enumerate(sequence)
    })

    facecolor[key] = '#ff0000'

    plotter.clear_blocks()
    plotter.draw_blocks(facecolor=facecolor)


def on_pick(e):
    index = e.ind[0]
    key = index_key[index]
    if key in top:
        compute_sequence(key)
        plotter.update()


# interactive visualisation

R = Rotation.from_axis_and_angle([1.0, 0, 0], -pi / 2)
assembly_transform(assembly, R)

plotter = AssemblyPlotter(assembly, figsize=(16, 6), tight=True)

plotter.draw_blocks(facecolor={k: '#eeeeee' for k in assembly.vertices()})
plotter.draw_vertices(keys=top, radius=0.01, picker=10)
plotter.register_listener(on_pick)
plotter.show()