Another script š This one is called RotoExtractor and it extracts all the roto shapes (with their own animation) individualy and places them in a new roto node with a label to indicate what roto shape has been extracted there.
Here it is:
def rotoExtractor(): import copy for i in nuke.selectedNodes(): roto_curves = i['curves'] roto_root_layer = roto_curves.rootLayer roto_list = [] for roto_shape in roto_root_layer: roto_shape_name = roto_shape.name roto_list.append(roto_shape_name) roto_list_number = len(roto_list) hero_roto_shape = 0 for roto_shape in roto_root_layer: roto_name = i.name() copy.copy(i) new_roto = nuke.selectedNode() new_roto['label'].setValue(roto_list[hero_roto_shape]) new_roto_curves = new_roto['curves'] new_roto_root_layer = new_roto_curves.rootLayer for new_roto_shape in new_roto_root_layer: new_roto_shape_name = new_roto_shape.name if new_roto_shape_name != roto_list[hero_roto_shape]: roto_shape_cp_list = [] for cp in new_roto_curves.toElement(new_roto_shape_name): roto_shape_cp_list.append(cp) roto_shape_cp_number = len(roto_shape_cp_list) while roto_shape_cp_number >= 1: new_roto_curves.toElement(new_roto_shape_name).remove(0) roto_shape_cp_number = roto_shape_cp_number - 1 hero_roto_shape = hero_roto_shape + 1