0

I am using this code, based on a previous question: https://blender.stackexchange.com/a/302335/171509

import bpy
Color_Node_UID = "Test"

obj = bpy.context.selected_objects[0] obj[Color_Node_UID] = (1.0, 0.0, 0.0) ui_prop = obj.id_properties_ui(Color_Node_UID) ui_prop.update(subtype="COLOR", min=0.0, max=1.0)

Which will create the custom attribute for this specific object:

enter image description here

In the shader I have an attribute node, named Test: enter image description here

But in the viewport it is still black

enter image description here

Do I open the color picker and change anything it is updating correctly:

enter image description here

enter image description here

I already had the same issue here: https://blender.stackexchange.com/a/298953/171509

The solution was to have an empty lamda in the FloatVectorProperty:

bpy.types.Object.custom_color = bpy.props.FloatVectorProperty(
    name="Custom Color",
    subtype='COLOR',
    default=(1.0, 1.0, 1.0),
    min=0.0,
    max=1.0,
    update=lambda self, context: None
)

But I just can't figure out how I can get the update lamda in the id_properties_ui.

ui_prop.update(subtype="COLOR", min=0.0, max=1.0, update=lambda self, context: None)

Errors with:

Python: Traceback (most recent call last):
  File "\Text", line 9, in <module>
TypeError: 'update' is an invalid keyword argument for update()

Would be epic to get a hint.

YupDiDo
  • 55
  • 4
  • This hack works, but I am not sure if this is a good approach. https://blender.stackexchange.com/a/258030/171509

    ` import bpy Color_Node_UID = "Test"

    obj = bpy.context.selected_objects[0] obj[Color_Node_UID] = (1.0, 0.0, 0.0) ui_prop = obj.id_properties_ui(Color_Node_UID) ui_prop.update(subtype="COLOR", min=0.0, max=1.0)

    obj.hide_render = obj.hide_render `

    – YupDiDo Oct 17 '23 at 12:49
  • I think ui_prop = ui_prop will fire the update callback – Gorgious Oct 17 '23 at 13:48

0 Answers0