def process(self): asset = self.data["asset"] subset = self.data["subset"] name = pype.blender.plugin.asset_name(asset, subset) collection = bpy.data.collections.new(name=name) bpy.context.scene.collection.children.link(collection) self.data['task'] = api.Session.get('AVALON_TASK') lib.imprint(collection, self.data) # Add the rig object and all the children meshes to # a set and link them all at the end to avoid duplicates. # Blender crashes if trying to link an object that is already linked. # This links automatically the children meshes if they were not # selected, and doesn't link them twice if they, insted, # were manually selected by the user. objects_to_link = set() if (self.options or {}).get("useSelection"): for obj in lib.get_selection(): objects_to_link.add(obj) if obj.type == 'ARMATURE': for subobj in obj.children: objects_to_link.add(subobj) for obj in objects_to_link: collection.objects.link(obj) return collection
def process(self): asset = self.data["asset"] subset = self.data["subset"] name = pype.blender.plugin.asset_name(asset, subset) collection = bpy.data.collections.new(name=name) bpy.context.scene.collection.children.link(collection) self.data['task'] = api.Session.get('AVALON_TASK') lib.imprint(collection, self.data) if (self.options or {}).get("useSelection"): for obj in lib.get_selection(): collection.objects.link(obj) return collection
def process(self): asset = self.data["asset"] subset = self.data["subset"] name = pype.hosts.blender.plugin.asset_name(asset, subset) collection = bpy.data.collections.new(name=name) bpy.context.scene.collection.children.link(collection) self.data['task'] = api.Session.get('AVALON_TASK') lib.imprint(collection, self.data) if (self.options or {}).get("useSelection"): for obj in lib.get_selection(): if (obj.animation_data is not None and obj.animation_data.action is not None): empty_obj = bpy.data.objects.new(name=name, object_data=None) empty_obj.animation_data_create() empty_obj.animation_data.action = obj.animation_data.action empty_obj.animation_data.action.name = name collection.objects.link(empty_obj) return collection