theodox / minq Goto Github PK
View Code? Open in Web Editor NEWa query language for Maya
a query language for Maya
I have a condition where doing a transform search for all children with like filtering returns an empty result if I try to do an exact match.
pseudo hierarchy
-my_model:root
-- my_model:my_control_offset
-- my_model:my_control_space
--my_model:my_control_driven
--my_model:my_control
doing: using(my_model:root).get(AllChildren).short().like('my_control')
results in: my_control, my_control_driven, my_control_space, my_control_offset
doing: using(my_model:root).get(AllChildren).short().like('my_control', exact=True)
results in: nothing
I think the correct behavior should be a returned result of: my_control
Please let me know if this is a bug or if I am not using the api correctly.
I borked the innards of where_not when I made the changes to support custom
and native
.
there's a lot of examples that look like this:
no_uvs = Meshes().where_not(lambda p: any(using(p).get(UVPointCount)))
Which is fine - but it's common enough that it would be nice to get rid of the boilerplate.
What's a nice elegant way to elide lambda p: using(p).get(XXX)....
?
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)
I see a lot of applications like this:
Meshes().foreach( lambda p: using (p).get(Connections))
where you want to do a minq expansion in a foreach loop. the lambda(p): using(p).get....
is boilerplate.
Maybe add a proxy class called each
which swapped in the boilerplate?
PROPOSED
Meshes().foreach(each.get(Connections))
Not quite sure what to do about this one. However I've noticed that the pyCharm debugger will force an early evaluation of a stream if you are stepping through code -- which can mean that the stream does not properly pass along it's resuilts. Here's a test example:
markup_objects = MarkupNode.find_markup() + LadderMarkupNode.find_markup()
return set(markup_objects.foreach(lambda x: x.index))
where the find_markup
functions are minq queries yielding table streams. if you run this without stepping through a debugger, it works. If you step through. the first line will look like it has the proper values -- but it will return an empty set, because after you step to the second line the stream -- which is a compound of two other streams that are now out of scope -- will be exhausted.
This may be an unavoidable gotcha. Any clever ideas?
it's pretty simple do to this upstream -- but not downstream because of possible branching.
Here;s an example for the hierarchy; the history would be similar.
def joint_parent(target):
# walk up to the first joint parent of <target> or None
def recurse_up(m):
upstream = cmds.listRelatives(m, p=True)
if upstream:
yield upstream[0]
for item in recurse_up(upstream[0]):
yield item
return Stream( (i for i in recurse_up(target)) )
It looks like maya does not allow bulk getAttr
calls on custom attributes :(
Will have to rejigger the split between where()
and whereMany()
to restrict custom attributes to where
calls, which will be slower.
Essentially a module minq.lowercase
which did the same trick as the main minq
module but exposed all the class names in lower-case format, enabling
cameras().where(item.hfov > 50).get(parents)
for people who don't like the capitalized class names....
I have no idea what the api might look like, but support for querying, making, and removing connections would be awesome
currently the idiom for creating tables is something like
main, secondary, tertiary = Query().split(3)
translates = secondary.get(Attribute, 't').get(Values)
rotates = tertiary.get(Attribute, 'r').get(Values)
table = main.join(pos=translates. rot=rotates)
Would it be nicer to try something like
table = query.table( pos= AttributeValues('t'), rot = AttributeValues('r'))
Would need a new Stream type which basically combined a get(Attribute).get(Values) pair into one op
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.