3dsmaxmaxscript

3ds max script make group by parents


Hy! I am not so well experienced with max script, but I have written/modified an exporter that can export single meshes, groups using the built in obj exporter.

Now I want to select parents(usually theese are not 3Dobjects) in hierarchy and convert them to groups with their parrents, and I have no idea how exatly I should do it. Any suggestions maybe script code you know?

Thanks in advanced


Solution

  • You can get the parent of any object in the scene by using

    myParent = $myObject.parent
    

    And you can use the following line to get all of a parent's children:

    myParent.children
    

    so in combination with select and group methods, you can do the following:

    myParent = $myObject.parent
    select myParent
    selectmore myParent.children
    group (GetCurrentSelection() as array) name:"myGroup"
    

    And now you have a group named myGroup containing a parent object and all of its children. With a little tinkering you can turn this into a method and also iterate through every object in your scene. Hope this helps you.