2017-05-26 73 views
0

通過選擇循環和附加子對象一起

on execute do 
(

    local AttachableObjectArray = #() 
    local SelectedNodes = getCurrentSelection() 
    local Idx = 1 





      for object in SelectedNodes[Idx].children do 
      (     
       append AttachableObjectArray object 
      )  

       for i = 1 to AttachableObjectArray.count do 
        (   
         polyop.attach attachableobjectarray[1] attachableobjectarray[i] 

         for j = 1 to AttachableObjectArray.count do 
         (
          if attachableobjectarray.count <= j do 
          (
           deselect SelectedNodes[Idx] 

          ) 
         ) 

        ) 
        SelectedNodes = getCurrentSelection() 
        print SelectedNodes.count 

這是我目前的腳本進行工作,但一次只適用於一個層次,我需要它循環經過我的選擇,直到所有的父母孩子們連接到 相互

問題: 父----兒童,兒童,兒童家長-----孩子 - 孩子 - 孩子 當前腳本: 父----智ldren掛接父-----兒童,兒童,兒童

由家長與鏈接到虛擬

感謝盒虛擬事先提示

回答

0
for obj in $/selection/* do -- use just the top-level nodes 
(
    local children = join #() obj 
    local childrenToAttach = for i = 2 to children.count where canConvertTo children[i] Mesh collect children[i] 
    if childrenToAttach.count > 1 do convertToPoly childrenToAttach[1] 
    for i = 2 to childrenToAttach.count do polyop.attach childrenToAttach[1] childrenToAttach[i] 
) 
+0

感謝swordslayer好找出來 –