Page MenuHome

Tools cannot be registered into some contexts (e.g. PAINT_TEXTURE).
Closed, ResolvedPublicBUG

Description

System Information
Operating system: Windows-10-10.0.17134 64 Bits
Graphics card: Intel(R) HD Graphics 620 Intel 4.5.0 - Build 24.20.100.6136

Blender Version
Broken: version: 2.80 (sub 59), branch: blender2.7, commit date: 2019-04-24 22:25, hash: rBd966c2f0c2ad

Short description of error
When trying to create an active tool in texture painting mode, a error message appears and the tool can't be registered.

Exact steps for others to reproduce the error

  • Load the script template for a UI tool simple
  • Remove the information for the second tool
  • Change the bl_context_mode to "PAINT_TEXTURE"
  • Run script: Name error: name "context" is not defined

Here's the script which is described above:

Event Timeline

Sebastian Parborg (zeddb) lowered the priority of this task from 90 to 50.

You're trying to use circle select tool in Texture Paint mode. That tool doesn't exist in the texture paint context.

You're trying to use circle select tool in Texture Paint mode. That tool doesn't exist in the texture paint context.

You're right, that could have caused the error, but I removed everything that has to do with the circle select and it still only runs in all the different edit modes and object mode. Sculpting and painting for example are not working.
Hopefully I missed something, it'd be great if you could check out this script:

Philipp Oeser (lichtwerk) changed the subtype of this task from "Report" to "Bug".

Reconfirmed.

This fails because some tool contexts define their tools with functions [see the following list for context that fail]:

  • PARTICLE (_defs_particle.generate_from_brushes)
  • SCULPT (_defs_sculpt.generate_from_brushes)
  • PAINT_TEXTURE (_defs_texture_paint.generate_from_brushes)
  • PAINT_VERTEX (_defs_vertex_paint.generate_from_brushes)
  • PAINT_WEIGHT (_defs_weight_paint.generate_from_brushes)
  • PAINT_GPENCIL (_defs_gpencil_paint.generate_from_brushes)
  • SCULPT_GPENCIL (_defs_gpencil_sculpt.generate_from_brushes)
  • WEIGHT_GPENCIL (_defs_gpencil_weight.generate_from_brushes)

ToolSelectPanelHelper._tools_flatten() is usually called with cls.tools_from_context(context) [that already yields from the function]
But when registering a tool, _tools_flatten() will still give back this function not a ToolDef - and we cannot get a bl_idname from that:

Traceback (most recent call last):
  File "/Text", line 30, in <module>
  File "/Text", line 24, in register
  File "/build_linux/bin/2.83/scripts/modules/bpy/utils/__init__.py", line 798, in register_tool
    item.idname for item in ToolSelectPanelHelper._tools_flatten(tools)
  File "/build_linux/bin/2.83/scripts/modules/bpy/utils/__init__.py", line 799, in <setcomp>
    if item is not None
AttributeError: 'function' object has no attribute 'idname'
Error: Python script failed, check the message in the system console
Philipp Oeser (lichtwerk) renamed this task from Active tool in texture paint mode can't be registered to Tools cannot be registered into some contexts (e.g. PAINT_TEXTURE)..Feb 6 2020, 2:10 PM