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 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