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()
from compas_rv2.datastructures import Skeleton from compas_rv2.rhino import SkeletonObject from compas_rv2.rhino import SkeletonArtist import compas_rhino guids = compas_rhino.select_lines() lines = compas_rhino.get_line_coordinates(guids) skeleton = Skeleton.from_skeleton_lines(lines) skeleton.update_mesh_vertices_pos() skeletonobject = SkeletonObject(skeleton) skeletonobject.draw() skeletonobject.dynamic_draw_widths() skeletonobject.move_skeleton_vertex() skeletonobject.draw() # skeletonobject.draw_mesh_vertices() # skeletonobject.move_mesh_vertex() # artist = SkeletonArtist(skeleton) # artist.draw_skeleton_vertices() # artist.draw_skeleton_edges() # artist.draw_mesh_vertices() # artist.draw_subd() # print(skeletonobject) # print(skeletonobject.artist)
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.")
from compas_rv2.datastructures import Skeleton from compas_rv2.rhino import RhinoSkeleton skeleton = Skeleton.from_json('skeleton_temp1.json') rhinoskeleton = RhinoSkeleton(skeleton) rhinoskeleton.dynamic_draw_self()