HERE = os.path.dirname(__file__) # load an assembly from a JSON file assembly = Assembly.from_json(os.path.join(HERE, '../data/wall_courses.json')) # make a list of the blocks that were already placed placed = list(assembly.vertices_where({'is_placed': True})) # draw the assembly artist = AssemblyArtist(assembly, layer="Assembly") artist.clear_layer() artist.draw_vertices() artist.draw_blocks(show_faces=False, show_edges=True) # draw filled in blocks for the placed ones if placed: artist.draw_blocks(keys=placed, show_faces=True, show_edges=False) # make sure Rhino redraws the view artist.redraw() # select a block key = AssemblyHelper.select_vertex(assembly)
def draw(self, settings=None): """Convenience function for drawing the assembly in Rhino using common visualisation settings. Parameters ---------- settings : dict, optional A dictionary with drawing options. In addition to all configuration options supported by the ``AssemblyArtist``, the following options are supported: * layer: The layer in which the assembly should be drawn. If provided, the layer will be cleared. * show.vertices: ``True``/``False``. * show.edges: ``True``/``False``. * show.faces: ``True``/``False``. * show.forces: ``True``/``False``. * show.forces_as_vectors: ``True``/``False``. * show.interfaces: ``True``/``False``. * show.friction: ``True``/``False``. * show.selfweight: ``True``/``False``. Notes ----- This function is provided for convenience. For more drawing options, see the ``AssemblyArtist``. """ from compas_assembly.rhino import AssemblyArtist settings = settings or {} artist = AssemblyArtist(self, layer=settings.get('layer')) artist.defaults.update(settings) artist.clear_layer() artist.draw_blocks() vertexcolor = { key: artist.defaults['color.vertex:is_support'] for key in self.vertices_where({'is_support': True}) } if settings.get('show.vertices'): artist.draw_vertices(color=vertexcolor) if settings.get('show.edges'): artist.draw_edges() if settings.get('show.interfaces'): artist.draw_interfaces() if settings.get('show.forces'): if settings.get('mode.interface') == 0: artist.color_interfaces(0) else: artist.color_interfaces(1) if settings.get('show.forces_as_vectors'): if settings.get('mode.force') == 0: artist.draw_forces(mode=0) else: artist.draw_forces(mode=1) if settings.get('show.selfweight'): artist.draw_selfweight() if settings.get('show.frictions'): if settings.get('mode.friction') == 0: artist.draw_frictions(mode=0) else: artist.draw_frictions(mode=1) artist.redraw()