Esempio n. 1
0
    if DiagramHelper.move_vertex(form, key):
        form.draw(layer='TNA::FormDiagram', clear_layer=True)

# 4. set the constraints
# Note: you should apply 3 sets of constraints
#       1. the edges in the spanning direction                 => fmin := 2, fmax := 2
#       2. the edges in the spanning direction on the boundary => fmin := 1, fmin := 1
#       3. the edges in the opposite direction                 => fmin := 0, fmax := 0

while True:
    edges = DiagramHelper.select_edges(form)
    if not edges:
        break

    if DiagramHelper.update_edge_attributes(form, edges):
        form.draw(layer='TNA::FormDiagram', clear_layer=True)

# 5. make the force diagram

force = ForceDiagram.from_formdiagram(form)
force.draw(layer='TNA::ForceDiagram', clear_layer=True)

DiagramHelper.move(force)
force.draw(layer='TNA::ForceDiagram', clear_layer=True)

# 6. compute horizontal equilibrium

horizontal(form, force, alpha=100, kmax=500)
force.draw(layer='TNA::ForceDiagram', clear_layer=True)
Esempio n. 2
0
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

form.draw(layer='AAG::FormDiagram')
force.draw(layer='AAG::ForceDiagram')
Esempio n. 3
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
Esempio n. 4
0
key = DiagramHelper.select_vertex(force)
if key is not None:
    force.vertex_attribute(key, 'is_fixed', True)
    force.draw(layer='TNA::ForceDiagram', clear_layer=True)

# set the constraints for the edges in the spanning direction
# => fmin := 2, fmax := 2

guids = compas_rhino.get_curves(layer='spanning')
if guids:
    keys = DiagramHelper.identify_edges_on_curves(form, guids)
    if keys:
        DiagramHelper.highlight_edges(form, keys)
        if DiagramHelper.update_edge_attributes(form,
                                                keys,
                                                names=['fmin', 'fmax']):
            form.draw(layer='TNA::FormDiagram', clear_layer=True)

# set the constraints for the edges on the boundary
# => fmin := 1, fmax := 1

guids = compas_rhino.get_curves(layer='boundary')
if guids:
    keys = DiagramHelper.identify_edges_on_curves(form, guids)
    if keys:
        DiagramHelper.highlight_edges(form, keys)
        if DiagramHelper.update_edge_attributes(form,
                                                keys,
                                                names=['fmin', 'fmax']):
            form.draw(layer='TNA::FormDiagram', clear_layer=True)
Esempio n. 5
0
def RunCommand(is_interactive):
    if 'TNA' not in sc.sticky:
        raise Exception("Initialise the plugin first!")

    TNA = sc.sticky['TNA']

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

    if option == 'form':
        form = TNA['form']
        if not form:
            return

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

        if option == 'vertices':
            keys = DiagramHelper.select_vertices(form)
            if not keys:
                return
            if DiagramHelper.update_vertex_attributes(form, keys):
                form.draw(layer=TNA['settings']['layer.form'],
                          clear_layer=True,
                          settings=TNA['settings'])

        elif option == 'edges':
            keys = DiagramHelper.select_edges(form)
            if not keys:
                return
            if DiagramHelper.update_edge_attributes(form, keys):
                form.draw(layer=TNA['settings']['layer.form'],
                          clear_layer=True,
                          settings=TNA['settings'])

        elif option == 'faces':
            keys = DiagramHelper.select_faces(form)
            if not keys:
                return
            if DiagramHelper.update_face_attributes(form, keys):
                form.draw(layer=TNA['settings']['layer.form'],
                          clear_layer=True,
                          settings=TNA['settings'])

    if option == 'force':
        force = TNA['force']
        if not force:
            return

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

        if option == 'vertices':
            keys = DiagramHelper.select_vertices(force)
            if not keys:
                return
            if DiagramHelper.update_vertex_attributes(force, keys):
                force.draw(layer=TNA['settings']['layer.force'],
                           clear_layer=True,
                           settings=TNA['settings'])

        elif option == 'edges':
            keys = DiagramHelper.select_edges(force)
            if not keys:
                return
            if DiagramHelper.update_edge_attributes(force, keys):
                force.draw(layer=TNA['settings']['layer.force'],
                           clear_layer=True,
                           settings=TNA['settings'])