コード例 #1
0
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)
コード例 #2
0
from __future__ import print_function

import compas
import compas_rhino
import compas_tna

from compas_tna.diagrams import FormDiagram
from compas_tna.rhino import DiagramHelper

# create a form diagram from a set of lines

guid = compas_rhino.select_mesh()
form = FormDiagram.from_rhinomesh(guid)

# identify the supports
# as the vertices that lie on the support curves

guids = compas_rhino.select_curves()
keys = DiagramHelper.identify_vertices_on_curves(form, guids)

form.set_vertices_attribute('is_anchor', True, keys)

# update the boundaries to include the horizontal reaction forces

form.update_boundaries()

# serialise the result

form.to_json('aag_01_formdiagram_from_mesh.json')

# draw the result in the layer AAG > FormDiagram
コード例 #3
0
* a Rhino mesh
* a Rhino surface
* a set of Rhino lines

"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import compas_rhino

from compas_tna.diagrams import FormDiagram

guid = compas_rhino.select_mesh()

f1 = FormDiagram.from_rhinomesh(guid, name='FromMesh')

f1.draw(layer='TNA::FormDiagram::Mesh')

guid = compas_rhino.select_surface()

f2 = FormDiagram.from_rhinosurface(guid, name='FromSurf')

f2.draw(layer='TNA::FormDiagram::Surface')

guids = compas_rhino.select_lines()

f3 = FormDiagram.from_rhinolines(guids, name='FromLines')

f3.draw(layer='TNA::FormDiagram::Lines')