~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to release/scripts/startup/bl_operators/object_align.py

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
114
114
    return Vector((left, front, up)), Vector((right, back, down))
115
115
 
116
116
 
117
 
def align_objects(align_x,
 
117
def align_objects(context,
 
118
                  align_x,
118
119
                  align_y,
119
120
                  align_z,
120
121
                  align_mode,
121
122
                  relative_to,
122
123
                  bb_quality):
123
124
 
124
 
    cursor = bpy.context.scene.cursor_location
 
125
    cursor = context.scene.cursor_location
125
126
 
126
127
    Left_Front_Up_SEL = [0.0, 0.0, 0.0]
127
128
    Right_Back_Down_SEL = [0.0, 0.0, 0.0]
128
129
 
129
130
    flag_first = True
130
131
 
131
 
    objs = []
 
132
    objects = []
132
133
 
133
 
    for obj in bpy.context.selected_objects:
 
134
    for obj in context.selected_objects:
134
135
        matrix_world = obj.matrix_world.copy()
135
136
        bb_world = [matrix_world * Vector(v[:]) for v in obj.bound_box]
136
 
        objs.append((obj, bb_world))
 
137
        objects.append((obj, bb_world))
137
138
 
138
 
    if not objs:
 
139
    if not objects:
139
140
        return False
140
141
 
141
 
    for obj, bb_world in objs:
 
142
    for obj, bb_world in objects:
142
143
 
143
144
        if bb_quality and obj.type == 'MESH':
144
145
            GBB = GlobalBB_HQ(obj)
150
151
 
151
152
        # Active Center
152
153
 
153
 
        if obj == bpy.context.active_object:
 
154
        if obj == context.active_object:
154
155
 
155
156
            center_active_x = (Left_Front_Up[0] + Right_Back_Down[0]) / 2.0
156
157
            center_active_y = (Left_Front_Up[1] + Right_Back_Down[1]) / 2.0
200
201
 
201
202
    # Main Loop
202
203
 
203
 
    for obj, bb_world in objs:
 
204
    for obj, bb_world in objects:
204
205
        matrix_world = obj.matrix_world.copy()
205
206
        bb_world = [matrix_world * Vector(v[:]) for v in obj.bound_box]
206
207
 
341
342
 
342
343
 
343
344
class AlignObjects(Operator):
344
 
    '''Align Objects'''
 
345
    """Align Objects"""
345
346
    bl_idname = "object.align"
346
347
    bl_label = "Align Objects"
347
348
    bl_options = {'REGISTER', 'UNDO'}
386
387
 
387
388
    def execute(self, context):
388
389
        align_axis = self.align_axis
389
 
        ret = align_objects('X' in align_axis,
 
390
        ret = align_objects(context,
 
391
                            'X' in align_axis,
390
392
                            'Y' in align_axis,
391
393
                            'Z' in align_axis,
392
394
                            self.align_mode,