Page MenuHome

Problem with bpy.ops.object.material_slot_assign () when running a script from the console
Closed, ResolvedPublic


System Information
Operating system: Linux-5.2.18-129.current-x86_64-with-glibc2.9 64 Bits
Graphics card: GeForce GTX 660/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 430.50

Blender Version
Broken: version: 2.80 (sub 75), branch: master, commit date: 2019-07-29 14:47, hash: rBf6cb5f54494e
Worked: (optional)

Short description of error
For automation I created a script from a sequence of actions which works great if I run it in the blender console window, or if i Run Script in a text editor.
But when I run this script through the command line without the graphical shell of the blender - he crashed.
If I exclude bpy.ops.object.material_slot_assign (), the script succeeds, except that the materials are not used.
Problem is repeated regardless of the platform, Windows or Linux, regardless of the PC used (3 different PCs).

Exact steps for others to reproduce the error
./blender -b -P /home/convert/script.txt

The error is reproduced even in the simplest example

import bpy
bpy.context.object.active_material_index = 0

In a full script, everything is executed until it reaches the line bpy.ops.object.material_slot_assign ()
Without this line, the script completes successfully and the result is saved.

And it does not depend on the assigned material.
I also attach an automatically generated file when the blender falls:



Event Timeline

Bastien Montagne (mont29) lowered the priority of this task from Needs Triage by Developer to Confirmed, Medium.

That operator is not designed to work without UI at all, it expects a valid 3DView from the context.

Will tweak the poll function of those ops to properly abort when this is not available, instead of crashing…

Hrmmm, actually it’s a bit more involved, not sure why we need view3d here, still digging.

Bastien Montagne (mont29) closed this task as Resolved.Fri, Oct 11, 8:44 PM

Grmlll, broken auto-close with fixes in release branch it'd seem… Fixed by rB1c2a20c84d46d30b.

Thank you guys, you are the best and thank you for making the best program.