1

I wanted to add a color field to my Blender addon panel, with which I can adjust the color input of a Principled Volume node. But i´m struggling, how I can insert such a color field there and synchronize it with the color field of the Principled Volume. Does anybody know how to do that? I would appreciate every help!

VICUBE Animation
  • 501
  • 3
  • 14

1 Answers1

0

check this out:

import bpy

def hndl_draw(self, context): row = self.layout.row()

row.prop(context.object.data, "myColor")

def get_color(self): return bpy.data.materials["Material.001"].node_tree.nodes["Principled Volume"].inputs[0].default_value

def set_color(self, value): bpy.data.materials["Material.001"].node_tree.nodes["Principled Volume"].inputs[0].default_value = value return

def register():
bpy.types.Armature.myColor = bpy.props.FloatVectorProperty( get=get_color, set=set_color, name = "myColor", subtype = "COLOR", size = 4, min = 0.0, max = 1.0, default = (0.75,0.0,0.8,1.0) )

bpy.types.DATA_PT_display.append(hndl_draw)

def unregister(): bpy.types.DATA_PT_display.remove(hndl_draw) del bpy.types.Armature.myColor

if name == "main": register()

Note1: i used the solution from here: Color as Custom Property?

Note2: i changed it a bit

Note3: you need a material called "Material.001" with a principled volume in it with exact the name i used, and an armature

result:

enter image description here

hope that helps.

Chris
  • 59,454
  • 6
  • 30
  • 84