GPv3: Set selected curve material as active material #113569

Closed
opened 2023-10-12 06:10:04 +02:00 by Pratik Borhade · 3 comments
Member

Set material of selected stoke as active in UIList.

  • Define GREASE_PENCIL_OT_set_active_material operator in grease_pencil_edit.cc
  • Mention this operator in strokes panel: VIEW3D_MT_edit_greasepencil_stroke
  • Iterate through all the drawings at current scene frame (foreach_editable_drawing)
    • Get geometry of this drawing: bke::CurvesGeometry &curves = drawing.strokes_for_write();
    • Retrieve material attribute:
      bke::SpanAttributeWriter<int> materials = curves.attributes_for_write().lookup_or_add_for_write_span<int>("material_index", ATTR_DOMAIN_CURVE);
    • Get material of the first selected curve
    • Change active material in the material slots list using the material index of the curve
    • Exit drawing loop
  • Send notifiers to other editors: WM_event_add_notifier()
Set material of selected stoke as active in UIList. - Define `GREASE_PENCIL_OT_set_active_material` operator in `grease_pencil_edit.cc` - Mention this operator in strokes panel: `VIEW3D_MT_edit_greasepencil_stroke` - Iterate through all the drawings at current scene frame (`foreach_editable_drawing`) - Get geometry of this drawing: ` bke::CurvesGeometry &curves = drawing.strokes_for_write();` - Retrieve material attribute: `bke::SpanAttributeWriter<int> materials = curves.attributes_for_write().lookup_or_add_for_write_span<int>("material_index", ATTR_DOMAIN_CURVE);` - Get material of the first selected curve - Change active material in the material slots list using the material index of the curve - Exit drawing loop - Send notifiers to other editors: `WM_event_add_notifier()`
Pratik Borhade added the
Type
Report
Status
Needs Triage
Priority
Normal
labels 2023-10-12 06:10:04 +02:00
Pratik Borhade added this to the Grease Pencil project 2023-10-12 12:08:43 +02:00
Pratik Borhade added
Type
To Do
and removed
Status
Needs Triage
Type
Report
labels 2023-10-12 12:49:57 +02:00
Pratik Borhade added the
Module
Grease Pencil
label 2023-10-12 13:02:07 +02:00

@PratikPB2123 I don't think this is correct. In your text you are assigning the material to the curve and must be inverse. I will take this one.

@PratikPB2123 I don't think this is correct. In your text you are assigning the material to the curve and must be inverse. I will take this one.
Antonio Vazquez self-assigned this 2023-10-27 10:31:40 +02:00
Antonio Vazquez changed title from GPv3: Set active material to GPv3: Set selected material as active material 2023-10-27 10:34:43 +02:00
Antonio Vazquez changed title from GPv3: Set selected material as active material to GPv3: Set selected curve material as active material 2023-10-27 10:35:00 +02:00
Author
Member

@antoniov hi, not sure if I understand this completely but in task description I wrote object->actcol = materials.span[curve_index] which is same your change in PR

Anyways, thanks for the PR 🙂

@antoniov hi, not sure if I understand this completely but in task description I wrote `object->actcol = materials.span[curve_index]` which is same your change in PR Anyways, thanks for the PR 🙂
Author
Member
a8cb0b0ca09959ef4228300d45a3d88a87f4d08c
Pratik Borhade added the
Status
Resolved
label 2023-11-13 12:28:53 +01:00
Blender Bot added
Status
Archived
and removed
Status
Resolved
labels 2023-11-13 12:29:37 +01:00
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
2 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#113569
No description provided.