def update_network_from_points(network, guids):
    points = compas_rhino.get_point_coordinates(guids)
    names = compas_rhino.get_object_names(guids)
    gkey_key = {geometric_key(network.vertex_coordinates(key)): key for key in network}
    for i, xyz in enumerate(points):
        name = names[i]
        try:
            attr = ast.literal_eval(name)
        except ValueError:
            pass
        else:
            gkey = geometric_key(xyz)
            if gkey in gkey_key:
                key = gkey_key[gkey]
                network.vertex[key].update(attr)
Exemple #2
0
def RunCommand(is_interactive):
    scene = get_scene()
    if not scene:
        return

    guids = compas_rhino.select_point()
    if not guids:
        return

    pt = compas_rhino.get_point_coordinates([guids])[0]
    skeleton = Skeleton.from_center_point(pt)
    if not skeleton:
        return

    compas_rhino.delete_objects([guids])

    rhinoskeleton = scene.add(skeleton, 'skeleton')
    rhinoskeleton.dynamic_draw_self()
    rhinoskeleton.draw_self()
Exemple #3
0
# select the original mesh
# select the border
# select the fixed points

guid_target = compas_rhino.select_mesh()
guid_border = compas_rhino.select_polyline()
guid_points = compas_rhino.select_points()

# wrap the Rhino mesh object for convenience
# wrap the Rhino curve object for convenience
# get the point coordinates

target = RhinoMesh(guid_target)
border = RhinoCurve(guid_border)
points = compas_rhino.get_point_coordinates(guid_points)

# make a mesh datastructure from the Rhino mesh
# triangulate the mesh

mesh = mesh_from_guid(Mesh, guid_target)
mesh_quads_to_triangles(mesh)

# identify the fixed vertices
# by matching the coordinates of the selected points
# up to a precision

keys = mesh_identify_vertices(mesh, points, '1f')
fixed = set(keys)

# create a conduit for visualisation
Exemple #4
0
            attr['y'] = y
            attr['z'] = z

    # update the conduit at the specified rate
    conduit.redraw(k)


# get the target mesh
# and its border

guid_target = compas_rhino.select_mesh()
guid_border = compas_rhino.select_polyline()

# get fixed points

points = compas_rhino.get_point_coordinates(compas_rhino.select_points())

# triangulate the input mesh

rs.MeshQuadsToTriangles(guid_target)

# make a remeshing mesh

mesh = compas_rhino.mesh_from_guid(Mesh, guid_target)

# update its attributes

mesh.attributes['name'] = 'Remeshed'
mesh.update_default_vertex_attributes({'is_fixed': False})

# make the target and border objects
def RunCommand(is_interactive):
    scene = get_scene()
    if not scene:
        return

    # skeleton from single point or a set of lines
    guids_temp = compas_rhino.rs.GetObjects(
        message="Select a single point or a group of lines",
        filter=compas_rhino.rs.filter.point | compas_rhino.rs.filter.curve)

    if not guids_temp:
        return

    # detect input object type
    guids_points = []
    guids_lines = []
    for guid in guids_temp:
        if is_curve_line(guid):
            guids_lines.append(guid)

        if compas_rhino.rs.IsPoint(guid):
            guids_points.append(guid)

    if len(guids_points) == 1 and len(guids_lines) == 0:
        guids = guids_points
        point = compas_rhino.get_point_coordinates(guids)[0]
        skeleton = Skeleton.from_center_point(point)

    elif len(guids_points) == 0 and len(guids_lines) > 0:
        guids = guids_lines
        lines = compas_rhino.get_line_coordinates(guids)
        skeleton = Skeleton.from_skeleton_lines(lines)

    if not skeleton:
        return

    compas_rhino.rs.HideObjects(guids)
    skeletonobject = SkeletonObject(skeleton)
    skeletonobject.draw()
    skeletonobject.dynamic_draw_widths()

    # modify skeleton
    while True:
        menu = CommandMenu(config)
        action = menu.select_action()
        if not action:
            return

        if action['name'] == 'Finish':
            break

        action['action'](skeletonobject)
        skeletonobject.draw()

    # make pattern
    mesh = skeletonobject.skeleton.to_mesh()
    xyz = mesh.vertices_attributes('xyz')
    faces = [mesh.face_vertices(fkey) for fkey in mesh.faces()]
    pattern = Pattern.from_vertices_and_faces(xyz, faces)

    # clear skeleton
    layer = skeletonobject.settings['layer']
    skeletonobject.clear()
    compas_rhino.delete_layers([layer])

    scene.clear()
    scene.add(pattern, name='pattern')
    scene.update()

    print("Pattern object successfully created. Input lines have been hidden.")
Exemple #6
0
"""Delaunay triangulation from points"""

import compas_rhino as rhino

from compas.datastructures.mesh import Mesh
from compas.datastructures.mesh.algorithms import delaunay_from_points

__author__ = ['Tom Van Mele', 'Matthias Rippmann']
__copyright__ = 'Copyright 2017, BRG - ETH Zurich',
__license__ = 'MIT'
__email__ = '*****@*****.**'

guids = rhino.select_points()
vertices = rhino.get_point_coordinates(guids)

faces = delaunay_from_points(vertices)

mesh = Mesh.from_vertices_and_faces(vertices, faces)

rhino.draw_mesh(mesh)