def draw(self, layer=None, clear_layer=True, settings=None): from compas_tna.rhino import FormArtist artist = FormArtist(self, layer=layer) if clear_layer: artist.clear_layer() if not settings: settings = {} if settings.get('show.vertices', True): vertexcolor = {} vertexcolor.update({ key: '#00ff00' for key in self.vertices_where({'is_fixed': True}) }) vertexcolor.update({ key: '#0000ff' for key in self.vertices_where({'is_external': True}) }) vertexcolor.update({ key: '#ff0000' for key in self.vertices_where({'is_anchor': True}) }) artist.draw_vertices(color=vertexcolor) if settings.get('show.edges', True): artist.draw_edges(keys=list(self.edges_where({'is_edge': True}))) if settings.get('show.faces', True): artist.draw_faces(keys=list(self.faces_where({'is_loaded': True}))) if settings.get('show.forces', False): artist.draw_forces(scale=settings.get('scale.forces', 0.1)) if settings.get('show.reactions', False): artist.draw_reactions(scale=settings.get('scale.reactions', 0.01)) artist.redraw()
def draw(self, layer=None, clear_layer=True): from compas_tna.rhino import FormArtist artist = FormArtist(self, layer=layer) if clear_layer: artist.clear_layer() vertexcolor = {} vertexcolor.update({ key: '#00ff00' for key in self.vertices_where({'is_fixed': True}) }) vertexcolor.update({ key: '#0000ff' for key in self.vertices_where({'is_external': True}) }) vertexcolor.update({ key: '#ff0000' for key in self.vertices_where({'is_anchor': True}) }) artist.draw_vertices(color=vertexcolor) artist.draw_edges(keys=list(self.edges_where({'is_edge': True}))) artist.draw_faces(keys=list(self.faces_where({'is_loaded': True}))) artist.redraw()
interior = boundaries[1:] form.set_vertices_attribute('is_anchor', True, keys=exterior) form.update_exterior(exterior, feet=1) form.update_interior(interior) # create the force diagram force = ForceDiagram.from_formdiagram(form) # compute equilibrium horizontal(form, force, kmax=20, display=True) vertical_from_formforce(form, force, density=form.init_scale(), kmax=100) # visualise result artist = FormArtist(form, layer='FormDiagram') artist.clear_layer() artist.draw_vertices(keys=list(form.vertices_where({'is_external': False}))) artist.draw_edges(keys=list(form.edges_where({'is_edge': True, 'is_external': False}))) artist.draw_faces(fkeys=list(form.faces_where({'is_loaded': True})), join_faces=True) artist.draw_reactions(scale=1.0) artist.draw_forces(scale=0.05) artist.redraw()
k, m, ind = identify_dof(form) for u, v in ind: form.set_edge_attributes((u, v), ('is_ind', 'q'), (True, random.choice(range(1, 5)))) vertical_from_qind(form) artist = FormArtist(form, layer='FormDiagram') artist.clear_layer() artist.draw_vertices( color={key: '#ff0000' for key in form.vertices_where({'is_anchor': True})}) artist.draw_edges( keys=list(form.edges_where({'is_edge': True})), color={(u, v): '#00ff00' for u, v in form.edges_where({'is_ind': True})}) artist.draw_edgelabels( text={(u, v): index for index, (u, v, attr) in enumerate(form.edges_where({'is_edge': True}, True)) if attr['is_ind']}) artist.draw_faces() artist.draw_forces(scale=0.01) artist.draw_reactions(scale=0.1) artist.redraw() # ============================================================================== # Main # ==============================================================================