def RunCommand(is_interactive): if 'AGS' not in sc.sticky: compas_rhino.display_message('AGS has not been initialised yet.') return system = sc.sticky['AGS']['system'] scene = sc.sticky['AGS']['scene'] filepath = compas_rhino.browse_for_file('Select an input file.', folder=system['session.dirname'], filter='obj') if not filepath: return dirname, _ = os.path.split(filepath) system['session.dirname'] = dirname graph = FormGraph.from_obj(filepath) if not graph.is_planar_embedding(): compas_rhino.display_message( 'The graph is not planar. Therefore, a form diagram cannot be created.' ) return form = FormDiagram.from_graph(graph) scene.purge() scene.add(form, name='Form', layer='AGS::FormDiagram') scene.update() scene.save()
def RunCommand(is_interactive): if 'AGS' not in sc.sticky: compas_rhino.display_message('AGS has not been initialised yet.') return scene = sc.sticky['AGS']['scene'] layer = compas_rhino.rs.CurrentLayer() layer_name = compas_rhino.rs.GetString("Layer to construct FormDiagram", layer) guids = compas_rhino.get_lines(layer=layer_name) if not guids: return compas_rhino.rs.HideObjects(guids) lines = compas_rhino.get_line_coordinates(guids) graph = FormGraph.from_lines(lines) if not graph.is_planar_embedding(): compas_rhino.display_message( 'The graph is not planar. Therefore, a form diagram cannot be created.' ) return form = FormDiagram.from_graph(graph) scene.purge() scene.add(form, name='Form', layer='AGS::FormDiagram') scene.update() scene.save()
from compas_ags.ags import graphstatics from compas_ags.ags import loadpath nodes = [[0.0, 0.0, 0], [1.0, 0.0, 0], [2.0, 0.0, 0], [3.0, 0.0, 0], [4.0, 0.0, 0], [5.0, 0.0, 0], [6.0, 0.0, 0], [0.0, -1.0, 0], [1.0, -1.0, 0], [2.0, -1.0, 0], [3.0, -1.0, 0], [4.0, -1.0, 0], [5.0, -1.0, 0], [6.0, -1.0, 0], [1.0, +1.0, 0], [2.0, +1.0, 0], [3.0, +1.0, 0], [4.0, +1.0, 0], [5.0, +1.0, 0]] edges = [(0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (0, 7), (1, 8), (2, 9), (3, 10), (4, 11), (5, 12), (6, 13), (0, 14), (14, 15), (15, 16), (16, 17), (17, 18), (18, 6), (1, 14), (2, 15), (3, 16), (4, 17), (5, 18)] graph = FormGraph.from_nodes_and_edges(nodes, edges) form = FormDiagram.from_graph(graph) force = ForceDiagram.from_formdiagram(form) index_uv = form.index_uv() ind = [4, 7, 10, 13, 16] for index in ind: u, v = index_uv[index] form.edge_attribute((u, v), 'is_ind', True) form.edge_attribute((u, v), 'q', 1.0) graphstatics.form_update_q_from_qind(form) graphstatics.force_update_from_form(force, form)
from compas_ags.diagrams import FormDiagram from compas_ags.diagrams import ForceDiagram from compas_ags.rhino import Scene graphstatics = Proxy('compas_ags.ags.graphstatics') HERE = os.path.dirname(__file__) DATA = os.path.join(HERE, '../data') FILE = os.path.join(DATA, 'debugging', 'truss.obj') # ============================================================================== # Init # ============================================================================== graph = FormGraph.from_obj(FILE) form = FormDiagram.from_graph(graph) force = ForceDiagram.from_formdiagram(form) # ============================================================================== # Boundary conditions # ============================================================================== form.edge_force((0, 1), -1.0) form.edge_force((2, 3), -1.0) form.edge_force((4, 5), -1.0) # ============================================================================== # Equilibrium # ==============================================================================
import compas_ags from compas_ags.diagrams import FormGraph from compas_ags.diagrams import FormDiagram from compas_ags.diagrams import ForceDiagram from compas_ags.viewers import Viewer from compas_ags.ags import form_update_from_force from compas_ags.ags import form_update_q_from_qind from compas_ags.ags import force_update_from_form from compas_ags.ags import ConstraintsCollection from compas_ags.ags import form_update_from_force_newton # ------------------------------------------------------------------------------ # 1. create a simple arch from nodes and edges, make form and force diagrams # ------------------------------------------------------------------------------ graph = FormGraph.from_json(compas_ags.get('paper/gs_arch.json')) form = FormDiagram.from_graph(graph) force = ForceDiagram.from_formdiagram(form) # ------------------------------------------------------------------------------ # 2. prescribe edge force density and set fixed vertices # ------------------------------------------------------------------------------ # prescribe force density to edge edges_ind = [ (2, 11), ] for index in edges_ind: u, v = index form.edge_attribute((u, v), 'is_ind', True) form.edge_attribute((u, v), 'q', -1.)
import compas_ags from compas_ags.diagrams import FormGraph from compas_ags.diagrams import FormDiagram from compas_ags.diagrams import ForceDiagram from compas_ags.viewers import Viewer from compas_ags.ags import form_update_q_from_qind from compas_ags.ags import force_update_from_form from compas_ags.ags import form_update_from_force from compas_ags.ags import force_update_from_constraints # ------------------------------------------------------------------------------ # 1. Get OBJ file for the geometry # ------------------------------------------------------------------------------ graph = FormGraph.from_obj(compas_ags.get('paper/gs_truss.obj')) # Add horizontal line to graph to make Structure isostatic. lines = graph.to_lines() lines.append(([-2.0, 0.0, 0.0], [0.0, 0.0, 0.0])) graph = FormGraph.from_lines(lines) form = FormDiagram.from_graph(graph) force = ForceDiagram.from_formdiagram(form) # ------------------------------------------------------------------------------ # 2. prescribe edge force density and set fixed vertices # ------------------------------------------------------------------------------ # prescribe force density to edge edges_ind = [ (8, 9), ]
import compas_ags from compas_ags.diagrams import FormGraph from compas_ags.diagrams import FormDiagram from compas_ags.diagrams import ForceDiagram from compas_ags.ags import graphstatics from compas_ags.viewers import Viewer # ------------------------------------------------------------------------------ # 1. get lines of a plane triangle frame in equilibrium, its applied loads and reaction forces # make form and force diagrams # ------------------------------------------------------------------------------ graph = FormGraph.from_obj(compas_ags.get('paper/gs_form_force.obj')) form = FormDiagram.from_graph(graph) force = ForceDiagram.from_formdiagram(form) # ------------------------------------------------------------------------------ # 2. set applied load # ------------------------------------------------------------------------------ # choose an independent edge and set the magnitude of the applied load # the system is statically determinate, thus choosing one edge is enough form.edge_force(0, -30.0) # update force densities of form and force diagrams graphstatics.form_update_q_from_qind(form) graphstatics.force_update_from_form(force, form)
'width': 1.0, 'color': '#cccccc', 'style': '--' }) return form_lines, force_lines # ------------------------------------------------------------------------------ # 1. Problem of getting to a funicular shape # - Input a circular arch # - Input "target forces" for the loads applied # - Update form and force diagram # ------------------------------------------------------------------------------ graph = FormGraph.from_obj(compas_ags.get('paper/exA_arch-circular.obj')) form = FormDiagram.from_graph(graph) edge_index = form.edge_index() index_edge = form.index_edge() # create a dual force diagram force = ForceDiagram.from_formdiagram(form) # create label for plots force_edges = force.ordered_edges(form) force_edge_labels = {(u, v): index for index, (u, v) in enumerate(force_edges)} force_edge_labels.update({(v, u): index for index, (u, v) in enumerate(force_edges)}) # set supports supports = [1, 7] for key in supports:
import random import compas import compas_ags from compas_ags.diagrams import FormGraph from compas_ags.diagrams import FormDiagram from compas_ags.diagrams import ForceDiagram from compas_ags.ags import graphstatics from compas_ags.viewers import Viewer graph = FormGraph.from_obj(compas.get('lines.obj')) form = FormDiagram.from_graph(graph) force = ForceDiagram.from_formdiagram(form) form.vertices_attribute('is_fixed', True, keys=form.leaves()) k, m, ind = graphstatics.form_identify_dof(form) for u, v in ind: form.edge_attributes((u, v), ('is_ind', 'q'), (True, random.choice(range(2, 20)))) graphstatics.form_update_q_from_qind(form) graphstatics.force_update_from_form(force, form) viewer = Viewer(form, force, delay_setup=False) viewer.draw_form(vertexsize=0.15, external_on=False)
from compas.geometry import subtract_vectors from compas.geometry import sum_vectors from compas.geometry import normalize_vector from compas.geometry import scale_vector from compas_ags.diagrams import FormGraph from compas_ags.diagrams import FormDiagram from compas_plotters import MeshPlotter # ============================================================================== # Construct the graph of a Fink truss. # ============================================================================== graph = FormGraph.from_obj(compas_ags.get('paper/fink.obj')) # ============================================================================== # Identify the fixed points of the graph. # ============================================================================== fixed = [6, 9] # ============================================================================== # Assert that the graph is 2D and that it is planar. # ============================================================================== assert graph.is_2d(), "The graph is not 2D." assert graph.is_planar(), "The graph is not planar." # ==============================================================================
from compas.rpc import Proxy graphstatics = Proxy('compas_ags.ags.graphstatics') graphstatics.restart_server() # this file has unloaded, 2-valent nodes # they will be removed automatically # and the result renumbered # HERE = os.path.dirname(__file__) # FILE = os.path.join(HERE, '../data/debugging/zero.obj') # graph = FormGraph.from_obj(FILE) guids = compas_rhino.select_lines() lines = compas_rhino.get_line_coordinates(guids) graph = FormGraph.from_lines(lines) form = FormDiagram.from_graph(graph) force = ForceDiagram.from_formdiagram(form) scene = Scene() # fix the supports form.vertices_attribute('is_fixed', True, [1, 12]) # set the loads form.edge_force((8, 19), +10.0) form.edge_force((14, 3), +10.0) form.edge_force((17, 7), +10.0) form.edge_force((11, 9), +10.0) form.edge_force((13, 16), +10.0) # compute initial form and force diagrams
edgelabel={uv: str(force.dual_edgelength(uv)) for uv in force.edges()}) viewer.show() # ------------------------------------------------------------------------------ # 5. Dense Constant force truss # - Input a non-triangulated dense truss, compute initial equilibrium # - Constraint top chord to constant force and move bottom chord to a sinusoidal shape # - Constraint the applied loads magnitude # ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------ # 1. Get geometry, apply loads and and compute equilibrium # ------------------------------------------------------------------------------ graph = FormGraph.from_obj(compas_ags.get('paper/exE_truss_dense.obj')) form = FormDiagram.from_graph(graph) force = ForceDiagram.from_formdiagram(form) force_edges = force.ordered_edges(form) force_edge_labels1 = {(u, v): index for index, (u, v) in enumerate(force_edges)} force_edge_labels2 = {(v, u): index for index, (u, v) in enumerate(force_edges)} force_edge_labels = {**force_edge_labels1, **force_edge_labels2} # prescribe force density to edge edges_ind = [ (17, 22), ] load = 1.0 for index in edges_ind:
# ------------------------------------------------------------------------------ # 4. Constant force truss # - Input a non-triangulated truss, compute initial equilibrium # - Move the form diagram support # - Move one of the internal nodes to a specific position # ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------ # 1. Get geometry, apply loads and and compute equilibrium # ------------------------------------------------------------------------------ input_file = compas_ags.get('paper/exD_truss.obj') graph = FormGraph.from_obj(input_file) form = FormDiagram.from_graph(graph) force = ForceDiagram.from_formdiagram(form) force_edges = force.ordered_edges(form) force_edge_labels1 = {(u, v): index for index, (u, v) in enumerate(force_edges)} force_edge_labels2 = {(v, u): index for index, (u, v) in enumerate(force_edges)} force_edge_labels = {**force_edge_labels1, **force_edge_labels2} # prescribe force density to edge edges_ind = [ (13, 14), ] for index in edges_ind: u, v = index form.edge_attribute((u, v), 'is_ind', True)