addons-contrib CreaPrim: partial 2.80 update
authorNBurn <7nburn@gmail.com>
Sat, 2 Feb 2019 23:31:30 +0000 (18:31 -0500)
committerNBurn <7nburn@gmail.com>
Sat, 2 Feb 2019 23:31:30 +0000 (18:31 -0500)
object_creaprim.py

index dee641e..53a1024 100644 (file)
@@ -92,7 +92,7 @@ class CreaPrim(bpy.types.Operator):
 
         objlist = []
         for selobj in bpy.context.scene.objects:
-            if selobj.select and test_data(selobj) is True:
+            if selobj.select_get() and test_data(selobj) is True:
                 objlist.append(selobj)
 
         if len(objlist) == 0:
@@ -194,8 +194,15 @@ def panel_func(self, context):
     self.layout.prop(scn, "Creaprim_Apply")
 
 
+classes = (
+    CreaPrim,
+    MessageOperator)
+
+
 def register():
-    bpy.utils.register_module(__name__)
+    for cls in classes:
+        bpy.utils.register_class(cls)
+    #bpy.utils.register_module(__name__)
     bpy.types.Scene.Creaprim_Name = bpy.props.StringProperty(
             name="Name",
             description="Name for the primitive",
@@ -206,14 +213,20 @@ def register():
             description="Apply transform to selected objects",
             default=False
             )
-    bpy.types.VIEW3D_PT_tools_object.append(panel_func)
-    bpy.app.handlers.scene_update_post.append(setname)
+    #bpy.types.VIEW3D_PT_tools_object.append(panel_func)
+    bpy.types.VIEW3D_PT_overlay_object.append(panel_func)
+    #bpy.app.handlers.scene_update_post.append(setname)
+    bpy.app.handlers.depsgraph_update_post.append(setname)
 
 
 def unregister():
-    bpy.utils.unregister_module(__name__)
-    bpy.types.VIEW3D_PT_tools_object.remove(panel_func)
-    bpy.app.handlers.scene_update_post.remove(setname)
+    #bpy.utils.unregister_module(__name__)
+    for cls in reversed(classes):
+        bpy.utils.unregister_class(cls)
+    #bpy.types.VIEW3D_PT_tools_object.remove(panel_func)
+    bpy.types.VIEW3D_PT_overlay_object.remove(panel_func)
+    #bpy.app.handlers.scene_update_post.remove(setname)
+    bpy.app.handlers.depsgraph_update_post.remove(setname)
     del bpy.types.Scene.Creaprim_Name
     del bpy.types.Scene.Creaprim_Apply