How to use the compas.get function in compas

To help you get started, we’ve selected a few compas examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github compas-dev / compas / tests / compas / datastructures / test_mesh.py View on Github external
def test_is_vertex_on_boundary():
    mesh = Mesh.from_obj(compas.get('faces.obj'))
    assert mesh.is_vertex_on_boundary(0)
    assert not mesh.is_vertex_on_boundary(15)
github compas-dev / compas / src / compas_blender / artists / networkartist.py View on Github external
self.clear_vertices()
        self.clear_edges()


# ==============================================================================
# Main
# ==============================================================================

if __name__ == "__main__":

    import compas

    from compas.datastructures import Network


    network = Network.from_obj(compas.get('grid_irregular.obj'))

    artist = NetworkArtist(network=network)

    #artist.clear_layer()

    artist.draw_vertices(radius=0.05)
    artist.draw_vertexlabels()
    #artist.clear_vertexlabels()
github compas-dev / compas / docs / examples / rhino / mesh-stanford-armadillo.py View on Github external
import compas
import compas_rhino

from compas.datastructures import Mesh


__author__    = ['Tom Van Mele', ]
__copyright__ = 'Copyright 2016 - Block Research Group, ETH Zurich'
__license__   = 'MIT License'
__email__     = 'van.mele@arch.ethz.ch'


mesh = Mesh.from_ply(compas.get('stanford_armadillo.ply'))

compas_rhino.mesh_draw(mesh)
github compas-dev / compas / src / compas_plotters / networkplotter.py View on Github external
#     self.draw_edges(
    #         color={(u, v): '#ff0000' for u, v in edges},
    #         width={(u, v): 5.0 for u, v in edges}
    #     )


# ==============================================================================
# Main
# ==============================================================================

if __name__ == "__main__":

    import compas
    from compas.datastructures import Network

    network = Network.from_obj(compas.get('grid_irregular.obj'))

    plotter = NetworkPlotter(network, figsize=(10, 8))

    plotter.draw_vertices(radius=0.1, picker=10)
    plotter.draw_edges()

    default = [plotter.defaults['vertex.facecolor'] for key in network.vertices()]
    highlight = '#ff0000'

    def on_pick(event):
        index = event.ind[0]

        colors = default[:]
        colors[index] = highlight

        plotter.vertexcollection.set_facecolor(colors)
github compas-dev / compas / src / compas / datastructures / network / planarity_.py View on Github external
return True


# ==============================================================================
# Main
# ==============================================================================

if __name__ == '__main__':

    import compas

    from compas.datastructures import Network
    from compas_plotters import NetworkPlotter

    network = Network.from_obj(compas.get('lines.obj'))

    network.add_edge(6, 15)

    if not network_is_planar(network):
        crossings = network_find_crossings(network)
    else:
        crossings = []

    print(crossings)

    plotter = NetworkPlotter(network)

    plotter.draw_vertices(radius=0.15, text={key: key for key in network.vertices()})
    plotter.draw_edges(color={edge: '#ff0000' for edges in crossings for edge in edges})

    plotter.show()
github compas-dev / compas / src / compas / geometry / offset / offset.py View on Github external
for line, distance in zip(pairwise(point_list), distances):
        segments.append(offset_line(line, distance, normal))
    return segments

# ==============================================================================
# Main
# ==============================================================================

if __name__ == "__main__":

    import compas

    from compas_plotters import MeshPlotter
    from compas.datastructures import Mesh

    mesh = Mesh.from_obj(compas.get('faces.obj'))

    polygons = []
    lines = []
    for fkey in mesh.faces():
        points = mesh.face_coordinates(fkey)
        offset = offset_polyline(points, 0.1)
        polygons.append({
            'points': offset,
            'edgecolor': '#ff0000'
        })
        for a, b in zip(points, offset):
            lines.append({
                'start': a,
                'end': b,
                'color': '#00ff00'
            })
github compas-dev / compas / src / compas_rhino / artists / volmeshartist.py View on Github external
self.clear_faces()
        self.clear_edges()


# ==============================================================================
# Main
# ==============================================================================

if __name__ == "__main__":

    import compas

    from compas.datastructures import VolMesh
    from compas_rhino.artists.volmeshartist import VolMeshArtist

    volmesh = VolMesh.from_obj(compas.get('boxes.obj'))

    artist = VolMeshArtist(volmesh, layer='VolMeshArtist')

    artist.clear_layer()

    artist.draw_vertices()
    artist.redraw(0.0)

    artist.draw_vertexlabels()
    artist.redraw(1.0)

    artist.draw_faces()
    artist.redraw(1.0)

    artist.draw_facelabels()
    artist.redraw(1.0)
github compas-dev / compas / src / compas / datastructures / mesh / matrices.py View on Github external
area[:len(b)] += b
    return spdiags(area, 0, xyz.shape[0], xyz.shape[0])


# ==============================================================================
# Main
# ==============================================================================

if __name__ == "__main__":

    import doctest

    import compas
    from compas.datastructures import Mesh

    mesh = Mesh.from_obj(compas.get('faces.obj'))

    doctest.testmod()
github compas-dev / compas / src / compas / topology / combinatorics.py View on Github external
tovisit -= visited
        components.append(list(visited))
    return components


# ==============================================================================
# Main
# ==============================================================================

if __name__ == "__main__":

    import compas
    from compas.datastructures import Network
    from compas_plotters import NetworkPlotter

    network = Network.from_obj(compas.get('grid_irregular.obj'))

    components = connected_components(network.adjacency)

    key_color = vertex_coloring(network.adjacency)

    colors = ['#ff0000', '#00ff00', '#0000ff', '#ffff00']

    plotter = NetworkPlotter(network, figsize=(10, 7))

    plotter.draw_vertices(facecolor={key: colors[key_color[key]] for key in network.vertices()})
    plotter.draw_edges()

    plotter.show()