ポリゴンを分けてたんだけど、
標準だといろいろメンドクサイ
通常のExtract
・原点はワールドに移動し・新しいオブジェクトはScene_Rootの子に
オブジェクト数が少ないうちはいいが
新規のオブジェクトの位置が遠い orz
Extract Plust
・オブジェクトの親を同じにする・名前を同じにする
・SRTを同じにする
以下コード
#Extract Plus
#v0.1
#SRTを抽出したオブジェクトと同じにする
delete = True
from win32com.client import constants as c
app = Application; log = app.Logmessage
def extractPoly():
oSel = app.Selection(0)
oSub = oSel.Subcomponent
oObj = oSub.Parent3DObject
oName = oObj.Name
op = app.ExtractFromComponents("ExtractPolygonsOp","",oName,delete,1)
newObj = op(0)
if oObj.Parent.Name !="Scene_Root":
app.ParentObj(oObj.Parent,newObj)
oTrans = oObj.Kinematics.Global.Transform
for Obj in newObj:
Obj.Kinematics.Global.Transform = oTrans
oGeo = Obj.ActivePrimitive.Geometry
oPnts = oGeo.Points
aPos = oPnts.PositionArray
aPosList = [list(aPos[0]),list(aPos[1]),list(aPos[2])]
v = XSIMath.CreateVector3()
m = XSIMath.CreateMatrix4()
oTrans.GetMatrix4(m)
m.InvertInPlace()
for i in range(oPnts.Count):
v.Set(aPosList[0][i],aPosList[1][i],aPosList[2][i])
v.MulByMatrix4InPlace(m)
aPosList[0][i] = v.X
aPosList[1][i] = v.Y
aPosList[2][i] = v.Z
oGeo.points.PositionArray = aPosList
return True
def main():
if app.Selection.Count == 0:
return
if app.Selection(0).Type == "polySubComponent":
extractPoly()
else:
log("Plz SelectPolygon")
return
main()


0 件のコメント:
コメントを投稿