2017-05-26 76 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好找出来 –