2012年4月18日 星期三

MAXscript : Skin Copy/Paste

--
--選擇已Skin物件執行Copy, 自動記錄bones和存出env, 再選擇要套用Skin的物件執行Paste套回
--需要設定tempDir供存出env檔案用
--by JanusHaung
skinBonesArray = #()
tempDir = "D:/MaxProject/export/"
envFilename = ""

rollout skinCopyPaste "Skin Copy Paste" width:185 height:50
(
 button btn_copy "Copy" across:2
 button btn_paste "Paste"
 label lbl1 ""

 on btn_copy pressed do (
  -- 選擇已skin好的物件並執行
  if $.modifiers[#Skin] != undefined do (
   skinBonesArray = for i in 1 to skinops.getnumberbones $.skin collect skinops.getbonename $.skin i 0
   envFilename = tempDir + $.name + ".env"
   skinOps.saveEnvelope $.skin envFilename
   lbl1.caption = "Skin copied."
  )
 )
 
 on btn_paste pressed do (
  max modify mode
  if skinBonesArray.count > 0 do (
   -- 選擇尚未skin好的模型執行
   if $.modifiers[#Skin] == undefined do addmodifier $ (Skin())
   for i in 1 to skinBonesArray.count do skinOps.addbone $.skin ( getNodeByName skinBonesArray[i] ) 0
   --先執行completeRedraw()才可成功LoadEnvlope
   completeRedraw()
   skinOps.LoadEnvelope $.skin envFilename
   lbl1.caption = "Skin pasted."
  )
 )
)

createDialog skinCopyPaste

沒有留言:

張貼留言