def RunCommand(is_interactive):

    if '3GS' not in sc.sticky:
        compas_rhino.display_message('3GS has not been initialised yet.')
        return

    scene = sc.sticky['3GS']['scene']

    # get ForceVolMeshObject from scene
    objects = scene.find_by_name('force')
    if objects:
        compas_rhino.display_message("Force diagram already exists in the scene!")
        return

    guids = rs.GetObjects("select polysurfaces", filter=rs.filter.polysurface)
    if not guids:
        return

    compas_rhino.rs.HideObjects(guids)

    force = volmesh_from_polysurfaces(ForceVolMesh, guids)

    scene.purge()
    scene.add_forcevolmesh(force, name='force', layer='3GS::ForceDiagram')

    objects = scene.find_by_name('force')
    force = objects[0]

    force.check_eq()

    scene.update()
    scene.save()

    print('Polyhedral force diagram successfully created.')
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'

    dof = proxy.form_count_dof(form.diagram)
    k = dof[0]
    inds = len(list(form.diagram.edges_where({'is_ind': True})))

    if k == inds:
        compas_rhino.display_message(
            'Success: You have identified the correct number of externally applied loads.'
        )
    elif k > inds:
        compas_rhino.display_message(
            'Warning: You have not yet identified all external loads. (%s required and %s selected)'
            % (k, inds))
    else:
        compas_rhino.display_message(
            'Warning: You have identified too many external forces as loads. (%s required and %s selected)'
            % (k, inds))
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']

    objects = scene.find_by_name('Form')
    if not objects:
        compas_rhino.display_message("There is no FormDiagram in the scene.")
        return
    form = objects[0]

    while True:
        edges = form.select_edges(
            "Mark selected edges as independent (all others as dependent).")
        if not edges:
            break

        form.diagram.edges_attribute('is_ind', False)
        form.diagram.edges_attribute('is_ind', True, keys=edges)
        scene.update()

    scene.save()
def RunCommand(is_interactive):

    if '3GS' not in sc.sticky:
        compas_rhino.display_message('3GS has not been initialised yet.')
        return

    scene = sc.sticky['3GS']['scene']

    # get ForceVolMeshObject from scene
    objects = scene.find_by_name('force')
    if not objects:
        compas_rhino.display_message("There is no force diagram in the scene.")
        return
    force = objects[0]

    # --------------------------------------------------------------------------

    vertices = force.select_vertices()

    rhino_vertex_move(force.diagram, vertices)

    objects = scene.find_by_name('form')
    if not objects:
        force.check_eq()
        scene.update()
        return
    form = objects[0]

    form.diagram.update_angle_deviations()

    force.check_eq()
    form.check_eq()

    scene.update()
    scene.save()
Beispiel #5
0
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()
Beispiel #6
0
def RunCommand(is_interactive):

    if 'AGS' not in sc.sticky:
        compas_rhino.display_message('AGS has not been initialised yet.')
        return

    webbrowser.open('https://blockresearchgroup.github.io/compas_ags/')
Beispiel #7
0
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()
Beispiel #8
0
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']

    objects = scene.find_by_name('Form')
    if not objects:
        compas_rhino.display_message("There is no FormDiagram in the scene.")
        return
    form = objects[0]

    form.diagram.vertices_attribute('is_fixed', False)
    scene.update()

    vertices = form.select_vertices("Fix selected vertices (unfix all others)")
    if not vertices:
        return

    form.diagram.vertices_attribute('is_fixed', True, keys=vertices)
    scene.update()

    scene.save()
def RunCommand(is_interactive):

    if 'EG' not in sc.sticky:
        compas_rhino.display_message("EscobedoGroup UI no available.")
        return

    mesh = sc.sticky["EG"].get('mesh')
    if not mesh:
        compas_rhino.display_message("No mesh is loaded.")
        return

    obj = MeshObject(mesh, layer="HiLo::Mesh")
    obj.clear_layer()
    obj.draw()

    compas_rhino.rs.EnableRedraw(True)
    compas_rhino.rs.Redraw()

    vertices = obj.select_vertices()
    if not vertices:
        return

    if mesh_update_vertex_attributes(obj.mesh, vertices):
        obj.clear()
        obj.draw()

        compas_rhino.rs.EnableRedraw(True)
        compas_rhino.rs.Redraw()
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']

    objects = scene.find_by_name('Force')
    if not objects:
        compas_rhino.display_message("There is no ForceDiagram in the scene.")
        return
    force = objects[0]

    options = ["Factor", "3Points"]
    option = compas_rhino.rs.GetString("Scale ForceDiagram:", strings=options)

    if not option:
        return

    if option == "Factor":
        scale_factor = compas_rhino.rs.GetReal("Scale factor", force.scale)
        force.scale = scale_factor

    elif option == "3Points":
        force.scale_from_3_points(message="Select the base node of the Force Diagram for the scaling opetation.")

    scene.update()
    scene.save()
