Exemplo n.º 1
0
import os
from compas_fofin.datastructures import Cablenet
from compas_fofin.rhino import CablenetArtist
from compas_fofin.equilibrium import cablenet_fd_alglib

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

cablenet = Cablenet.from_obj(FILE)
cablenet.set_vertices_attribute('is_anchor',
                                True,
                                keys=cablenet.vertices_where(
                                    {'vertex_degree': 1}))

cablenet_fd_alglib(cablenet)

artist = CablenetArtist(cablenet, layer="FoFin::Cablenet")
artist.clear_layer()
artist.draw_vertices()
artist.draw_edges()
artist.draw_forces(scale=0.05)
artist.draw_loads()
artist.draw_reactions()
artist.redraw()
Exemplo n.º 2
0
 def draw(self, layer=None, clear_layer=True, settings=None):
     from compas_fofin.rhino import CablenetArtist
     layer = layer or settings.get('layer')
     artist = CablenetArtist(self, layer=layer)
     if clear_layer:
         artist.clear_layer()
     if settings.get('show.vertices', True):
         vertexcolor = {}
         vertexcolor.update({
             key: (0, 255, 0)
             for key in self.vertices_where_predicate(
                 lambda key, attr: attr['constraint'] is not None)
         })
         vertexcolor.update({
             key: (255, 0, 0)
             for key in self.vertices_where({'is_anchor': True})
         })
         artist.draw_vertices(color=vertexcolor)
     if settings.get('show.edges', True):
         artist.draw_edges()
     if settings.get('show.faces', True):
         artist.draw_faces()
     if settings.get('show.normals', False):
         artist.draw_normals(scale=settings.get('scale.normals'))
     if settings.get('show.forces', False):
         artist.draw_forces(compression=settings.get(
             'color.forces:compression', None),
                            tension=settings.get('color.forces:tension',
                                                 None),
                            scale=settings.get('scale.forces', None))
     if settings.get('show.reactions', False):
         artist.draw_reactions(color=settings.get('color.reactions', None),
                               scale=settings.get('scale.reactions', None))
     if settings.get('show.residuals', False):
         artist.draw_residuals(color=settings.get('color.residuals', None),
                               scale=settings.get('scale.residuals', None),
                               tol=settings.get('tol.residuals', None))
     if settings.get('show.loads', False):
         artist.draw_loads(color=settings.get('color.loads', None),
                           scale=settings.get('scale.loads', None))
     if settings.get('show.selfweight', False):
         artist.draw_selfweight(color=settings.get('color.selfweight',
                                                   None),
                                scale=settings.get('scale.selfweight',
                                                   None))
     if settings.get('show.stress', False):
         artist.draw_stress(scale=settings.get('scale.stress', None))
     artist.redraw()
def draw():
    artist.clear_layer()
    artist.draw_vertices(color={
        key: (255, 0, 0)
        for key in cablenet.vertices_where({'is_anchor': True})
    })
    artist.draw_edges()
    artist.redraw()


cablenet = Cablenet.from_obj(compas.get('faces.obj'))

for key, attr in cablenet.vertices(True):
    attr['is_anchor'] = cablenet.vertex_degree(key) == 2

artist = CablenetArtist(cablenet, layer="Mesh::FD")

draw()

while True:
    selected = CablenetHelper.select_vertices(cablenet)
    if not selected:
        break

    if CablenetHelper.update_vertex_attributes(cablenet, selected):
        cablenet_fd(cablenet)
        draw()

while True:
    selected = CablenetHelper.select_edges(cablenet)
    if not selected:
Exemplo n.º 4
0
def RunCommand(is_interactive):
    if "FoFin" not in sc.sticky:
        raise Exception("Initialise the plugin first!")

    cablenet = sc.sticky["FoFin"]['cablenet']
    settings = sc.sticky["FoFin"]['settings']

    if not cablenet:
        return

    if compas_rhino.update_settings(settings):
        artist = CablenetArtist(cablenet, layer=settings['layer'])
        artist.clear_layer()
        artist.draw_mesh()
        artist.draw_vertices()
        artist.draw_edges()
        artist.redraw()
Exemplo n.º 5
0
def RunCommand(is_interactive):
    if "FoFin" not in sc.sticky:
        raise Exception("Initialise the plugin first!")

    settings = sc.sticky["FoFin"]['settings']

    filepath = compas_rhino.browse_for_file()
    if not filepath:
        return

    if not filepath.endswith('.json'):
        return

    cablenet = Cablenet.from_json(filepath)

    sc.sticky["FoFin"]["cablenet"] = cablenet

    artist = CablenetArtist(cablenet, layer=settings['layer'])
    artist.clear_layer()
    artist.draw_mesh()
    artist.draw_vertices()
    artist.draw_edges()
    artist.redraw()