Notifications
Clear all

[Closed] help on treeview activex control

Hi, I am trying to make a script capable to do this:
Navigate trough the tracks of selected objects (similar to the 3dsmax track view) and select any of them, then you can use some spinners to change the value, and also if there are other objects in your selection with the same track, they change too. Its similar to the “Do” script from BlurStudios.

But i found a brickwall just in the beggining:

I am using the Tree View activex control, and I can populate the tree relatively easy. Once its done, I can navigate the tree, but I cant figure out an easy way to access the track´s controller based on node selection.

Let me explain a little more: the TreeView is made of INodes, wich have some properties, but not a property where I can store a reference to the controller. I constructed the tree iterating over all the subanims, making a new node for each subanim and changing the “text” property of that node. So, when I access a Node in the TV, i just can retrieve the text of that node, not a reference to the value.

any idea of how can I retrieve a reference to the controller instead of just the text of the node of the TV

rollout trackMadness “Track”
(
activeXControl tv “MSComctlLib.TreeCtrl” height:400
edittext nodePath
button update “Update”
fn initTreeView tv ilTv=
(
tv.Indentation = 28*15
tv.LineStyle = #tvwRootLines
tv.PathSeparator = “.”
)
fn expand tv theNode theChildren =
(
for i in theChildren do
(

          subArray = #()
          for j = 1 to i.numSubs do
          (
              append subArray i[j]
          )
          newNode = tv.Nodes.add theNode.index 4 "" i.name
          expand tv newNode subArray
      )
  )
  fn updateTree =
  (
      tv.nodes.clear()
      theRoot = tv.Nodes.add()
      theRoot.text = "Selection"
      showproperties theRoot
      expand tv theRoot selection
  )
  on trackMadness open do
  (
      initTreeView tv ilTv
      updateTree()
      
  )
  on tv NodeClick theNode do
  (
      nodePath.text = theNode.fullpath
  )
  on update pressed do
  (
      
      updateTree()
      
  )

)
tkm= newrolloutfloater “Track Maddness” 300 500
addrollout trackMadness tkm

2 Replies

Best is to use an array to store the subanims and build the treeview nodes from there:

(
-- Fill array with 3 subanims (Pos, Rot and Scale)
local arrSubanims = #($Box01[3][1], $Box01[3][2], $Box01[3][3])

-- Reset treeview
tv.nodes.clear()

-- Add all subanims
for i = 1 to arrSubanims.count do
(
    theRoot = tv.Nodes.add()
    theRoot.text = arrSubanims[i].name
    -- Store array index in tag property
    theRoot.tag = i
)

on tv NodeClick theNode do
(
    -- Retrieve array index from tag property
    format "Subanim : %
" arrSubanims[theNode.tag]
)
)
  • Martijn

Thanks Martijn, I think ill have to work on a recursive implementation of your code ( to retrieve every single subanim), I really appreciate your help!

Alfonso Peralta