This question is within the context of Geometry Node and drivers.
Using the Python API, we can retrieve the drivers associated to Geometry Nodes of a given node tree this way:
fcurves = tree.animation_data.drivers.values()
for fc in fcurves:
print("fc data_path: " + fc.data_path + " array_index=" + str(fc.array_index))
For a node with compound components (vector) such as this one:
we will have the following result:
fc data_path: nodes["Switch.001"].inputs[2].default_value array_index=0
fc data_path: nodes["Switch.001"].inputs[2].default_value array_index=1
To get the path of the property, we need to append the array index to the data path, for example: nodes["Switch.001"].inputs[2].default_value[0]
For a node with non-compound component such as this one:
we will have the following result:
fc data_path: nodes["Switch"].inputs[1].default_value array_index=0
The problem is that the FCurve's array_index mentions 0 even though the property is not compound. So based on this information alone, we cannot determine the right path of the property: it may be either
nodes["Switch"].inputs[1].default_value[0]
or
nodes["Switch"].inputs[1].default_value
If array_index was set to -1 in the case of non-compound property, that would be unambiguous, but as it is 0 we cannot know with this information alone. Hence my question: how can we determine the right data_path of the property in such a case?
Note: a workaround is to access the node property input given the FCurve data_path and check its type dynamically. However this is cumbersome so I was looking for a cleaner way.