This is probably more of a general python question, but my searching for the answer elsewhere hasn’t helped. I have a vector list (from static particles in Blender) that I am exporting. The vector list that is exported looks something like [[A, B, C (vector)],[D, E, F (vector)]]. What I would like however is this information formatted to look like A B C D E F. Since this is vector information the usual python string replacing functions don’t work, nor can I seem to get this vector information converted to a string to do some replacing. I thought wrapping the data might be the missing peice of the puzzle, but I can’t seem to get that working either. Thoughts anyone?
do you mean something like this:
destData = []
for vect in sourceData:
for elem in vect:
destData.append(elem)
something like this should work
pars = [tuple(vec) for v in particles]
Thanks for the responses. ashid’s idea gets rid of several issues, but the output still looks like [A, B, C, D, E, F] rather than just A B C D E F.
@Campbell
I don’t understand your solution due to my beginner status. Could you elaborate? Do you mean somthing like this (using an API example):
effects= Effect.Get()
for eff in effects:
for p in eff.getParticlesLoc():
if type(p)==list:
pars = [tuple(vec) for v in p]
print pars
I can’t seem to get it working since vec isn’t defined.
If you just want a string with all information (if I understood you correctly).
destData = str()
for vect in sourceData:
for elem in vect:
destData+=" "+str(elem)
Hey Crouch,
Your way worked exactly the way I needed. Thanks!