Skip to content

Instantly share code, notes, and snippets.

@sambler
Created July 7, 2016 07:10
Show Gist options
  • Save sambler/47a505c1029f7926753e8ce50ff752b2 to your computer and use it in GitHub Desktop.
Save sambler/47a505c1029f7926753e8ce50ff752b2 to your computer and use it in GitHub Desktop.
Sample test addon to show using unregister() to remove changes by the addon
bl_info = {"version": (1, 0), "blender": (2, 75, 0), "author": "myname",
"name": "testing addon", "location": "blender", "description": "test a new addon" ,
"warning": "only for testing", "category": "test", }
import bpy
# add your operators, panels .....
def register() :
bpy.types.scene.my_int_storage = bpy.props.IntProperty()
bpy.utils.register_class(myOperator)
bpy.types.VIEW3D_MT_object.append(add_my_menu_item)
def unregister() :
# remove all changes made in register()
bpy.types.VIEW3D_MT_object.remove(add_my_menu_item)
bpy.utils.unregister_class(myOperator)
del bpy.types.scene.my_int_storage
if __name__ == "__main__":
try:
# by running unregister here we can run this script
# in blenders text editor
# the first time we run this script inside blender
# we get an error that removing the changes fails
unregister()
except:
pass
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment