Itoo Software Forum

Author Topic: Instantiate with parents?  (Read 92 times)

SnipeyX

  • Newbie
  • *
  • Posts: 27
Instantiate with parents?
« on: November 10, 2021, 09:21:13 PM »
Any clever scripting possibility of creating a hierarchy from the RailClone tools Utility so that sequential objects down the length of a linear operator are parented one to the next? I'm building a rope type object and would like one end of the objects to be a rootNode, second object a child of the first, third object a child of the second, etc.

Paul Roberts

  • iToo Software
  • Hero Member
  • *****
  • Posts: 2083
Re: Instantiate with parents?
« Reply #1 on: November 11, 2021, 09:50:16 AM »
Hi,

That's an interesting question. RailClone Tools itself cannot be maxscripted, but it does name the instances it creates in a numeric sequence so you could try selecting them all and running the attached script. The script adds all the instances to an array, orders them alphanumerically, and then creates a hierarchy.

I hope it helps,
Paul
Paul Roberts
iToo Software

SnipeyX

  • Newbie
  • *
  • Posts: 27
Re: Instantiate with parents?
« Reply #2 on: November 11, 2021, 07:16:15 PM »
Nice, thank you! In my specific setup I have 5 objects per chain (a single source spline with hundreds of subsplines for each chain), so I used the code below, but your array sorting is a smart addition, I was just requiring (hoping) the selection would be in the correct right order :)

objs = selection as array
for i=1 to objs.count by 5 do (
      objs[i+1].parent = objs
      objs[i+2].parent = objs[i+1]
      objs[i+3].parent = objs[i+2]
      objs[i+4].parent = objs[i+3]
   )