Beispiel #11
0
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']

    objects = scene.find_by_name('Form')
    if not objects:
        compas_rhino.display_message("There is no FormDiagram in the scene.")
        return
    form = objects[0]

    objects = scene.find_by_name('Force')
    if not objects:
        compas_rhino.display_message("There is no ForceDiagram in the scene.")
        return
    force = objects[0]

    threshold = scene.settings['AGS']['max_deviation']
    check = check_deviations(form.diagram, force.diagram, tol=threshold)
    max_dev = max(form.diagram.edges_attribute('a'))

    if check:
        compas_rhino.display_message('Diagrams are parallel!\nMax. angle deviation: {0:.2g} deg\nThreshold assumed: {1:.2g} deg.'.format(max_dev, threshold))
    else:
        compas_rhino.display_message('Diagrams are not parallel!\nMax. angle deviation: {0:.2g} deg\nThreshold assumed: {1:.2g} deg.'.format(max_dev, threshold))
Beispiel #12
0
def RunCommand(is_interactive):

    shelvepath = os.path.join(compas.APPTEMP, 'AGS', '.history')
    if not os.path.exists(os.path.dirname(shelvepath)):
        try:
            os.makedirs(os.path.dirname(shelvepath))
        except OSError as error:
            if error.errno != errno.EEXIST:
                raise

    db = shelve.open(shelvepath, 'n')
    db['states'] = []

    scene = Scene(db, 20, SETTINGS)
    scene.purge()

    sc.sticky["AGS"] = {
        'proxy': Proxy(),
        'system': {
            "session.dirname": CWD,
            "session.filename": None,
            "session.extension": 'ags'
        },
        'scene': scene,
    }

    scene.update()

    # would be useful to add a notification about the cloud: new / reconnect
    compas_rhino.display_message("AGS has started.")
Beispiel #13
0
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']

    form = scene.find_by_name("Form")[0]

    objects = scene.find_by_name("Force")
    if objects:
        force = objects[0]
    else:
        force = None

    # Turn on edge labels
    original_setting = form.settings["show.edgelabels"]
    form.settings["show.edgelabels"] = True
    scene.update()

    AttributesForm.from_sceneNode(form, dual=force)

    # Revert to original setting
    form.settings["show.edgelabels"] = original_setting
    scene.update()
Beispiel #14
0
def RunCommand(is_interactive):

    if 'AGS' not in sc.sticky:
        compas_rhino.display_message('AGS has not been initialised yet.')
        return

    AGS_form_select_ind_cmd.RunCommand(True)
    AGS_form_assign_forces_cmd.RunCommand(True)
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']

    form = scene.find_by_name("Form")[0]
    AttributesForm.from_sceneNode(form)
Beispiel #16
0
def RunCommand(is_interactive):

    if '3GS' not in sc.sticky:
        compas_rhino.display_message('3GS has not been initialised yet.')
        return

    scene = sc.sticky['3GS']['scene']

    SettingsForm.from_scene(scene, object_types=[ForceVolMeshObject, FormNetworkObject], global_settings=['3GS', 'Solvers'])

    scene.update()
    scene.save()
Beispiel #17
0
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']
    if not scene:
        return

    # TODO: deal with undo redo
    SettingsForm.from_scene(scene, object_types=[FormObject, ForceObject])
Beispiel #18
0
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']
    if not scene:
        return

    if not scene.redo():
        compas_rhino.display_message("Nothing left to redo.")
Beispiel #19
0
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']

    max_dev = compas_rhino.rs.GetReal(message="Assign threshold for maximum angle deviation", number=scene.settings['AGS']['max_deviation'])
    if not max_dev:
        return

    scene.settings['AGS']['max_deviation'] = max_dev
def RunCommand(is_interactive):

    sc.doc.EndUndoRecord(sc.doc.CurrentUndoRecordSerialNumber)

    if 'AGS' not in sc.sticky:
        compas_rhino.display_message('AGS has not been initialised yet.')
        return

    scene = sc.sticky['AGS']['scene']
    if not scene:
        return

    scene.update()
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']

    objects = scene.find_by_name('Force')
    if not objects:
        compas_rhino.display_message("There is no ForceDiagram in the scene.")
        return
    force = objects[0]

    force.inspector_off()
