Skip to content
Snippets Groups Projects
Commit c0e45f9e authored by Martin Buerbaum's avatar Martin Buerbaum
Browse files

* 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.
parent a75327ab
Branches
Tags
No related merge requests found
......@@ -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 @@ bl_addon_info = {
'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()
......@@ -431,7 +431,9 @@ def import_object(obname):
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,
......@@ -442,15 +444,15 @@ def import_object(obname):
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 @@ class ImportRecorder(bpy.types.Operator):
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 @@ class ImportBomb(bpy.types.Operator):
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'}
......
......@@ -61,9 +61,9 @@ def setupshards(context):
#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 @@ class SetupShards(bpy.types.Operator):
def execute(self, context):
setupshards(context)
return {'FINISHED'}
#bpy.types.register(SetupShards)
#if __name__ == "__main__":
# bpy.ops.object.fracture_setup_shards()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment