Running into some issues with the FloatVectorProperty.
Long story short I made some changes in blenderseed to how we display nodes, and for ease of use I’m working on an automated function to copy the value of a variable in a socket class into another variable in the node itself.
Here’s a snipped of the code:
for node_group in bpy.data.node_groups:
for node in node_group.nodes:
for socket in node.inputs:
if hasattr(socket, "socket_value"):
current_value = socket.socket_value
default_value = socket.socket_default_value
if current_value != default_value:
logger.debug("Updating shader tree %s, Node: %s, Parameter: %s", node_group.name, node.name, socket.socket_osl_id)
setattr(node, socket.socket_osl_id, current_value)
setattr(socket, "socket_value", default_value)
The ‘socket_value’ variable is adjustable by the user (socket_default_value isn’t).
This method of copying works great for FloatProperty, IntProperty, StringProperty, and FloatVectorProperty with the ‘COLOR’ subtype. However, it breaks with a FloatVectorProperty with a size of ‘2’ and no subtype.
Here’s what I get when I call a color in the Python console:
Here’s what happens when I try to call a float[2] (as we call it) variable:
I don’t get the actual values. If I do a list() I can:
but for some reason, this doesn’t work in blenderseed. Instead I get this:
[] (an empty list).
Am I missing something? What is the best way to retrieve the values of an arbitrarily sized FloatVectorProperty?