Page MenuHome

Scripting - crash with bpy.ops.view3d.viewnumpad
Closed, InvalidPublic

Description

System Information
Operating system and graphics card

Windows 7 64 Bit
Nvidia 760 GTX

Blender Version
Broken: (example: 2.69.7 4b206af, see splash screen)
Worked: (optional)

Worked in 2.76b, has quit working in 2.77

Short description of error

Script with bpy.ops.view3d.viewnumpad to switch the views crashes with mesh in edit mode. It works fine in all other modes.

Exact steps for others to reproduce the error
Based on a (as simple as possible) attached .blend file with minimum amount of steps

Load the attached blend file. In the User Preferences tick Rotate around selection. Run the included script. This will create a row of navigation buttons in the Info editor. Enter Edit Mode. Now click at one of the navigation buttons. Blender will crash.

This script works fine in Blender 2.76b. But in 2.77 this crash appears when in Edit mode and with Rotate around selection ticked.

Running an up to date Blender 2.78b in VS with debugging stops at the math_matrix.c script behind the void copy_m4m4 class.

Attached is also a short video that shows the crash.






Details

Type
Bug

Event Timeline

Brendon Murphy (meta-androcto) triaged this task as Needs Information from User priority.Feb 21 2017, 10:21 AM
Brendon Murphy (meta-androcto) edited projects, added Addons; removed BF Blender.

hi, I have no fail or crash here using nightly build.
I open your file, run the script, turn on drivers... then can use as expected.
why does this addon/blend file need the auto run drivers check?

In fact, closing this as invalid as there's no bug or crash I found.
Feel free to re-open with more substance.

Hi Brendon,

Thanks for checking. Just to be sure, have you turned on rotate around selection in the user preferences and tested the addon in edit mode?

And what do you mean with turn on drivers?

Reiner,
auto run scripts may have popped up as i only tested your .blend & ran the script within from the text editor. but it seems to appear immediately when I open the file.
& yes thanks for clarify, indeed this is instant crash.
I had not turned on rotate around selection in the user preferences & it worked fine.
Turning on rotate around selection in the user preferences is instant crash with this script.

Brendon Murphy (meta-androcto) raised the priority of this task from Needs Information from User to Confirmed, Medium.Feb 21 2017, 12:34 PM

Ah, so i am glad that i asked again. Thanks for confirming :)

Julian Eisel (Severin) closed this task as Invalid.Feb 23 2017, 2:18 AM

You're not overwriting context correctly. The view3d.viewnumpad operator may depend on data from the context region, which isn't the correct one if executed from a non-3D-View area (and if not overridden correctly).
This should work:

def execute(self, context): 
        for area in bpy.context.screen.areas:
            if area.type == 'VIEW_3D':
                for region in area.regions:
                    if region.type == 'WINDOW':
                        override = bpy.context.copy()
                        override['area'] = area
                        override['region'] = region
                        bpy.ops.view3d.viewnumpad(override, type='TOP', align_active=False)
        return {'FINISHED'}

This is not a Blender bug but one caused by wrong usage of BPY, thus closing as invalid.

Yes, that fixed the problem. Many thanks :)