Group by type

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  03 March 2013
Group by type

Hey guys I want to be able to group certain objects by the type they are. So I have created 4 lattices clustered the verts of the lattice points and created control curves for the clusters. Then I want to group those under their respectful group.

When I try to put the selected obj under variables I can not seem to break it apart. I want to make a general selection in the scene I don't want to select individuals by hand I want to do a general selection and divide the object up in code. Ok so with all lattices and clusters and control curves selected I want to break it up in latSel variable, clustSel variable and ctrlSel variable. So far I got this code but it not working correctly.

latType =, sl=1, type='lattice')
cmds.pickWalk(latType, direction='up' )

This gets me the lattice but no base? And there is no base info in the docs.

For the cluster it does not work when I enter the type cluster. In the doc the creation command for the cluster is cluster why can I not enter cluster in the type and get just the cluster?

clustType =, sl=1, type='cluster')

This will return everything selected. Is cluster not the definition of a cluster? I have also tried exactType'cluster' got the same result.
Character TD
  03 March 2013
When you select a cluster, lattice, or nurbscurve in the viewport, you select it's transform, not it's shape. If you want to check if you have a cluster or a lattice selected you need to check the node type of it's shape.

Instead of doing a series of ls commands with different types, get everything that is selected with one ls and perform different procedures based on each node's type.

sel =, transforms=True, long=True)
objs = {}
for obj in sel:
    children = cmds.listRelatives(obj, shapes=True, fullPath=True)
    if children:
        ntype = cmds.nodeType(children[0])
        if ntype == 'lattice':
            # do lattice stuff
            objs.setdefault('lattice', []).append(obj)
        elif ntype == 'clusterHandle':
            # do cluster stuff
            objs.setdefault('cluster', []).append(obj)
        elif ntype == 'nurbsCurve':
            # do nurbs curve stuff
            objs.setdefault('nurbscurve', []).append(obj)

Now you can access all the selected lattices with objs['lattice']

If you want to get the baseLattice associated with a lattice, you have to get the connected ffd, and from there get the baseLattice, which should be connected to the baseLatticeMatrix attribute on the ffd.
latticeShape = 'ffd1LatticeShape'
base = None
for ffd in cmds.listConnections(latticeShape, source=False, type='ffd') or []:
    conns = cmds.listConnections(ffd, destination=False, type='baseLattice')
    if conns:
        base = conns[0]

Note that listConnections will return the transform of the ffdBase, even though it is the shape that is actually connected.
  03 March 2013
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 11:34 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.