Hi there,
i’m currently learning about python in general and about blender python specifically.
But i’m at the very beginning so this might not make a lot of sense.
I tried to write a little script (https://www.dropbox.com/s/cvwvzli2e5g11kz/DataGraph.py?dl=0) that takes in a number of lists containing values from 0 to 1. These lists are wrapped into another list so that i can access this list without worrying about how many “sublists” i entered.
[SUB]# Data Source[/SUB]
[SUB]n = [ [/SUB]
[SUB][0.1, 0.5, 0.3, 1.0 , 0.7, 1.0, .5], [/SUB]
[SUB][0.5, 0.3, 0.1, 0.1, 0.2, 1.0, .5], [/SUB]
[SUB][0.1, 0.5, 0.3, 1.0 , 0.7, 1.0, .5],[/SUB]
[SUB][0.5, 0.3, 0.1, 0.1, 0.2, 1.0, .5] [/SUB]
[SUB]]
[/SUB][SUB]index1 = 0[/SUB]
[SUB]index2 = 0[/SUB]
The next step would be to create a row of scaled cubes to represent the items in the sublists. And there should be as many rows as there are sublists in n. This works fine with this:
[SUB]# Grid Generation[/SUB]
[SUB]for i in range (0, len(n)): [/SUB]
[SUB] for j in range (0, len(n[0])): [/SUB]
[SUB] x = i [/SUB]
[SUB] y = j [/SUB]
[SUB] z = 0[/SUB]
[SUB] bpy.ops.mesh.primitive_cube_add(radius=1, view_align=False, enter_editmode=False, location=(y, x, 0))[/SUB]
[SUB] bpy.ops.transform.resize(value=(.25, .25, n[index1][index2]))[/SUB]
[SUB] bpy.ops.transform.translate(value=(0, 0, n[index1][index2]))[/SUB]
[SUB] if index2 < len(n[0]):[/SUB]
[SUB] index2 += 1[/SUB]
[SUB] if index2 == len(n[0]):[/SUB]
[SUB] index1 += 1[/SUB]
[SUB] index2 = 0[/SUB]
[SUB] if index1 == len(n):[/SUB]
[SUB] break[/SUB]
In the attached file there are comments which might make things more obvious. Now this is probably not very well done but it works fine with just one exception that i can’t figure out why. In the console it keeps telling me
“convertViewVec: called in an invalid context” which i figured out is caused by the translate method in the for loop.
Is this a problem? Or maybe someone has a quick idea how this can be avoided? I think maybe accessing the list for a vector Coordinate might be inappropriate but I don’t know how to do it differently.
Thanks in advance if someone has a look at it.
Regards