def mesh_update_vertex_attributes(mesh, keys, names=None): """Update the attributes of the vertices of a mesh. Parameters ---------- mesh : compas.datastructures.Mesh A mesh object. keys : tuple, list The keys of the vertices to update. names : tuple, list (None) The names of the atrtibutes to update. Default is to update all attributes. Returns ------- bool ``True`` if the update was successful. ``False`` otherwise. See Also -------- * :func:`mesh_update_attributes` * :func:`mesh_update_edge_attributes` * :func:`mesh_update_face_attributes` """ return VertexModifier.update_vertex_attributes(mesh, keys, names=names)
def mesh_move_vertices(mesh, keys): """Move on vertices of the mesh. Parameters ---------- mesh : compas.datastructures.Mesh A mesh object. keys : list The vertices to move. constraint : Rhino.Geometry (None) A Rhino geometry object to constrain the movement to. By default the movement is unconstrained. allow_off : bool (False) Allow the vertex to move off the constraint. """ return VertexModifier.move_vertices(mesh, keys)
def network_move_vertex(network, key, constraint=None, allow_off=False): """Move on vertex of the network. Parameters ---------- network : compas.datastructures.Network A network object. key : str The vertex to move. constraint : Rhino.Geometry (None) A Rhino geometry object to constrain the movement to. By default the movement is unconstrained. allow_off : bool (False) Allow the vertex to move off the constraint. """ return VertexModifier.move_vertex(network, key, constraint=constraint, allow_off=allow_off)
artist = MeshArtist(mesh, layer="Cablenet") artist.clear_layer() artist.draw_vertices(color=vertexcolor) artist.draw_edges(color=edgecolor) artist.redraw() # select mesh vertices # update the attributes # redraw mesh if successful while True: selected = VertexSelector.select_vertices(mesh) if not selected: break if VertexModifier.update_vertex_attributes(mesh, selected): artist.clear_layer() artist.draw_vertices(color=vertexcolor) artist.draw_edges(color=edgecolor) # select mesh edges # update the attributes # redraw mesh if successful while True: selected = EdgeSelector.select_edges(mesh) if not selected: break if EdgeModifier.update_edge_attributes(mesh, selected): artist.clear_layer() artist.draw_vertices(color=vertexcolor) artist.draw_edges(color=edgecolor)
# set default vertex attributes mesh.update_default_vertex_attributes({'is_fixed': False}) # make an artist for visualisation artist = MeshArtist(mesh, layer='SubdModeling::Control') # draw the control mesh draw_mesh() # allow the user to change the attributes of the vertices while True: keys = VertexSelector.select_vertices(mesh) if not keys: break VertexModifier.update_vertex_attributes(mesh, keys) draw_mesh() # make a subd mesh (using catmullclark) subd = mesh_subdivide(mesh, scheme='catmullclark', k=4, fixed=mesh.vertices_where({'is_fixed': True})) # give the subdivision mesh a different name subd.attributes['name'] = 'Mesh' # draw the result artist.mesh = subd artist.layer = 'SubdModeling::Mesh' artist.clear_layer()
def redraw(): artist.clear_layer() artist.draw_vertices() artist.draw_edges() artist.redraw() # ============================================================================== # Vertex attributes # ============================================================================== while True: keys = VertexSelector.select_vertices(shell) if not keys: break if VertexModifier.update_vertex_attributes(shell, keys): shell.fofin() redraw() # ============================================================================== # Export result # ============================================================================== shell.to_json(FILE) # ============================================================================== # Visualize result # ============================================================================== artist.clear_layer() artist.draw_vertices()