import compas_rhino import compas_tna from compas_tna.diagrams import FormDiagram from compas_tna.rhino import DiagramHelper # create a form diagram from a set of lines guid = compas_rhino.select_mesh() form = FormDiagram.from_rhinomesh(guid) # identify the supports # as the vertices that lie on the support curves guids = compas_rhino.select_curves() keys = DiagramHelper.identify_vertices_on_curves(form, guids) form.set_vertices_attribute('is_anchor', True, keys) # update the boundaries to include the horizontal reaction forces form.update_boundaries() # serialise the result form.to_json('aag_01_formdiagram_from_mesh.json') # draw the result in the layer AAG > FormDiagram form.draw(layer='AAG::FormDiagram')
formdata, scale = tna.vertical_from_zmax_proxy(form.to_data(), zmax) form.data = formdata return scale # 1. make the form diagram from selected line elements guids = compas_rhino.select_lines() rs.HideObjects(guids) form = FormDiagram.from_rhinolines(guids) form.draw(layer='TNA::FormDiagram', clear_layer=True) # 2. identify the supports keys = DiagramHelper.select_vertices(form) if keys: form.set_vertices_attributes(['is_anchor', 'is_fixed'], [True, True], keys=keys) form.draw(layer='TNA::FormDiagram', clear_layer=True) # 3. update the boundaries # Note: add only one foot per support to control the direction of the horizontal component # of the reaction force form.update_boundaries(feet=1) form.draw(layer='TNA::FormDiagram', clear_layer=True) # move the "feet" such that the horizontal reaction forces are constrained in the correct direction
from compas_tna.equilibrium import vertical_from_zmax_rhino as vertical # create diagrams from serialised files form = FormDiagram.from_json('aag_06_distribution_formdiagram.json') force = ForceDiagram.from_json('aag_06_distribution_forcediagram.json') # visualise the diagrams form.draw(layer='AAG::FormDiagram') force.draw(layer='AAG::ForceDiagram') # update the force bounds on the edges of the form diagram 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 = FormDiagram.from_json('aag_02_formdiagram.json') # create a force diagram from the form diagram force = ForceDiagram.from_formdiagram(form) # visualise the result force.draw(layer='AAG::ForceDiagram') # move the force diagram to a different location DiagramHelper.move(force) force.draw(layer='AAG::ForceDiagram') # fix one of the force diagram vertices to keep it there in the future key = DiagramHelper.select_vertex(force) if key is not None: DiagramHelper.update_vertex_attributes(force, [key]) # redraw the force diagram force.draw(layer='AAG::ForceDiagram')
formdata, scale = tna.vertical_from_zmax_proxy(form.to_data(), zmax) form.data = formdata return scale # make the form diagram from selected line elements guids = compas_rhino.select_lines() form = FormDiagram.from_rhinolines(guids) form.draw(layer='TNA::FormDiagram', clear_layer=True) # identify the supports guids = compas_rhino.select_curves() keys = DiagramHelper.identify_vertices_on_curves(form, guids) if keys: form.set_vertices_attributes(['is_anchor', 'is_fixed'], [True, True], keys=keys) form.draw(layer='TNA::FormDiagram', clear_layer=True) # update the boundaries # Note: add only one foot per support to control the direction of the horizontal component # of the reaction force form.update_boundaries(feet=1) form.draw(layer='TNA::FormDiagram', clear_layer=True) # move the "feet" such that the horizontal reaction forces are constrained in the correct direction while True:
# except BrokenPipeError: # return None form.data = formdata return scale # make the form diagram from selected line elements guids = compas_rhino.select_lines() form = FormDiagram.from_rhinolines(guids) form.draw(layer='TNA::FormDiagram', clear_layer=True) # identify the supports keys = DiagramHelper.select_vertices(form) if keys: form.vertices_attributes(['is_anchor', 'is_fixed'], [True, True], keys=keys) form.draw(layer='TNA::FormDiagram', clear_layer=True) # update the boundaries # Note: two feet per support to allow for non-symmetrical force distributions # in the different webs of the cross-vault form.update_boundaries(feet=2) form.draw(layer='TNA::FormDiagram', clear_layer=True) # make the force diagram
def RunCommand(is_interactive): if 'TNA' not in sc.sticky: raise Exception("Initialise the plugin first!") TNA = sc.sticky['TNA'] form = TNA['form'] force = TNA['force'] settings = TNA['settings'] options = ['form', 'force'] option = rs.GetString("Select a Diagram", options[0], options) if not option: return if option == 'form': if not form: return options = ['vertices', 'edges', 'faces'] option = rs.GetString("Select a component", options[0], options) if not option: return if option == 'vertices': options = ['selection', 'boundary', 'anchors', 'external', 'all'] option = rs.GetString("Selection mode", options[0], options) if not option: return if option == 'selection': keys = DiagramHelper.select_vertices(form) elif option == 'boundary': keys = list(form.vertices_on_boundary()) elif option == 'anchors': keys = list(form.vertices_where({'is_anchor': True})) elif option == 'external': keys = list(form.vertices_where({'is_external': True})) elif option == 'all': keys = list(form.vertices()) else: raise NotImplementedError if not keys: return if DiagramHelper.update_vertex_attributes(form, keys): form.draw(layer=settings['layer.form'], clear_layer=True, settings=settings) elif option == 'edges': options = [ 'selection', 'parallel', 'continuous', 'boundary', 'external', 'all' ] option = rs.GetString("Selection mode", options[0], options) if option == 'selection': keys = DiagramHelper.select_edges(form) elif option == 'parallel': keys = DiagramHelper.select_parallel_edges(form) elif option == 'continuous': keys = DiagramHelper.select_continuous_edges(form) elif option == 'boundary': keys = list(form.edges_on_boundary()) elif option == 'external': keys = list(form.edges_where({'is_external': True})) elif option == 'all': keys = list(form.edges()) else: raise NotImplementedError if not keys: return if DiagramHelper.update_edge_attributes(form, keys): form.draw(layer=settings['layer.form'], clear_layer=True, settings=settings) elif option == 'faces': pass else: raise NotImplementedError
# # 3. update the boundaries # Note: add only one foot per support to control the direction of the horizontal component # of the reaction force form.update_boundaries(feet=1) form.draw(layer='TNA::FormDiagram', clear_layer=True) # # 4. make the force diagram force = ForceDiagram.from_formdiagram(form) force.draw(layer='TNA::ForceDiagram', clear_layer=True) DiagramHelper.move(force) force.draw(layer='TNA::ForceDiagram', clear_layer=True) # # 5. compute horizontal equilibrium horizontal(form, force, alpha=100, kmax=500) force.draw(layer='TNA::ForceDiagram', clear_layer=True) # # 6. compute vertical equilibrium based on a chosen height of the highest point of the equilibrium network while True: zmax = rs.GetReal('Z Max') if not zmax:
def RunCommand(is_interactive): if 'TNA' not in sc.sticky: raise Exception("Initialise the plugin first!") TNA = sc.sticky['TNA'] options = ['form', 'force'] option = rs.GetString("Select a Diagram", options[0], options) if not option: return if option == 'form': form = TNA['form'] if not form: return options = ['vertices', 'edges', 'faces'] option = rs.GetString("Select a component type", options[0], options) if not option: return if option == 'vertices': keys = DiagramHelper.select_vertices(form) if not keys: return if DiagramHelper.update_vertex_attributes(form, keys): form.draw(layer=TNA['settings']['layer.form'], clear_layer=True, settings=TNA['settings']) elif option == 'edges': keys = DiagramHelper.select_edges(form) if not keys: return if DiagramHelper.update_edge_attributes(form, keys): form.draw(layer=TNA['settings']['layer.form'], clear_layer=True, settings=TNA['settings']) elif option == 'faces': keys = DiagramHelper.select_faces(form) if not keys: return if DiagramHelper.update_face_attributes(form, keys): form.draw(layer=TNA['settings']['layer.form'], clear_layer=True, settings=TNA['settings']) if option == 'force': force = TNA['force'] if not force: return options = ['vertices', 'edges'] option = rs.GetString("Select a component type", options[0], options) if not option: return if option == 'vertices': keys = DiagramHelper.select_vertices(force) if not keys: return if DiagramHelper.update_vertex_attributes(force, keys): force.draw(layer=TNA['settings']['layer.force'], clear_layer=True, settings=TNA['settings']) elif option == 'edges': keys = DiagramHelper.select_edges(force) if not keys: return if DiagramHelper.update_edge_attributes(force, keys): force.draw(layer=TNA['settings']['layer.force'], clear_layer=True, settings=TNA['settings'])