from compas_tna.rhino import FormArtist from compas_tna.rhino import DiagramHelper from compas_tna.equilibrium import vertical_from_zmax_rhino as vertical # create diagrams from serialised files form = FormDiagram.from_json('aag_04_horizontal_formdiagram.json') force = ForceDiagram.from_json('aag_04_horizontal_forcediagram.json') # compute the scale of the force diagram # such that the highest vertex of the form diagram is at a prescribed value zmax = 3 scale = vertical(form, zmax, kmax=100) force.attributes['scale'] = scale print(scale) # draw the result form.draw(layer='AAG::FormDiagram') artist = FormArtist(form, layer='AAG::FormDiagram') artist.clear_reactions() artist.draw_reactions(scale=0.25) artist.draw_forces(scale=0.01)
while True: keys = DiagramHelper.select_continuous_edges(form) if not keys: break DiagramHelper.update_edge_attributes(form, keys) # update the horizontal equilibrium horizontal(form, force, alpha=100, kmax=1000) # compute the scale of the force diagram # such that the highest vertex of the form diagram is at a prescribed value zmax = 3 force.attributes['scale'] = vertical(form, zmax, kmax=100) # 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() # serialise the data