def force_update_from_form_xfunc(force, form, *args, **kwargs): from compas_ags.diagrams import FormDiagram from compas_ags.diagrams import ForceDiagram form = FormDiagram.from_data(form) force = ForceDiagram.from_data(force) force_update_from_form(force, form, *args, **kwargs) return force.to_data()
def RunCommand(is_interactive): if 'AGS' not in sc.sticky: compas_rhino.display_message('AGS has not been initialised yet.') return proxy = sc.sticky['AGS']['proxy'] scene = sc.sticky['AGS']['scene'] objects = scene.find_by_name('Form') if not objects: compas_rhino.display_message("There is no FormDiagram in the scene.") return form = objects[0] proxy.package = 'compas_ags.ags.graphstatics' edges = list(form.diagram.edges_where({'is_ind': True})) if not len(edges): compas_rhino.display_message( "You have not yet assigned force values to the form diagram. Please assign forces first." ) return dof = proxy.form_count_dof(form.diagram) if dof[0] != len(edges): compas_rhino.display_message( "You have not assigned the correct number of force values. Please, check the degrees of freedom of the form diagram and update the assigned forces accordingly." ) return # this should become part of the scene for guid in list(scene.objects.keys()): obj = scene.objects[guid] if obj.name == 'Force': compas_rhino.rs.EnableRedraw(False) try: obj.clear() del scene.objects[guid] except Exception: pass compas_rhino.rs.EnableRedraw(True) compas_rhino.rs.Redraw() forcediagram = ForceDiagram.from_formdiagram(form.diagram) force_id = scene.add(forcediagram, name="Force", layer="AGS::ForceDiagram") force = scene.find(force_id) form.diagram.data = proxy.form_update_q_from_qind_proxy(form.diagram.data) force.diagram.data = proxy.force_update_from_form_proxy( force.diagram.data, form.diagram.data) force.scale = compute_force_drawingscale(form, force) force.location = compute_force_drawinglocation(form, force) form.settings['scale.forces'] = compute_form_forcescale(form) scene.update() scene.save()
(6, 13), (0, 14), (14, 15), (15, 16), (16, 17), (17, 18), (18, 6), (1, 14), (2, 15), (3, 16), (4, 17), (5, 18), ] form = FormDiagram.from_vertices_and_edges(vertices, edges) force = ForceDiagram.from_formdiagram(form) index_uv = form.index_uv() ind = [3, 6, 10, 13, 16] for index in ind: u, v = index_uv[index] form.edge[u][v]['is_ind'] = True form.edge[u][v]['q'] = 1. graphstatics.form_update_q_from_qind(form) graphstatics.force_update_from_form(force, form) force.vertex[7]['x'] = 0 force.vertex[7]['y'] = 0
def force_update_from_form_proxy(forcedata, formdata, *args, **kwargs): form = FormDiagram.from_data(formdata) force = ForceDiagram.from_data(forcedata) force_update_from_form(force, form, *args, **kwargs) return force.to_data()
def form_update_from_force_newton_proxy(forcedata, formdata, *args, **kwargs): form = FormDiagram.from_data(formdata) force = ForceDiagram.from_data(forcedata) form_update_from_force_newton(force, form, *args, **kwargs) # Still need dealing with constraints return force.to_data()
import os import json from compas_ags.diagrams import FormDiagram from compas_ags.diagrams import ForceDiagram from compas_ags.ags import graphstatics from compas_ags.viewers import Viewer HERE = os.path.dirname(__file__) FILE = os.path.join(HERE, '../data/forms/howe_modified.ags') with open(FILE, 'r') as f: data = json.load(f) form = FormDiagram.from_data(data['data']['form']) force = ForceDiagram.from_data(data['data']['force']) form.dual = force force.dual = form graphstatics.form_update_from_force(form, force, kmax=100) # ============================================================================== # Visualize # ============================================================================== viewer = Viewer(form, force, delay_setup=False, figsize=(12, 7.5)) viewer.draw_form(vertexsize=0.15, vertexcolor={ key: '#000000' for key in form.vertices_where({'is_fixed': True})
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.select_file(folder=system['session.dirname'], filter=system['session.extension']) if not filepath: return if not os.path.exists(filepath): return if not os.path.isfile(filepath): return if not filepath.endswith(".{}".format(system['session.extension'])): return dirname, basename = os.path.split(filepath) filename, extension = os.path.splitext(basename) system['session.dirname'] = dirname system['session.filename'] = filename with open(filepath, "r") as f: session = json.load(f, cls=DataDecoder) if not session['data']['form']: compas_rhino.display_message('The session file has no form diagram.') scene.clear() formdiagram = FormDiagram.from_data(session['data']['form']) form_id = scene.add(formdiagram, name='Form', layer='AGS::FormDiagram') form = scene.find(form_id) if 'settings' in session['scene']['form']: form.settings.update(session['scene']['form']['settings']) if 'anchor' in session['scene']['form']: form.anchor = session['scene']['form']['anchor'] if 'location' in session['scene']['form']: form.location = session['scene']['form']['location'] if 'scale' in session['scene']['form']: form.scale = session['scene']['form']['scale'] if session['data']['force']: forcediagram = ForceDiagram.from_data(session['data']['force']) forcediagram.dual = formdiagram formdiagram.dual = forcediagram force_id = scene.add(forcediagram, name='Force', layer='AGS::ForceDiagram') force = scene.find(force_id) if 'settings' in session['scene']['force']: force.settings.update(session['scene']['force']['settings']) if 'anchor' in session['scene']['force']: force.anchor = session['scene']['force']['anchor'] if 'location' in session['scene']['force']: force.location = session['scene']['force']['location'] if 'scale' in session['scene']['form']: force.scale = session['scene']['force']['scale'] scene.update() scene.save()
def compute_loadpath_compression_proxy(formdata, forcedata, *args, **kwargs): form = FormDiagram.from_data(formdata) force = ForceDiagram.from_data(forcedata) lp = compute_internal_work_compression(form, force, *args, **kwargs) return lp
def compute_loadpath_proxy(formdata, forcedata, *args, **kwargs): form = FormDiagram.from_data(formdata) force = ForceDiagram.from_data(forcedata) lp = compute_loadpath(form, force, *args, **kwargs) return lp