def RunCommand(is_interactive): if 'TNA' not in sc.sticky: raise Exception("Initialise the plugin first!") TNA = sc.sticky['TNA'] settings = TNA['settings'] options = ['obj', 'json', 'lines', 'mesh'] option = rs.GetString("Initialise FormDiagram from", options[0], options) if not option: return if option == 'obj': filepath = compas_rhino.select_file(folder=compas_tna.DATA, filter='OBJ files (*.obj)|*.obj||') if not filepath: return form = FormDiagram.from_obj(filepath) elif option == 'json': filepath = compas_rhino.select_file( folder=compas_tna.DATA, filter='JSON files (*.json)|*.json||') if not filepath: return form = FormDiagram.from_json(filepath) elif option == 'lines': guids = compas_rhino.select_lines() if not guids: return lines = compas_rhino.get_line_coordinates(guids) form = FormDiagram.from_lines(lines) elif option == 'mesh': guid = compas_rhino.select_mesh() if not guid: return form = FormDiagram.from_rhinomesh(guid) else: raise NotImplementedError del TNA['form'] del TNA['force'] TNA['form'] = form TNA['force'] = None compas_rhino.clear_layer(settings['layer.force']) form.draw(layer=settings['layer.form'], clear_layer=True, settings=settings)
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_tna.equilibrium import vertical_from_zmax_rhino as vertical_from_zmax from compas_tna.equilibrium import vertical_from_formforce_rhino as vertical_from_formforce from compas_tna.rhino import FormArtist __author__ = ['Tom Van Mele', ] __copyright__ = 'Copyright 2016 - Block Research Group, ETH Zurich' __license__ = 'MIT License' __email__ = '*****@*****.**' # make a form diagram from an obj file file = compas.get('faces.obj') form = FormDiagram.from_obj(file) # update the boundary conditions boundaries = form.vertices_on_boundaries() exterior = boundaries[0] interior = boundaries[1:] form.set_vertices_attribute('is_anchor', True, keys=exterior) form.update_exterior(exterior, feet=1) form.update_interior(interior) # create the force diagram
__copyright__ = 'Copyright 2016 - Block Research Group, ETH Zurich' __license__ = 'MIT License' __email__ = '*****@*****.**' __all__ = [] f = XFunc('compas_ags.ags.graphstatics.identify_dof_xfunc') def identify_dof(form): return f(form.to_data()) form = FormDiagram.from_obj(compas.get('lines.obj')) form.set_vertices_attributes(('is_fixed', 'is_anchor'), (True, True), keys=form.vertices_on_boundary()) form.set_edges_attribute('is_edge', False, keys=form.edges_on_boundary()) k, m, ind = identify_dof(form) for u, v in ind: form.set_edge_attributes((u, v), ('is_ind', 'q'), (True, random.choice(range(1, 5)))) vertical_from_qind(form) artist = FormArtist(form, layer='FormDiagram')
import compas_tna 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'