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 show_angles(self): angles = self.form.get_edges_attribute('a') amin = min(angles) amax = max(angles) adif = amax - amin text = {} color = {} for u, v, attr in self.form.edges_where({'is_edge': True}, True): a = attr['a'] if a > 5: text[u, v] = "{:.1f}".format(a) color[u, v] = i_to_green((a - amin) / adif) artist = FormArtist(self.form, layer=self.settings['form.layer']) artist.clear_edgelabels() artist.draw_edgelabels(text=text, color=color) 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()
import compas import compas_rhino import compas_tna compas_tna.TEMP = os.path.join(os.path.dirname(__file__), 'tmp') from compas.utilities import i_to_green from compas_tna.diagrams import FormDiagram from compas_tna.diagrams import ForceDiagram from compas_tna.rhino import FormArtist # create diagrams from serialised files form = FormDiagram.from_json('aag_08_final_formdiagram.json') force = ForceDiagram.from_json('aag_08_final_forcediagram.json') # draw the result form.draw(layer='AAG::FormDiagram') force.draw(layer='AAG::ForceDiagram') artist = FormArtist(form, layer='AAG::FormDiagram') artist.clear_reactions() artist.draw_reactions(scale=0.25) artist.draw_forces(scale=0.01) artist.redraw()
def hide_angles(self): artist = FormArtist(self.form, layer=self.settings['form.layer']) artist.clear_edgelabels() artist.redraw()
def hide_reactions(self): artist = FormArtist(self.form, layer=self.settings['form.layer']) artist.clear_reactions() artist.redraw()
def show_forces(self): artist = FormArtist(self.form, layer=self.settings['form.layer']) artist.clear_forces() artist.draw_forces() artist.redraw()