PLyczkowski / rRMB

Right button menu for Blender.
8 stars 3 forks source link

Runtime error happened during 'Align Orientation To Selecton' operation #44

Open newillusion opened 7 years ago

newillusion commented 7 years ago

Traceback (most recent call last): File "C:\Users\RvvMx2\AppData\Roaming\Blender Foundation\Blender\2.78\scripts\addons\rRMB.py", line 1240, in execute bpy.ops.object.select_all(action='DESELECT') File "C:\Program Files\Blender Foundation\Blender-78\2.78\scripts\modules\bpy\ops.py", line 189, in call ret = op_call(self.idname_py(), None, kw) RuntimeError: Operator bpy.ops.object.select_all.poll() failed, context is incorrect

location: :-1

bpy.ops.transform.rotate(value=0, axis=(-0.130106, -0.982962, 0.129837), constraint_axis=(False, False, False), constraint_orientation='rOrientation', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1, release_confirm=True)


PLyczkowski commented 7 years ago

Sorry about that. Check if you tried to run it on an object that has mesh data shared by multiple users (linked duplicate).

newillusion commented 7 years ago

Hm... Excuse me, i call operation "Align Orientation To Selecton" not from rRMB menu, but from spacekey-called menu in object mode (not in edit mode). I can't found another way to call it for objects. My mistake happend becouse i think what such operation is more usefull in object mode - align orientation (without visual rotation) for several selected object by active object.

If You solve, what it is possible to extend "Align Orientation To Selecton" operation for object mode too, there is text for that (what i use after error in rRMB happened):


        source = bpy.context.active_object
        objects = bpy.context.selected_objects
        mat_source = source.rotation_euler.to_matrix()
        mat_source.invert()

        for ob in objects:
            if ob != source:
                mat_ob = ob.rotation_euler.to_matrix()
                if ob.type == 'MESH':
                    mat = mat_source * mat_ob

                    for v in ob.data.vertices:
                        vec = mat * v.co
                        v.co = vec

                    ob.rotation_euler = source.rotation_euler