以前作った物をUPしてみたのですが、
人に見せるコードではないですね orz
自分ですらわかりません。
最近は、自スクリプトのメンテもするようになってきましたので
これは意識して修正をして行かねばなりませんね
SelarateSelCluster
選択したクラスターを分離して新しいオブジェクトにするスクリプト
#-----------------------------------------------------------------------
#SeparateSelCluster
#選択したクラスタを分離、マテリアルを適用
#使用法
#クラスタを選択実行
#履歴
# v1.0 完成
from win32com.client import constants as c
app = Application;log = app.Logmessage
import re
#-----------------------------------------------------------------------
# Main
#-----------------------------------------------------------------------
def main():
#クラスターを確認
oSel = app.Selection(0)
if oSel.Type != "poly":
log("Select Poly Cluster")
return 0
oCls = oSel
oObj = oSel.Parent3DObject
oGeo = oObj.ActivePrimitive.Geometry
#ポリゴンのインデックスを-1で初期化[-1,-1,-1]
aIndex = oGeo.Polygons.IndexArray
a = []
for i in aIndex:
a.append(-1)
for i,v in enumerate(oCls.FindIndices(aIndex)):
if v != -1:
a[i] = 1
extIndex = []
for i,v in enumerate(a):
if v == 1:
extIndex.append(i)
subset = extIndex
oSub = oGeo.Polygons.SubComponent
oSub.ElementArray = subset
app.SelectObj(oSub)
op = app.ExtractFromComponents("ExtractPolygonsOp", oSub, oObj.Name + "_" + oSel.Name, True, "siImmediateOperation", "siKeepGenOpInputs", "")
newObj = op(0)(0)
app.DeleteObj(oCls)
oCls = newObj.ActivePrimitive.Geometry.Clusters
for i in oCls:
if i.Type == "polygon":
newObj.SetMaterial(oCls.Material)
app.DeleteObj(oCls)
#親子付けをする
#バグ報告アリガトウございますです。ちょっとOffっておきます〜
#app.ParentObj(oObj.Parent3DObject,newObj)
return 1
main()
#-----------------------------------------------------------------------
使用の際の不具合の責は負いませんぜ
バグ報告は歓迎します (≧▽≦)ゞ
0 件のコメント:
コメントを投稿