You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							46 lines
						
					
					
						
							1.2 KiB
						
					
					
				
			
		
		
	
	
							46 lines
						
					
					
						
							1.2 KiB
						
					
					
				| import bpy
 | |
| 
 | |
| def main(context):
 | |
|     obs = list(context.selected_objects)
 | |
|     for ob in obs:
 | |
|         empty = bpy.data.objects.new(ob.name+"_empty", None)
 | |
|         scene = bpy.context.scene
 | |
|         scene.objects.link(empty)
 | |
|         bpy.ops.object.select_pattern(pattern=empty.name,extend=False)
 | |
|         bpy.ops.object.select_pattern(pattern=ob.name,extend=True)
 | |
|         bpy.ops.object.parent_no_inverse_set()
 | |
|         bpy.ops.object.select_pattern(pattern=empty.name,extend=False)
 | |
|         bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM')
 | |
|         bpy.ops.object.select_pattern(pattern=ob.name,extend=False)
 | |
|         bpy.ops.object.delete(use_global=False)
 | |
|         
 | |
|         scene.update()
 | |
|         
 | |
| class Emptyfy(bpy.types.Operator):
 | |
|     """Tooltip"""
 | |
|     bl_idname = "object.emptyfy"
 | |
|     bl_label = "Emptify"
 | |
| 
 | |
|     @classmethod
 | |
|     def poll(cls, context):
 | |
|         return context.active_object is not None
 | |
| 
 | |
|     def execute(self, context):
 | |
|         main(context)
 | |
|         return {'FINISHED'}
 | |
| 
 | |
| 
 | |
| def register():
 | |
|     bpy.utils.register_class(Emptyfy)
 | |
| 
 | |
| 
 | |
| def unregister():
 | |
|     bpy.utils.unregister_class(Emptyfy)
 | |
| 
 | |
| 
 | |
| if __name__ == "__main__":
 | |
|     register()
 | |
| 
 | |
|     # test call
 | |
|     #bpy.ops.object.emptyfy()
 |