Ejemplo n.º 1
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()
Ejemplo n.º 2
0
from compas_ags.diagrams import FormDiagram
from compas_ags.diagrams import ForceDiagram

from compas_ags.rhino import Scene

graphstatics = Proxy('compas_ags.ags.graphstatics')

HERE = os.path.dirname(__file__)
DATA = os.path.join(HERE, '../data')
FILE = os.path.join(DATA, 'debugging', 'truss.obj')

# ==============================================================================
# Init
# ==============================================================================

graph = FormGraph.from_obj(FILE)

form = FormDiagram.from_graph(graph)
force = ForceDiagram.from_formdiagram(form)

# ==============================================================================
# Boundary conditions
# ==============================================================================

form.edge_force((0, 1), -1.0)
form.edge_force((2, 3), -1.0)
form.edge_force((4, 5), -1.0)

# ==============================================================================
# Equilibrium
# ==============================================================================
import compas_ags
from compas_ags.diagrams import FormGraph
from compas_ags.diagrams import FormDiagram
from compas_ags.diagrams import ForceDiagram
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),
]
Ejemplo n.º 4
0
import compas_ags

from compas_ags.diagrams import FormGraph
from compas_ags.diagrams import FormDiagram
from compas_ags.diagrams import ForceDiagram
from compas_ags.ags import graphstatics

from compas_ags.viewers import Viewer

# ------------------------------------------------------------------------------
# 1. get lines of a plane triangle frame in equilibrium, its applied loads and reaction forces
#    make form and force diagrams
# ------------------------------------------------------------------------------

graph = FormGraph.from_obj(compas_ags.get('paper/gs_form_force.obj'))

form = FormDiagram.from_graph(graph)
force = ForceDiagram.from_formdiagram(form)

# ------------------------------------------------------------------------------
# 2. set applied load
# ------------------------------------------------------------------------------

# choose an independent edge and set the magnitude of the applied load
# the system is statically determinate, thus choosing one edge is enough
form.edge_force(0, -30.0)

# update force densities of form and force diagrams
graphstatics.form_update_q_from_qind(form)
graphstatics.force_update_from_form(force, form)
Ejemplo n.º 5
0
            'width': 1.0,
            'color': '#cccccc',
            'style': '--'
        })

    return form_lines, force_lines


# ------------------------------------------------------------------------------
#   1. Problem of getting to a funicular shape
#       - Input a circular arch
#       - Input "target forces" for the loads applied
#       - Update form and force diagram
# ------------------------------------------------------------------------------

graph = FormGraph.from_obj(compas_ags.get('paper/exA_arch-circular.obj'))
form = FormDiagram.from_graph(graph)
edge_index = form.edge_index()
index_edge = form.index_edge()

# create a dual force diagram
force = ForceDiagram.from_formdiagram(form)

# create label for plots
force_edges = force.ordered_edges(form)
force_edge_labels = {(u, v): index for index, (u, v) in enumerate(force_edges)}
force_edge_labels.update({(v, u): index for index, (u, v) in enumerate(force_edges)})

# set supports
supports = [1, 7]
for key in supports:
Ejemplo n.º 6
0
import random

import compas
import compas_ags

from compas_ags.diagrams import FormGraph
from compas_ags.diagrams import FormDiagram
from compas_ags.diagrams import ForceDiagram
from compas_ags.ags import graphstatics

from compas_ags.viewers import Viewer

graph = FormGraph.from_obj(compas.get('lines.obj'))

form = FormDiagram.from_graph(graph)
force = ForceDiagram.from_formdiagram(form)

form.vertices_attribute('is_fixed', True, keys=form.leaves())

k, m, ind = graphstatics.form_identify_dof(form)

for u, v in ind:
    form.edge_attributes((u, v), ('is_ind', 'q'),
                         (True, random.choice(range(2, 20))))

graphstatics.form_update_q_from_qind(form)
graphstatics.force_update_from_form(force, form)

viewer = Viewer(form, force, delay_setup=False)

viewer.draw_form(vertexsize=0.15, external_on=False)
Ejemplo n.º 7
0
from compas.geometry import subtract_vectors
from compas.geometry import sum_vectors
from compas.geometry import normalize_vector
from compas.geometry import scale_vector

from compas_ags.diagrams import FormGraph
from compas_ags.diagrams import FormDiagram

from compas_plotters import MeshPlotter

# ==============================================================================
# Construct the graph of a Fink truss.
# ==============================================================================

graph = FormGraph.from_obj(compas_ags.get('paper/fink.obj'))

# ==============================================================================
# Identify the fixed points of the graph.
# ==============================================================================

fixed = [6, 9]

# ==============================================================================
# Assert that the graph is 2D and that it is planar.
# ==============================================================================

assert graph.is_2d(), "The graph is not 2D."
assert graph.is_planar(), "The graph is not planar."

# ==============================================================================
                    edgelabel={uv: str(force.dual_edgelength(uv)) for uv in force.edges()})
    viewer.show()


# ------------------------------------------------------------------------------
#   5. Dense Constant force truss
#       - Input a non-triangulated dense truss, compute initial equilibrium
#       - Constraint top chord to constant force and move bottom chord to a sinusoidal shape
#       - Constraint the applied loads magnitude
# ------------------------------------------------------------------------------

# ------------------------------------------------------------------------------
#   1. Get geometry, apply loads and and compute equilibrium
# ------------------------------------------------------------------------------

graph = FormGraph.from_obj(compas_ags.get('paper/exE_truss_dense.obj'))

form = FormDiagram.from_graph(graph)
force = ForceDiagram.from_formdiagram(form)
force_edges = force.ordered_edges(form)

force_edge_labels1 = {(u, v): index for index, (u, v) in enumerate(force_edges)}
force_edge_labels2 = {(v, u): index for index, (u, v) in enumerate(force_edges)}
force_edge_labels = {**force_edge_labels1, **force_edge_labels2}

# prescribe force density to edge
edges_ind = [
    (17, 22),
]
load = 1.0
for index in edges_ind:

# ------------------------------------------------------------------------------
#   4. Constant force truss
#       - Input a non-triangulated truss, compute initial equilibrium
#       - Move the form diagram support
#       - Move one of the internal nodes to a specific position
# ------------------------------------------------------------------------------

# ------------------------------------------------------------------------------
#   1. Get geometry, apply loads and and compute equilibrium
# ------------------------------------------------------------------------------

input_file = compas_ags.get('paper/exD_truss.obj')

graph = FormGraph.from_obj(input_file)
form = FormDiagram.from_graph(graph)
force = ForceDiagram.from_formdiagram(form)
force_edges = force.ordered_edges(form)

force_edge_labels1 = {(u, v): index for index, (u, v) in enumerate(force_edges)}
force_edge_labels2 = {(v, u): index for index, (u, v) in enumerate(force_edges)}
force_edge_labels = {**force_edge_labels1, **force_edge_labels2}

# prescribe force density to edge
edges_ind = [
    (13, 14),
]
for index in edges_ind:
    u, v = index
    form.edge_attribute((u, v), 'is_ind', True)