Skip to content

Instantly share code, notes, and snippets.

@nrtkbb
Created March 28, 2015 14:38
Show Gist options
  • Save nrtkbb/2882d63df78ecd87ac4c to your computer and use it in GitHub Desktop.
Save nrtkbb/2882d63df78ecd87ac4c to your computer and use it in GitHub Desktop.
follicleがないhairSystemとpfxHairを見つけて選択するやつ
# -*- coding: utf-8 -*-
import pymel.core as pm
def selectEmptyHairs():
hairs = pm.ls(type='hairSystem')
if len(hairs) is 0:
pfxs = pm.ls(type='pfxHair')
if len(pfxs) is 0:
return 'Not found hairSystem and pfxHair.'
else:
# pfxHairShapeのtransformを選択
pm.select(map(lambda p:p.getParent(), pfxs))
return 'Not found hairSystem, But few found pfxHair.'
selection = []
for hair in hairs:
follicles = hair.attr('inputHair').inputs()
if len(follicles) is 0:
selection.append(hair.getParent())
pfxs = pm.listConnections(hair, source=False, type='pfxHair')
selection.extend(pfxs)
pfxs = pm.ls(type='pfxHair')
for pfx in pfxs:
try:
hairs = pfx.attr('renderHairs').inputs()
if len(hairs) is 0:
selection.append(pfx.getParent())
except:
selection.append(pfx.getParent())
if len(selection) is 0:
return 'Not found empty hairSystem and empty pfxHair.'
else:
pm.select(selection)
return 'Found empty hairSystem or pfxHair.'
@nrtkbb
Copy link
Author

nrtkbb commented Mar 29, 2015

maya/scriptsなどに保存してMayaのScriptEditor(PythonTab)へコマンドを打ち込む

from selectEmptyHair import selectEmptyHairs
selectEmptyHairs()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment