Example #1
0
def from_vertices_and_faces(vs, fs):
    mesh = Mesh.from_vertices_and_faces(vs, fs)
    form = FormDiagram.from_mesh(mesh)
    corners = list(form.vertices_where({'vertex_degree': 2}))

    form.vertices_attribute('is_anchor', True, keys=corners)
    form.edges_attribute('q', 10.0, keys=form.edges_on_boundary())
    relax_boundary_openings(form, corners)

    form.update_boundaries()
    force = ForceDiagram.from_formdiagram(form)

    horizontal_nodal(form, force, alpha=95)
    scale = vertical_from_zmax(form, 450.0)

    return form
from compas.plotters import MeshPlotter

from compas_tna.diagrams import FormDiagram
from compas_tna.utilities import relax_boundary_openings

form = FormDiagram.from_obj('data/rhinomesh.obj')

corners = list(form.vertices_where({'vertex_degree': 2}))

form.set_vertices_attributes(('is_anchor', 'is_fixed'), (True, True),
                             keys=corners)
form.set_edges_attribute('q', 10.0, keys=form.edges_on_boundary())

relax_boundary_openings(form)

form.update_boundaries(feet=2)

form.to_json('data/boundaryconditions.json')

# ==============================================================================
# Visualisation
# ==============================================================================

plotter = MeshPlotter(form, figsize=(12, 8), tight=True)

vertexcolor = {}
vertexcolor.update(
    {key: '#00ff00'
     for key in form.vertices_where({'is_fixed': True})})
vertexcolor.update(
    {key: '#0000ff'
from compas_plotters import MeshPlotter
from compas_tna.diagrams import FormDiagram
from compas_tna.utilities import relax_boundary_openings

FILE_I = compas_tna.get('tutorial/rhinomesh.obj')
FILE_O = compas_tna.get('tutorial/boundaryconditions.json')

form = FormDiagram.from_obj(FILE_I)

corners = list(form.vertices_where({'vertex_degree': 2}))

form.vertices_attribute('is_anchor', True, keys=corners)
form.edges_attribute('q', 10.0, keys=form.edges_on_boundary())

relax_boundary_openings(form, corners)

form.update_boundaries(feet=2)

form.to_json(FILE_O)

# ==============================================================================
# Visualisation
# ==============================================================================

plotter = MeshPlotter(form, figsize=(12, 8), tight=True)

vertexcolor = {}
vertexcolor.update(
    {key: '#00ff00'
     for key in form.vertices_where({'is_fixed': True})})