[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [563] trunk/py/scripts/addons/fracture: * Added new Submenu "Fracture Objects" (Bomb, Recorder, Projectile) in the "Add" menu.
Martin Buerbaum
martin.buerbaum at gmx.at
Tue Apr 13 14:57:44 CEST 2010
Revision: 563
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=563
Author: pontiac
Date: 2010-04-13 14:57:44 +0200 (Tue, 13 Apr 2010)
Log Message:
-----------
* Added new Submenu "Fracture Objects" (Bomb, Recorder, Projectile) in the "Add" menu.
* Fixed usage of "relative_path" in bpy.ops.wm.link_append()
* Added "fracture" name to all operators somewhere.
Modified Paths:
--------------
trunk/py/scripts/addons/fracture/__init__.py
trunk/py/scripts/addons/fracture/fracture_ops.py
trunk/py/scripts/addons/fracture/fracture_setup.py
Modified: trunk/py/scripts/addons/fracture/__init__.py
===================================================================
--- trunk/py/scripts/addons/fracture/__init__.py 2010-04-13 12:01:21 UTC (rev 562)
+++ trunk/py/scripts/addons/fracture/__init__.py 2010-04-13 12:57:44 UTC (rev 563)
@@ -17,7 +17,7 @@
# ##### END GPL LICENSE BLOCK #####
bl_addon_info = {
- 'name': 'Object: Fracture tools',
+ 'name': 'Object: Fracture Tools',
'author': 'pildanovak',
'version': '2.0',
'blender': (2, 5, 3),
@@ -27,26 +27,54 @@
'category': 'Object'}
import bpy
+from fracture import fracture_ops, fracture_setup
+class INFO_MT_add_fracture_objects(bpy.types.Menu):
+ bl_idname = "INFO_MT_add_fracture_objects"
+ bl_label = "Fracture Objects"
+
+ def draw(self, context):
+ layout = self.layout
+ layout.operator_context = 'INVOKE_REGION_WIN'
+
+ layout.operator("object.import_fracture_bomb",
+ text="Bomb")
+ layout.operator("object.import_fracture_projectile",
+ text="Projectile")
+ layout.operator("object.import_fracture_recorder",
+ text="Rigidbody Recorder")
+
+import space_info
+# Define the submenu
+menu_func = (lambda self,
+ context: self.layout.menu("INFO_MT_add_fracture_objects", icon="PLUGIN"))
+
+
def register():
- from fracture import fracture_ops, fracture_setup
bpy.types.register(fracture_ops.FractureSimple)
bpy.types.register(fracture_ops.FractureGroup)
- bpy.types.register(fracture_ops.ImportRecorder)
- bpy.types.register(fracture_ops.ImportBomb)
- bpy.types.register(fracture_ops.ImportProjectile)
- bpy.types.register(fracture_setup.SetupShards)
+ bpy.types.register(fracture_ops.ImportFractureRecorder)
+ bpy.types.register(fracture_ops.ImportFractureBomb)
+ bpy.types.register(fracture_ops.ImportFractureProjectile)
+ bpy.types.register(fracture_setup.SetupFractureShards)
+ bpy.types.register(INFO_MT_add_fracture_objects)
+ # Add the "add fracture objects" menu to the "Add" menu
+ space_info.INFO_MT_add.append(menu_func)
+
def unregister():
- from fracture import fracture_ops, fracture_setup
bpy.types.unregister(fracture_ops.FractureSimple)
bpy.types.unregister(fracture_ops.FractureGroup)
- bpy.types.unregister(fracture_ops.ImportRecorder)
- bpy.types.unregister(fracture_ops.ImportBomb)
- bpy.types.unregister(fracture_ops.ImportProjectile)
- bpy.types.unregister(fracture_setup.SetupShards)
+ bpy.types.unregister(fracture_ops.ImportFractureRecorder)
+ bpy.types.unregister(fracture_ops.ImportFractureBomb)
+ bpy.types.unregister(fracture_ops.ImportFractureProjectile)
+ bpy.types.unregister(fracture_setup.SetupFractureShards)
+ bpy.types.unregister(INFO_MT_add_fracture_objects)
+ # Remove "add fracture objects" menu from the "Add" menu.
+ space_info.INFO_MT_add.remove(menu_func)
+
if __name__ == "__main__":
register()
Modified: trunk/py/scripts/addons/fracture/fracture_ops.py
===================================================================
--- trunk/py/scripts/addons/fracture/fracture_ops.py 2010-04-13 12:01:21 UTC (rev 562)
+++ trunk/py/scripts/addons/fracture/fracture_ops.py 2010-04-13 12:57:44 UTC (rev 563)
@@ -431,8 +431,10 @@
s = os.sep
dpath = bpy.utils.script_paths()[0] + \
'%saddons%sfracture%sdata.blend\\Object\\' % (s, s, s)
- print(opath)
+ # DEBUG
+ #print('import_object: ' + opath)
+
bpy.ops.wm.link_append(
path=opath,
filename=obname,
@@ -442,15 +444,15 @@
autoselect=True,
active_layer=True,
instance_groups=True,
- relative_paths=True)
+ relative_path=True)
for ob in bpy.context.selected_objects:
ob.location = bpy.context.scene.cursor_location
-class ImportRecorder(bpy.types.Operator):
+class ImportFractureRecorder(bpy.types.Operator):
'''Imports a rigidbody recorder'''
- bl_idname = "object.import_recorder"
+ bl_idname = "object.import_fracture_recorder"
bl_label = "Add Rigidbody Recorder (Fracture)"
bl_options = {'REGISTER', 'UNDO'}
@@ -460,9 +462,9 @@
return {'FINISHED'}
-class ImportBomb(bpy.types.Operator):
+class ImportFractureBomb(bpy.types.Operator):
'''Import a bomb'''
- bl_idname = "object.import_bomb"
+ bl_idname = "object.import_fracture_bomb"
bl_label = "Add Bomb (Fracture)"
bl_options = {'REGISTER', 'UNDO'}
@@ -472,9 +474,9 @@
return {'FINISHED'}
-class ImportProjectile(bpy.types.Operator, ):
+class ImportFractureProjectile(bpy.types.Operator, ):
'''Imports a projectile'''
- bl_idname = "object.import_projectile"
+ bl_idname = "object.import_fracture_projectile"
bl_label = "Add Projectile (Fracture)"
bl_options = {'REGISTER', 'UNDO'}
Modified: trunk/py/scripts/addons/fracture/fracture_setup.py
===================================================================
--- trunk/py/scripts/addons/fracture/fracture_setup.py 2010-04-13 12:01:21 UTC (rev 562)
+++ trunk/py/scripts/addons/fracture/fracture_setup.py 2010-04-13 12:57:44 UTC (rev 563)
@@ -61,9 +61,9 @@
#print(ob)
-class SetupShards(bpy.types.Operator):
+class SetupFractureShards(bpy.types.Operator):
''''''
- bl_idname = "object.fracture_setup_shards"
+ bl_idname = "object.setup_fracture_shards"
bl_label = "Setup Fracture Shards"
bl_options = {'REGISTER', 'UNDO'}
@@ -72,8 +72,3 @@
def execute(self, context):
setupshards(context)
return {'FINISHED'}
-
-#bpy.types.register(SetupShards)
-
-#if __name__ == "__main__":
-# bpy.ops.object.fracture_setup_shards()
More information about the Bf-extensions-cvs
mailing list