1
$\begingroup$

G'day,

I'm using Blender 2.78 64 bit in Windows 7. I'm trying to use the Scripting Screen layout to run, debug and edit python scripts.

When I press the Run Script button in Blender, the screen layout reverts to the default layout which closes the Scripting Window and the Python Interactive Console. Then to rerun the script I need to reopen the Scripting layout and import the python code back into the Scripting window (very frustrating).

Is there any way to stop Blender from reverting back to the default layout when python scripts are run?

Or, is there a way to make the Scripting screen layout the default layout?

I have seen some suggestions about including input() or raw_input() at the end of the code to prevent the python console from closing. This solution has not worked, raw_input() causes Blender to hang (python console is 3.5.2). Surely there must be a better solution than using raw_input() to pause completion of the script in any case.

Any suggestions would be greatly appreciated.

Thanks.

$\endgroup$
  • $\begingroup$ Does it do this for other Python scripts or just that one? $\endgroup$ – VSB Jul 3 '17 at 13:55
  • 3
    $\begingroup$ The described behaviour suggests you are switching context within the script, meaning the current view (like TextEditor, ) gets switched to a 3d view because you have a line like bpy.context.area.type = 'VIEW_3D'. -- at the end you could switch back to TEXT_EDITOR. $\endgroup$ – zeffii Jul 3 '17 at 18:14
  • 1
    $\begingroup$ Try minimising your script to the least amount of code that still shows this issue. Then share that with us. $\endgroup$ – dr. Sybren Jul 3 '17 at 18:24
1
$\begingroup$

Thanks very much for the responses. Zeffii is correct, I had used the following code to delete all objects, but it was also resetting the view. Removing the below code resolves the issue. Thanks again.

def reset_blend():
    bpy.ops.wm.read_factory_settings()

    for scene in bpy.data.scenes:
        for obj in scene.objects:
            scene.objects.unlink(obj)

    for bpy_data_iter in (
            bpy.data.objects,
            bpy.data.meshes,
            bpy.data.lamps,
            bpy.data.cameras,
            ):
        for id_data in bpy_data_iter:
            bpy_data_iter.remove(id_data)

reset_blend()
$\endgroup$
  • 1
    $\begingroup$ that's not the solution I would go for, but whatever works for you is OK. $\endgroup$ – zeffii Jul 4 '17 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.