如何在 MaxScript 中获取 SubRollouts 的顺序

How to get the order of SubRollouts in MaxScript

我正在尝试访问 mainSubRollout 的 属性 以获取子部署的顺序。

在 运行 下面的代码之后,像图像一样将 Sub 2 卷展栏拖到顶部并检查 mainRolTest.mainSubRollout.rollouts 它总是 returns #(Rollout:subRollout1, Rollout:subRollout2) 即使显示的顺序部署不一样。

如何访问它们当前显示的顺序?

图片的结果应该是:#(Rollout:subRollout2, Rollout:subRollout1)

try destroyDialog mainRolTest catch()

(

  rollout subRollout1 "Sub 1" autoLayoutOnResize:true
  (
    button theButton1 "Fake Button 1"
    )

  rollout subRollout2 "Sub 2"  autoLayoutOnResize:true
  (
    button theButton2 "Fake Button 2"
    )

  rollout mainRolTest "..."
  (

    button btn_close "X" align:#right offset:[13,-5]

    SubRollout mainSubRollout "" height:133 width:150 pos:[0,20]

    on btn_close pressed do destroydialog mainRolTest

    )

  createDialog mainRolTest 150 133 style:#() lockHeight:true lockWidth:true
  AddSubRollout mainRolTest.mainSubRollout subRollout1
  AddSubRollout mainRolTest.mainSubRollout subRollout2

  )

-- This always returns #(Rollout:subRollout1, Rollout:subRollout2)
-- Even though the order of the rollouts are not the same
-- How can i access this info?
mainRolTest.mainSubRollout.rollouts

您始终可以使用他们的实际位置:

fn sortByY A B = (windows.getWindowPos A.hWnd).y - (windows.getWindowPos B.hWnd).y
rollouts = #() + mainRolTest.mainSubRollout.rollouts
qSort rollouts sortByY --> 'rollouts' will now be sorted based on Y

如果你想要索引又不介意一点点.NET,也可以这样做:

iGlobal = (dotNetClass "Autodesk.Max.GlobalInterface").Instance
rollupContainer = iGlobal.GetIRollup (UIAccessor.GetParentWindow mainRolTest.mainSubRollout.rollouts[1].hwnd)
rollupContainer.GetPanelIndex mainRolTest.mainSubRollout.rollouts[2].hwnd

为了完整起见,您也可以通过 Qt 来完成:

QtWidgets = python.import "PySide2.QtWidgets"
rolloutWidget = QtWidgets.QWidget.find (UIAccessor.GetParentWindow mainRolTest.mainSubRollout.rollouts[1].hwnd)
((rolloutWidget.parent()).layout()).indexOf rolloutWidget