예제 #1
0
from compas_tna.equilibrium import vertical_from_zmax_rhino as vertical

# create diagrams from serialised files

form = FormDiagram.from_json('aag_06_distribution_formdiagram.json')
force = ForceDiagram.from_json('aag_06_distribution_forcediagram.json')

# visualise the diagrams

form.draw(layer='AAG::FormDiagram')
force.draw(layer='AAG::ForceDiagram')

# update the force bounds on the edges of the form diagram

while True:
    keys = DiagramHelper.select_continuous_edges(form)
    if not keys:
        break
    DiagramHelper.update_edge_attributes(form, keys)

# update the horizontal equilibrium

horizontal(form, force, alpha=100, kmax=1000)

# compute the scale of the force diagram
# such that the highest vertex of the form diagram is at a prescribed value

zmax = 3
force.attributes['scale'] = vertical(form, zmax, kmax=100)

# draw the result
예제 #2
0
def RunCommand(is_interactive):
    if 'TNA' not in sc.sticky:
        raise Exception("Initialise the plugin first!")

    TNA = sc.sticky['TNA']
    form = TNA['form']
    force = TNA['force']
    settings = TNA['settings']

    options = ['form', 'force']
    option = rs.GetString("Select a Diagram", options[0], options)
    if not option:
        return

    if option == 'form':
        if not form:
            return

        options = ['vertices', 'edges', 'faces']
        option = rs.GetString("Select a component", options[0], options)
        if not option:
            return

        if option == 'vertices':
            options = ['selection', 'boundary', 'anchors', 'external', 'all']
            option = rs.GetString("Selection mode", options[0], options)
            if not option:
                return

            if option == 'selection':
                keys = DiagramHelper.select_vertices(form)
            elif option == 'boundary':
                keys = list(form.vertices_on_boundary())
            elif option == 'anchors':
                keys = list(form.vertices_where({'is_anchor': True}))
            elif option == 'external':
                keys = list(form.vertices_where({'is_external': True}))
            elif option == 'all':
                keys = list(form.vertices())
            else:
                raise NotImplementedError

            if not keys:
                return

            if DiagramHelper.update_vertex_attributes(form, keys):
                form.draw(layer=settings['layer.form'],
                          clear_layer=True,
                          settings=settings)

        elif option == 'edges':
            options = [
                'selection', 'parallel', 'continuous', 'boundary', 'external',
                'all'
            ]
            option = rs.GetString("Selection mode", options[0], options)

            if option == 'selection':
                keys = DiagramHelper.select_edges(form)
            elif option == 'parallel':
                keys = DiagramHelper.select_parallel_edges(form)
            elif option == 'continuous':
                keys = DiagramHelper.select_continuous_edges(form)
            elif option == 'boundary':
                keys = list(form.edges_on_boundary())
            elif option == 'external':
                keys = list(form.edges_where({'is_external': True}))
            elif option == 'all':
                keys = list(form.edges())
            else:
                raise NotImplementedError

            if not keys:
                return

            if DiagramHelper.update_edge_attributes(form, keys):
                form.draw(layer=settings['layer.form'],
                          clear_layer=True,
                          settings=settings)

        elif option == 'faces':
            pass

        else:
            raise NotImplementedError