Example #1
0
def initiate_mesh(layer):
    
    objs = rs.ObjectsByLayer(layer)
    lines = [(rs.CurveStartPoint(crv), rs.CurveEndPoint(crv)) for crv in objs]
    rs.DeleteObjects(objs)
    
    objs_dict = {}
    for i, pts in enumerate(lines):
        cent = centroid_points(pts)
        objs_dict[geometric_key(cent)] = str(objs[i]) 
        
    mesh = Mesh.from_lines(lines)
    
    for u,v, attr in mesh.edges(True):
        cent = centroid_points([mesh.vertex_coordinates(u), mesh.vertex_coordinates(v)])
        attr['master'] = False
        attr['color'] = [50, 255, 100]
        attr['passive'] = False
        attr['id'] = objs_dict[geometric_key(cent)]
        name = 'e_' + str(u) + '_' + str(v)
        
    return mesh
Example #2
0
from compas.geometry.algorithms.smoothing import mesh_smooth_area
from compas.geometry.algorithms.smoothing_cpp import smooth_centroid_cpp
from compas_pattern.algorithms.smoothing import define_constraints
from compas_pattern.algorithms.smoothing import apply_constraints

surface_guid = rs.GetObject('srf', filter=8)
curve_features_guids = rs.GetObjects('crv features', filter=4)
if curve_features_guids is None:
    curve_features_guids = []
point_features_guids = rs.GetObjects('pt features', filter=1)
if point_features_guids is None:
    point_features_guids = []

lines = rs.GetObjects('lines', filter=4)
edges = [[rs.CurveStartPoint(line), rs.CurveEndPoint(line)] for line in lines]
mesh = Mesh.from_lines(edges)

print mesh.number_of_vertices() - mesh.number_of_edges(
) + mesh.number_of_faces()
faces = list(mesh.faces())
for fkey in faces:
    if len(mesh.face_vertices(fkey)) > 10:
        mesh.delete_face(fkey)
print mesh.number_of_vertices() - mesh.number_of_edges(
) + mesh.number_of_faces()

smooth_mesh = mesh.copy()
smooth_mesh.cull_vertices()
constraints, surface_boundaries = define_constraints(
    smooth_mesh,
    surface_guid,