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