Beispiel #22
0
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()
Beispiel #23
0
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']
    if not proxy:
        return

    proxy.stop_server()
    proxy.start_server()

    compas_rhino.display_message('AGS server restarted.')
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']

    objects = scene.find_by_name('Force')
    if not objects:
        compas_rhino.display_message("There is no ForceDiagram in the scene.")
        return
    force = objects[0]

    options = ["VertexLabels", "EdgeLabels", "ForceLabels", "CompressionTension"]

    while True:
        option = compas_rhino.rs.GetString("FormDiagram Display", strings=options)
        if not option:
            return

        if option == "VertexLabels":
            if force.settings['show.vertexlabels'] is True:
                force.settings['show.vertexlabels'] = False
            else:
                force.settings['show.vertexlabels'] = True

        elif option == "EdgeLabels":
            if force.settings['show.edgelabels'] is True:
                force.settings['show.edgelabels'] = False
            else:
                force.settings['show.edgelabels'] = True
                force.settings['show.forcelabels'] = False

        elif option == "ForceLabels":
            if force.settings['show.forcelabels'] is True:
                force.settings['show.forcelabels'] = False
            else:
                force.settings['show.forcelabels'] = True
                force.settings['show.edgelabels'] = False

        elif option == "CompressionTension":
            if force.settings['show.forcecolors'] is True:
                force.settings['show.forcecolors'] = False
            else:
                force.settings['show.forcecolors'] = True

        scene.update()

    scene.save()
Beispiel #25
0
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]

    objects = scene.find_by_name('Force')
    if not objects:
        compas_rhino.display_message("There is no ForceDiagram in the scene.")
        return
    force = objects[0]

    proxy.package = 'compas_ags.ags.loadpath'

    lp = proxy.compute_loadpath(form.diagram, force.diagram)
    compas_rhino.display_message(
        'The total load-path of the structure is {} kNm.'.format(round(lp, 2)))
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']

    objects = scene.find_by_name('Form')
    if not objects:
        compas_rhino.display_message("There is no FormDiagram in the scene.")
        return
    form = objects[0]

    if form.move():
        scene.update()
        scene.save()
def RunCommand(is_interactive):

    if '3GS' not in sc.sticky:
        compas_rhino.display_message('3GS has not been initialised yet.')
        return

    scene = sc.sticky['3GS']['scene']

    # get ForceVolMeshObject from scene
    objects = scene.find_by_name('force')
    if not objects:
        compas_rhino.display_message("There is no force diagram in the scene.")
        return
    force = objects[0]

    # select halfface ----------------------------------------------------------
    boundary_halffaces = force.diagram.halffaces_on_boundaries()

    hf_inspector = VolmeshHalffaceInspector(force.diagram,
                                            hfkeys=boundary_halffaces,
                                            dependents=True)
    hf_inspector.enable()
    halfface = mesh_select_face(force.diagram)
    hf_inspector.disable()
    del hf_inspector

    # pull faces ---------------------------------------------------------------
    rhino_volmesh_pull_halffaces(force.diagram, hfkey=halfface)

    # check if there is form diagram -------------------------------------------
    objects = scene.find_by_name('form')
    if not objects:
        force.check_eq()
        scene.update()
        return
    form = objects[0]

    # update -------------------------------------------------------------------
    form.diagram.update_angle_deviations()

    form.check_eq()
    force.check_eq()

    scene.update()
    scene.save()
Beispiel #28
0
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']

    objects = scene.find_by_name('Form')
    if not objects:
        compas_rhino.display_message("There is no FormDiagram in the scene.")
        return

    answer = compas_rhino.rs.GetString("Force Polygons Inspector", "Cancel",
                                       ["On", "Off", "Cancel"])
    if answer == "On":
        AGS_form_inspector_on_cmd.RunCommand(True)
    if answer == "Off":
        AGS_form_inspector_off_cmd.RunCommand(True)
def RunCommand(is_interactive):

    if 'AGS' not in sc.sticky:
        compas_rhino.display_message('AGS has not been initialised yet.')
        return

    options = ["FromObj", "FromLines", "FromLayer"]
    option = compas_rhino.rs.GetString("Create Form:", strings=options)

    if not option:
        return

    if option == "FromObj":
        AGS_form_from_obj_cmd.RunCommand(True)

    elif option == "FromLines":
        AGS_form_from_lines_cmd.RunCommand(True)

    elif option == "FromLayer":
        AGS_form_from_layer_cmd.RunCommand(True)
Beispiel #30
0
def RunCommand(is_interactive):

    if 'AGS' not in sc.sticky:
        compas_rhino.display_message('AGS has not been initialised yet.')
        return

    options = ["EdgesTable", "EdgeInformation", "ForcePolygons"]
    option = compas_rhino.rs.GetString("Create Form:", strings=options)

    if not option:
        return

    if option == "EdgesTable":
        AGS_edges_table_cmd.RunCommand(True)

    elif option == "EdgeInformation":
        AGS_edge_information_cmd.RunCommand(True)

    elif option == "ForcePolygons":
        AGS_form_inspector_control_cmd.RunCommand(True)