I'm looking for an approach to parse xy positional information (mesh centers) into a numpy array to extract the column row information for each xy position. z is object name (or could be a reference to FbxMesh)
[
[1782.6000366210938, 336.4900026321411, u'5_07_05'],
[2397.0, -1506.7100219726562, u'5_08_08'],
[3011.4000244140625, -277.9100217819214, u'5_09_06'],
[3011.4000244140625, 336.4900026321411, u'5_09_05'],
[2397.0, -277.9099597930908, u'5_08_06'],
[2397.0, 336.4900026321411, u'5_08_05'],
[1782.6000366210938, -1506.7100219726562, u'5_07_08'],
[2397.0, -892.3099975585938, u'5_08_07'],
[1782.6000366210938, -892.3099975585938, u'5_07_07'],
[3011.4000244140625, -1506.7100219726562, u'5_09_08'],
[1782.6000366210938, -277.90999126434326, u'5_07_06'],
[3011.4000244140625, -892.3099975585938, u'5_09_07']
]
The idea would be to reshape the array above into a correctly shaped array from the lowest value on the bottom left to the highest on the top right.. then sample the column and row index of each item [0,0] [0,1] etc.. and then export the mesh with an appropriate name.. cheers
Update:
I can sort that above list sorted_array = sorted(unsorted_array,key=lambda x: (x[0],x[1]))
[1782.6000366210938, -1506.7100219726562, u'5_07_08']
[1782.6000366210938, -892.3099975585938, u'5_07_07']
[1782.6000366210938, -277.90999126434326, u'5_07_06']
[1782.6000366210938, 336.4900026321411, u'5_07_05']
[2397.0, -1506.7100219726562, u'5_08_08']
[2397.0, -892.3099975585938, u'5_08_07']
[2397.0, -277.9099597930908, u'5_08_06']
[2397.0, 336.4900026321411, u'5_08_05']
[3011.4000244140625, -1506.7100219726562, u'5_09_08']
[3011.4000244140625, -892.3099975585938, u'5_09_07']
[3011.4000244140625, -277.9100217819214, u'5_09_06']
[3011.4000244140625, 336.4900026321411, u'5_09_05']
format [X, Y, 'name']
I'd like to arrange this into a grid and then transpose , for example
After this the idea is to read out each grid cells index and the name in the array eg tile_X0_Y0 etc..
Just play with the axes of the transpose
and flip
commands.
import numpy as np
a=np.array([[[9,8],[9,7],[9,6],[9,5]],
[[8,8],[8,7],[8,6],[8,5]],
[[7,8],[7,7],[7,6],[7,5]]])
b=np.transpose(a,axes=[1,0,2])
c=np.flip(b,axis=1)
d=np.flip(c,axis=0)
print(a)
print('******')
print(b)
print('*****')
print(c)
print('*****')
print(d)
output:
[[[9 8]
[9 7]
[9 6]
[9 5]]
[[8 8]
[8 7]
[8 6]
[8 5]]
[[7 8]
[7 7]
[7 6]
[7 5]]]
******
[[[9 8]
[8 8]
[7 8]]
[[9 7]
[8 7]
[7 7]]
[[9 6]
[8 6]
[7 6]]
[[9 5]
[8 5]
[7 5]]]
*****
[[[7 8]
[8 8]
[9 8]]
[[7 7]
[8 7]
[9 7]]
[[7 6]
[8 6]
[9 6]]
[[7 5]
[8 5]
[9 5]]]
*****
[[[7 5]
[8 5]
[9 5]]
[[7 6]
[8 6]
[9 6]]
[[7 7]
[8 7]
[9 7]]
[[7 8]
[8 8]
[9 8]]]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.