Right way to get bulk xfroms
theodox opened this issue · 1 comments
theodox commented
it's easy to get Xform queries for one object at a time, but there doesn't appear to be a fast way to do bulk Xform queries. Something like Selected().get(Positions, worldSpace = True)
is attractive but before committing to it i'd like to make sure it's performant
The below works for one object at a time but not for streams due to this limitation
from minq import *
from itertools import islice
from maya.api.OpenMaya import MVector
class Xform(Projection):
QUERY = 'pivots'
def __iter__(self):
kw = {'q': True}
kw[self.QUERY] = True
kw.update(**self.kwargs)
a,b,c = itertools.tee(command_stream(self.incoming, cmds.xform, q=1, t=1, ws=1),3)
triples = itertools.izip_longest(
itertools.islice(a, 0, None, 3),
itertools.islice(b, 1, None, 3),
itertools.islice(c, 2, None, 3)
)
return itertools.imap(MVector, triples)
class Positions(Xform):
QUERY='translation'
class Rotations(Xform):
QUERY = 'rotation'
class Scales(Xform):
QUERY = 'scale'
Selected().get(Positions, worldSpace = True)
theodox commented
Tried to solve this with the WorldPositions and LocalPositions classes