Skip to content

Instantly share code, notes, and snippets.

@mattebb
Last active December 10, 2015 13:28
Show Gist options
  • Save mattebb/4440723 to your computer and use it in GitHub Desktop.
Save mattebb/4440723 to your computer and use it in GitHub Desktop.
Partio NumPy demo
import partio
import numpy as np
p = partio.create()
size = 3
posattr = p.addAttribute("pos",partio.FLOAT,size)
for i in range(8):
p.addParticle()
data = tuple(i+j*100 for j in range(size))
p.set(posattr, i, data)
print( [p.get(posattr, i) for i in range(p.numParticles())] )
print( p.getArray(posattr) )
import partio
import numpy as np
ar = np.arange(24)[::-1]
print(ar)
p = partio.create()
posattr = p.addAttribute("pos",partio.VECTOR,3)
it = p.addParticles(8)
print( [p.get(posattr, i) for i in range(p.numParticles())] )
p.setArray(posattr, ar)
print( [p.get(posattr, i) for i in range(p.numParticles())] )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment