Post #3525:
Ph
📋 Metadata
- Author: roaoao
- Date: 2020-08-19 23:39:49
- Type:
answer - Quality Score: 8/10
- Reply to: post_03517
🏷️ Tags
pie-menu stack-key hotkeys intermediate solved
⚙️ Related PME Features
- Stack Key Editor
- Pie Menu Editor
- Python Scripting
💬 Content
Phazor:
I have a line layer that I use with a line material, a fill layer with fill material, and another fill layer with the multiply blend mode with fill material for shadows.
I want to have a toggle in a pie menu that automatically switches layers and materials with a single button and reverts back if I hit the button again.
Sorry for the late reply.
To set active layer by name use this code:
C.object.data.layers.active = C.object.data.layers['Fill Layer']
To set active material by name you can use this:
C.object.active_material_index = C.object.material_slots.find('Fill Material')
So you need a stack key (not a macro) with 2 slots:
Fill:
C.object.data.layers.active = C.object.data.layers['Fill Layer']; C.object.active_material_index = C.object.material_slots.find('Fill Material')
Line:
C.object.data.layers.active = C.object.data.layers['Line Layer']; C.object.active_material_index = C.object.material_slots.find('Line Material')
❤️ 2 likes