選択した、頂点、ポリゴン、エッジが入っちゃっているクラスタを調査する

Twitterでふられたので、Pythonで作ってみました。
選択した頂点等、コンポーネントがちょっとでもかすっているクラスタを調査し、選択します。
名付けて、「出てこいクラスター」もしくは「表に出ろやクラスター」

内容は雑ですが、大体こんな感じかと・・・。
SIのコンポーネントを探したいときに階層のいちいち深いところまでいかないといけない典型的な例でした。

なんで横のつながりでサクッといかないんでしょうかねぇ・・・。

どっかの大きな組織のようですねぇ。w

それにしても、Pythonまじ便利。

import win32com.client
from win32com.client import constants

try:

	# Applicationを短縮
	app = Application
	selist = []

	oCmp = app.GetValue("SelectionList")
	clstype = ''

	# 選択したオブジェクト分だけ回す
	for oSel in oCmp:
		oObj = oSel.SubComponent.Parent3DObject
		# print oSel.SubComponent.Parent3DObject
		# 選択された頂点毎に調査
		for oSubcmp in oSel.SubComponent.ComponentCollection:
			# print oSubcmp.index

			# 選択対象のタイプを絞る(ていうかサブコンポーネントクラスタのタイプ名が違うのはなんで??)
			if str(oSubcmp) == 'Vertex':
				clstype = 'pnt'
			elif str(oSubcmp) == 'PolygonFace':
				clstype = 'poly'
			elif str(oSubcmp) == 'Edge':
				clstype = 'edge'
				
			# 選択した頂点がクラスタの中に存在しているか調査
			for oCls in oObj.ActivePrimitive.Geometry.Clusters:
				# クラスタタイプ調査
				if clstype == oCls.type:
					# リストに調査クラスタが入っていないか?
					if selist.count(str(oCls)) == 0:
						myElem = oCls.Elements
						a = 0
						# print '-cluster elements ' + oCls.type
						while a < len(myElem):
							# print myElem(a)
							if oSubcmp.index == myElem(a):
								# print clstype + '==' + oCls.type
								print oCls
								selist.append(str(oCls))
								break
							a = a + 1
							
	# print '選択対象確認 ' + selist
	app.SelectObj(selist, "", "")
	
except:
	print 'エラー!'