Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrendon Murphy <meta.androcto1@gmail.com>2015-05-01 05:52:03 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2015-05-01 05:52:03 +0300
commit40c00d312f0cc54485f93e47763eb9cd9b413fee (patch)
tree6043d6cf956cc8e737a07c49f0891acf94a87a42 /add_mesh_extra_objects/add_empty_as_parent.py
parent3b6028fd8b895dcc42b23e481fd8d99c10553acd (diff)
add_extra_mesh_objects: new version
Tracker: https://developer.blender.org/T44561 New UI, New Addons, Better organization & removal of 'Lesser Object Types' Merged & removed "lesser" & 'larger" add mesh scripts. Menu updates & re-organization & modernize. New: Add Vert, Round Cube, Menger Cube, Brilliant Diamond, Parent to Empty Removed: Add Mesh: Sqorus, Trapezohedron, Wedge, Polysphere. Merged add_mesh_symmetrical_empty from contrib Documentation: http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Add_Mesh/Add_Mesh_Extra_Objects
Diffstat (limited to 'add_mesh_extra_objects/add_empty_as_parent.py')
-rw-r--r--add_mesh_extra_objects/add_empty_as_parent.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/add_mesh_extra_objects/add_empty_as_parent.py b/add_mesh_extra_objects/add_empty_as_parent.py
new file mode 100644
index 00000000..86280554
--- /dev/null
+++ b/add_mesh_extra_objects/add_empty_as_parent.py
@@ -0,0 +1,57 @@
+# GPL # Original Author Liero #
+
+import bpy
+from bpy.props import StringProperty, FloatProperty, BoolProperty, FloatVectorProperty
+
+def centro(objetos):
+ x = sum([obj.location[0] for obj in objetos])/len(objetos)
+ y = sum([obj.location[1] for obj in objetos])/len(objetos)
+ z = sum([obj.location[2] for obj in objetos])/len(objetos)
+ return (x,y,z)
+
+class P2E(bpy.types.Operator):
+ bl_idname = 'object.parent_to_empty'
+ bl_label = 'Parent Selected to Empty'
+ bl_description = 'Parent selected objects to a new Empty'
+ bl_options = {'REGISTER', 'UNDO'}
+
+ nombre = StringProperty(name='', default='OBJECTS', description='Give the empty / group a name')
+ grupo = bpy.props.BoolProperty(name='Create Group', default=False, description='Also link objects to a new group')
+ cursor = bpy.props.BoolProperty(name='Cursor Location', default=False, description='Add the empty at cursor / selection center')
+ renombrar = bpy.props.BoolProperty(name='Rename Objects', default=False, description='Rename child objects')
+
+ @classmethod
+ def poll(cls, context):
+ return (context.object and context.object.select)
+
+ def draw(self, context):
+ layout = self.layout
+ layout.prop(self,'nombre')
+ column = layout.column(align=True)
+ column.prop(self,'grupo')
+ column.prop(self,'cursor')
+ column.prop(self,'renombrar')
+
+ def execute(self, context):
+ objs = bpy.context.selected_objects
+ bpy.ops.object.mode_set()
+ if self.cursor:
+ loc = context.scene.cursor_location
+ else:
+ loc = centro(objs)
+ bpy.ops.object.add(type='EMPTY',location=loc)
+ bpy.context.object.name = self.nombre
+ if self.grupo:
+ bpy.ops.group.create(name=self.nombre)
+ bpy.ops.group.objects_add_active()
+ for o in objs:
+ o.select = True
+ if not o.parent:
+ bpy.ops.object.parent_set(type='OBJECT')
+ if self.grupo:
+ bpy.ops.group.objects_add_active()
+ o.select = False
+ for o in objs:
+ if self.renombrar:
+ o.name = self.nombre+'_'+o.name
+ return {'FINISHED'} \ No newline at end of file