Skip to content

Instantly share code, notes, and snippets.

@tcrowson
Last active January 2, 2016 07:59
Show Gist options
  • Save tcrowson/8273720 to your computer and use it in GitHub Desktop.
Save tcrowson/8273720 to your computer and use it in GitHub Desktop.
For Softimage. This script gathers all the polymeshes for selected models and places them in model-specific groups.
# Gathers all the polymeshes for selected models and places them in model-specific groups
# (i.e. one group for each model).
from win32com.client import constants
if len(Application.Selection) > 0:
selectedModels = [item for item in Application.Selection if item.Type == '#model']
# Create the groups and populate them
for model in selectedModels:
flag = True
for group in Application.FindObjects("", "{9D0673C2-6741-11D1-BE9F-00A024EE478D}" ):
if group.Name == "%s_POLYMESHES"%(model):
flag = False
if flag:
grp = Application.ActiveProject2.ActiveScene.Root.AddGroup(None,"%s_POLYMESHES"%(model))
for mesh in model.FindChildren("", constants.siPolyMeshType, c.siGeometryFamily, True):
grp.AddMember(mesh, False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment