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.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), ] for index in edges_ind: u, v = index form.edge_attribute((u, v), 'is_ind', True) form.edge_attribute((u, v), 'q', +1.)