CONTEXT:
I am trying to create a 3D Data-Viz project that will take values from a CSV file and use certain values to drive the Z-scale of simple cubes that will stretch vertically as a value gets higher. It would function similarly to this 3D-Viz asset from the Unity Asset Store, except instead of longitude and latitude, it would take custom tags assigned by hand: https://assetstore.unity.com/packages/templates/systems/globe-data-visualizer-80008
I have tried looking at a lot of SE questions, and Python/Blender API as well to try and reverse engineer some other approaches; some of the pages I have gone through:
How to read a csv file and use the values as x and y points in blender?
MY EFFORT(S):
My CSV File has a format that fits like
08-S33,Grind,2018,1,118654,1015122,1168.864432
04-LSE200,Gear,2018,1,61,1798,339.2658509
My scene currently has a few simple primitives with names "Cube.001" and Cube.002" I have given them Game Properties that have values that match the first column in my CSV like '04-LSE200':
I have tried to write my own script that says:
import bpy, csv
fp = "E:\Data_Viz_Prototype\Data Files\Workcenter_DPPM.csv"
with open( fp ) as csvfile:
rdr = csv.reader ( csvfile)
for i, row in enumerate (rdr):
if i == 0: continue #Skip colum titles
if row[2:3] != 2018: continue #Skip any rows not from 2018
if row[3:2] != 1: continue #Skip any rows not from January
wc, dept, year, month, run, rej, dppm = row[:]
if bpy.data.objects["Cube.002"]['Work_Center'] == '04-LSE200':
bpy.data.objects["Cube.002"].scale = (.5, .5, dppm)
However I get the following error:
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
KeyError: 'bpy_struct[key]: key "Work_Center" not found'
I have tried some of the following code in the console window to make sure I can talk to Game properties:
import bpy
bpy.ops.object.game_property_new(type='FLOAT', name="Test")
obj = bpy.data.objects["Cube.002"]
cube = obj.data
print(bpy.types.GameStringProperty.values(cube))
Which will create a new property upon compile, but returns an empty list "[]"
FINAL THOUGHTS:
I am very aware this could be an "X-Y Problem"; in which case I think I need some serious redirection. I found this one SE question where they were trying to drive values from a CSV file using the node editor; maybe this is the correct approach but I don't even know how to start:
Animation nodes - Driving scale attribute from a CSV list to create a bar chart
My co-worker and I combined have a fair amount of experience in coding, game engines, and modeling; but neither of us is notably familiar with Blender.