As far as I know, maya's database doesn't index all geometry vertex counts in a 
way that you can filter select on it. The API selection mechanism only lets you 
select on name patterns and then filter on type. And the python commands wrap 
around that to add more type filtering. 
I believe your only option is to loop over all geometry and do a 
polyEvaluate(v=True) on each one to test the vertex count, and then append to a 
list. A list comprehension would be the same speed as a multi-line for loop:

# list comp
matches = [geom for geom in cmds.ls(dag=True, g=True) if 
cmds.polyEvaluate(geom, v=True) > 1000]

# same as normal loop 
matches = []
for geom in cmds.ls(dag=True, g=True):
    if cmds.polyEvaluate(geom, v=True) > 1000:
        matches.append(geom)

This would also be slightly faster if you were to do it in the API because of 
the selection iterator.

Is this something where you need extremely low latency searches for queries 
happening constantly? Or were you just looking for a simpler way to do the 
query? Because if you needed a solution faster than looping over every single 
one, in the way thats similar to your SQL style query, you would need to index 
all the geometry yourself by vertex count into a dictionary. And then either 
manage it yourself each some geometry is modified or attach some kind of 
scriptJob to keep updating it. But Im not sure if thats even your goal. The SQL 
query just sorta made me think you needed fast queries that are indexed.


On Dec 26, 2011, at 4:32 AM, Panupat wrote:

> say I want to select geometries that have more than X amount of
> vertices. Using some kind of logic like this
> 
> select geometry where vertex count > 10000
> 
> Is this doable? I can think of a way to cycle through all geometries
> and check their vertices but wondering if there's a better way.
> 
> -- 
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings: 
> http://groups.google.com/group/python_inside_maya/subscribe

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to