1
# AlingTools.py (c) 2009, 2010 Gabriel Beaudin (gabhead)
3
# ***** BEGIN GPL LICENSE BLOCK *****
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU General Public License
8
# as published by the Free Software Foundation; either version 2
9
# of the License, or (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software Foundation,
18
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
# ***** END GPL LICENCE BLOCK *****
23
"name": "Simple Align",
24
"author": "Gabriel Beaudin (gabhead)",
27
"location": "View3D > Tool Shelf > Simple Align Panel",
28
"description": "Align Selected Objects to Active Object",
30
"wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"\
31
"Scripts/3D interaction/Align_Tools",
32
"tracker_url": "https://projects.blender.org/tracker/index.php?"\
33
"func=detail&aid==22389",
34
"category": "3D View"}
36
"""Align Selected Objects"""
41
class AlignUi(bpy.types.Panel):
42
bl_space_type = 'VIEW_3D'
43
bl_region_type = 'TOOLS'
45
bl_label = "Simple Align"
46
bl_context = "objectmode"
48
def draw(self, context):
54
row.label(text="Active object is: ", icon='OBJECT_DATA')
56
row.label(obj.name, icon='EDITMODE_HLT')
61
col.label(text="Align Loc + Rot:", icon='MANIPUL')
64
col = layout.column(align=False)
65
col.operator("object.align",text="XYZ")
68
col.label(text="Align Location:", icon='MAN_TRANS')
70
col = layout.column_flow(columns=5,align=True)
71
col.operator("object.align_location_x",text="X")
72
col.operator("object.align_location_y",text="Y")
73
col.operator("object.align_location_z",text="Z")
74
col.operator("object.align_location_all",text="All")
77
col.label(text="Align Rotation:", icon='MAN_ROT')
79
col = layout.column_flow(columns=5,align=True)
80
col.operator("object.align_rotation_x",text="X")
81
col.operator("object.align_rotation_y",text="Y")
82
col.operator("object.align_rotation_z",text="Z")
83
col.operator("object.align_rotation_all",text="All")
86
col.label(text="Align Scale:", icon='MAN_SCALE')
88
col = layout.column_flow(columns=5,align=True)
89
col.operator("object.align_objects_scale_x",text="X")
90
col.operator("object.align_objects_scale_y",text="Y")
91
col.operator("object.align_objects_scale_z",text="Z")
92
col.operator("object.align_objects_scale_all",text="All")
97
for i in bpy.context.selected_objects:
98
i.location = bpy.context.active_object.location
99
i.rotation_euler = bpy.context.active_object.rotation_euler
104
for i in bpy.context.selected_objects:
105
i.location = bpy.context.active_object.location
108
for i in bpy.context.selected_objects:
109
i.location.x = bpy.context.active_object.location.x
112
for i in bpy.context.selected_objects:
113
i.location.y = bpy.context.active_object.location.y
116
for i in bpy.context.selected_objects:
117
i.location.z = bpy.context.active_object.location.z
121
for i in bpy.context.selected_objects:
122
i.rotation_euler = bpy.context.active_object.rotation_euler
125
for i in bpy.context.selected_objects:
126
i.rotation_euler.x = bpy.context.active_object.rotation_euler.x
129
for i in bpy.context.selected_objects:
130
i.rotation_euler.y = bpy.context.active_object.rotation_euler.y
133
for i in bpy.context.selected_objects:
134
i.rotation_euler.z = bpy.context.active_object.rotation_euler.z
136
def ScaleAll(context):
137
for i in bpy.context.selected_objects:
138
i.scale = bpy.context.active_object.scale
141
for i in bpy.context.selected_objects:
142
i.scale.x = bpy.context.active_object.scale.x
145
for i in bpy.context.selected_objects:
146
i.scale.y = bpy.context.active_object.scale.y
149
for i in bpy.context.selected_objects:
150
i.scale.z = bpy.context.active_object.scale.z
154
## Align All Rotation And Location
155
class AlignOperator(bpy.types.Operator):
157
bl_idname = "object.align"
158
bl_label = "Align Selected To Active"
161
def poll(cls, context):
162
return context.active_object != None
164
def execute(self, context):
168
#######################Align Location########################
170
class AlignLocationOperator(bpy.types.Operator):
172
bl_idname = "object.align_location_all"
173
bl_label = "Align Selected Location To Active"
176
def poll(cls, context):
177
return context.active_object != None
179
def execute(self, context):
183
class AlignLocationXOperator(bpy.types.Operator):
185
bl_idname = "object.align_location_x"
186
bl_label = "Align Selected Location X To Active"
189
def poll(cls, context):
190
return context.active_object != None
192
def execute(self, context):
196
class AlignLocationYOperator(bpy.types.Operator):
198
bl_idname = "object.align_location_y"
199
bl_label = "Align Selected Location Y To Active"
202
def poll(cls, context):
203
return context.active_object != None
205
def execute(self, context):
209
class AlignLocationZOperator(bpy.types.Operator):
211
bl_idname = "object.align_location_z"
212
bl_label = "Align Selected Location Z To Active"
215
def poll(cls, context):
216
return context.active_object != None
218
def execute(self, context):
222
#######################Align Rotation########################
224
class AlignRotationOperator(bpy.types.Operator):
226
bl_idname = "object.align_rotation_all"
227
bl_label = "Align Selected Rotation To Active"
230
def poll(cls, context):
231
return context.active_object != None
233
def execute(self, context):
237
class AlignRotationXOperator(bpy.types.Operator):
239
bl_idname = "object.align_rotation_x"
240
bl_label = "Align Selected Rotation X To Active"
243
def poll(cls, context):
244
return context.active_object != None
246
def execute(self, context):
250
class AlignRotationYOperator(bpy.types.Operator):
252
bl_idname = "object.align_rotation_y"
253
bl_label = "Align Selected Rotation Y To Active"
256
def poll(cls, context):
257
return context.active_object != None
259
def execute(self, context):
263
class AlignRotationZOperator(bpy.types.Operator):
265
bl_idname = "object.align_rotation_z"
266
bl_label = "Align Selected Rotation Z To Active"
269
def poll(cls, context):
270
return context.active_object != None
272
def execute(self, context):
275
#######################Align Scale########################
277
class AlignScaleOperator(bpy.types.Operator):
279
bl_idname = "object.align_objects_scale_all"
280
bl_label = "Align Selected Scale To Active"
283
def poll(cls, context):
284
return context.active_object != None
286
def execute(self, context):
290
class AlignScaleXOperator(bpy.types.Operator):
292
bl_idname = "object.align_objects_scale_x"
293
bl_label = "Align Selected Scale X To Active"
296
def poll(cls, context):
297
return context.active_object != None
299
def execute(self, context):
303
class AlignScaleYOperator(bpy.types.Operator):
305
bl_idname = "object.align_objects_scale_y"
306
bl_label = "Align Selected Scale Y To Active"
309
def poll(cls, context):
310
return context.active_object != None
312
def execute(self, context):
316
class AlignScaleZOperator(bpy.types.Operator):
318
bl_idname = "object.align_objects_scale_z"
319
bl_label = "Align Selected Scale Z To Active"
322
def poll(cls, context):
323
return context.active_object != None
325
def execute(self, context):
331
bpy.utils.register_module(__name__)
336
bpy.utils.unregister_module(__name__)
340
if __name__ == "__main__":