Regression: Grease Pencil materials added via Python do not show up in "Change Active Material" Menu #102566

Closed
opened 2022-11-17 01:01:43 +01:00 by Matthew Gafford · 10 comments

System Information
Operating system: Windows 10
Graphics card: RTX 3070 FE

Blender Version
Broken: 3.3.1
Worked: 2.93

Caused by e3faef686d

Short description of error
Any new materials that have been added to the Grease Pencil object using the materials.append() method will not show in the GP Change Active Material menu (default U key), unless you open the Material Properties menu and scroll down to let them populate there first.
Video explanation:
grease-pencil-materials-added-via-python-do-not.mp4

Exact steps for others to reproduce the error

  1. Open .blend file below
  2. Run the included script in the Text Editor (This will create my character's GP object, and then add the layers and many materials to it)
  3. Go into Draw Mode on the new GP object
  4. Press the U key to change the material. You will only see the first material that was added.
  5. Change to the Material Properties tab on the right, and scroll to the rest of the materials that haven't been seen yet. As more materials populate there, they will then be available when pressing the U key in Draw Mode.

PythonAddedGPMaterialsNotInMaterialSwitcher.blend

**System Information** Operating system: Windows 10 Graphics card: RTX 3070 FE **Blender Version** Broken: 3.3.1 Worked: 2.93 Caused by e3faef686d **Short description of error** Any new materials that have been added to the Grease Pencil object using the `materials.append()` method will not show in the GP Change Active Material menu (default U key), unless you open the Material Properties menu and scroll down to let them populate there first. Video explanation: [grease-pencil-materials-added-via-python-do-not.mp4](https://archive.blender.org/developer/F13937536/grease-pencil-materials-added-via-python-do-not.mp4) **Exact steps for others to reproduce the error** 1. Open .blend file below 2. Run the included script in the Text Editor (This will create my character's GP object, and then add the layers and many materials to it) 3. Go into Draw Mode on the new GP object 4. Press the U key to change the material. You will only see the first material that was added. 5. Change to the Material Properties tab on the right, and scroll to the rest of the materials that haven't been seen yet. As more materials populate there, they will then be available when pressing the U key in Draw Mode. [PythonAddedGPMaterialsNotInMaterialSwitcher.blend](https://archive.blender.org/developer/F13931576/PythonAddedGPMaterialsNotInMaterialSwitcher.blend)

Added subscriber: @AFoxInSpace

Added subscriber: @AFoxInSpace

Added subscriber: @mano-wii

Added subscriber: @mano-wii

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'

Thanks for the report, I can confirm the issue.
The sample file could still be simplified further. Could you find a way to nail it down to a few lines of code?

Thanks for the report, I can confirm the issue. The sample file could still be simplified further. Could you find a way to nail it down to a few lines of code?

PythonAddedGPMaterialsNotInMaterialSwitcherTRIMMED.blend

Now the code just creates the object and 4 materials.

[PythonAddedGPMaterialsNotInMaterialSwitcherTRIMMED.blend](https://archive.blender.org/developer/F13938680/PythonAddedGPMaterialsNotInMaterialSwitcherTRIMMED.blend) Now the code just creates the object and 4 materials.
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Philipp Oeser self-assigned this 2022-11-18 10:19:17 +01:00
Member

Problem is that the material does not have its preview icon generated (yet).

You could either do it in your script (material.id_data.preview_ensure()), but I will propose a more general solution (ensuring the icon previews in the UI code -- similar to 182edd4c35)

Problem is that the material does not have its preview icon generated (yet). You could either do it in your script (`material.id_data.preview_ensure()`), but I will propose a more general solution (ensuring the icon previews in the UI code -- similar to 182edd4c35)

This issue was referenced by 4d58a1c657

This issue was referenced by 4d58a1c657db7acc585d1782d66ff983ef5ce90a

This issue was referenced by 3e81d177ea

This issue was referenced by 3e81d177ea08b4c3cb44fac0cf9e9a252b36b52c
Philipp Oeser changed title from Grease Pencil materials added via Python do not show up in "Change Active Material" Menu to Regression: Grease Pencil materials added via Python do not show up in "Change Active Material" Menu 2022-11-18 10:41:07 +01:00
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#102566
No description provided.