Hi guys,
I’m very new to python, but picking it up fairly quickly because I have some familiarity with other programming languages.
I just need some advice on a specific aspect.
I’m trying to visualise a vector field based on data in a text file. I’m having trouble working out how to import and reference the data.
The data is in the form of a space delimited text file with scientific notation. So, for example, a 3x4 array would look something like this:
0 12 3.45 5e7
2.23e-3 98 3 43
32e-12 2.45 23.4 234
At the moment I’m working with data that is 32x32, but I have arrays that are 128x128x128 and would visualise anything up to that size in future depending on what my system can handle.
Anyway, I wanted to avoid installing numpy to avoid any complications that may arise installing stuff, just until I get more familiar with python.
I tried doing it as a list, but not sure exactly how to access the elements, or if I need to do anything to help it recognize the scientific notation.
I know that the rest of my code works, because the following works
import bpy
import math
from math import pi
for x in range(1,32):
for y in range(1,32):
bpy.ops.mesh.primitive_cone_add(location=((x-17)/2,(y-17)/2,0),rotation=(0,0,0), )
bpy.ops.transform.resize(value = (0.05, 0.05, 0.3) )
bpy.ops.transform.rotate(value = (pi/2,), axis = (1,1,0),)
but it doesn’t work when I try to use data for each object from a text file
import bpy
import math
from math import pi
uExpFile = open(r'D:\simulations\Electromagnetic\images\uExp.txt')
uExp = []
for line in uExpFile.readlines():
y = [value for value in line.split()]
uExp.append(y)
uExpFile.close()
vExpFile = open(r'D:\simulations\Electromagnetic\images\vExp.txt')
vExp = []
for line in vExpFile.readlines():
y = [value for value in line.split()]
vExp.append(y)
vExpFile.close()
for x in range(1,32):
for y in range(1,32):
bpy.ops.mesh.primitive_cone_add(location=((x-17)/2,(y-17)/2,0),rotation=(0,0,0), )
bpy.ops.transform.resize(value = (0.05, 0.05, 0.3) )
bpy.ops.transform.rotate(value = (pi/2,), axis = (vExp[x,y],uExp[x,y],0),)
Any help with this would be appreciated
Cheers.