Main Page Contents

Nebula2 Named Object Hierarchy Viewer

@section NMaxHowtoExposeNOHOverview Overview

This tutorial demonstrates how to create a Nebula2 Named Object Hierarchy with MaxScript and TreeView ActiveX control. It is a simple demonstration of the Nebula2 3DS Max Expose plugin but you will get to know that it is powerful and can extend it in a various ways for your purpose.

The MaxScript source code of this tutorial nohviewer_demo.ms can be found in '$nebula2/code/contrib/nmax/maxscripts/ directory.

You can open and run the script in Utilities > MAXScript panel of 3DS Max. The following image is the result of the script.

nohviewer01.png
@section NMaxHowtoExposeNOHMaxScript MaxScript

The following is MaxScript code for this tutorial:

rollout NOHTreeViewer "Nebula Object Viewer" width:355 height:540
(
    ActiveXControl tv "MSComctlLib.TreeCtrl.2" pos:[5,52] width:343 height:478
    
    function addChild parentTreeNodeIndex parentNodeName objectName = 
    (
        cmd = parentNodeName + ".getchildren"
        children = nebula2.callv cmd
    
        for i in children do
        (
            cmd = i + ".getname"
            objName = nebula2.callv cmd
    
            o = tv.nodes.add parentTreeNodeIndex 4 "" objName[1]
            
            addChild o.index i objName
        )
    )

    on NOHTreeViewer open do
    (
        nebula2.sel "/"
        root = tv.nodes.add()
        root.text = "/"
        
        r = nebula2.callv ".getchildren"
        addChild root.index root.text root.text
    )
)

rollpage = newRolloutFloater "Nebula Object Viewer" 355 540
addRollout NOHTreeViewer rollpage 

Next Step by Step section will shows you that how the above script works.

@section NMaxHowtoExposeNOHStepByStep Step By Step

rollout NOHTreeViewer "Nebula Object Viewer" width:355 height:540
(
This is the rollout to be created when the script is executed. It will display the title "Nebula Object Viewer". The variable NOHTreeViewer will be used later on to create a dialog out of the rollout definition.

ActiveXControl tv "MSComctlLib.TreeCtrl.2" pos:[5,52] width:343 height:478
This code creates a TreeView ActiveX control in the rollout.

    function addChild parentTreeNodeIndex parentNodeName objectName = 
    (
This function recursively collects Nebula objects and add it for a child node of the TreeView.

        cmd = parentNodeName + ".getchildren"
        children = nebula2.callv cmd
First, the function collects all child objects of the given Nebula objects by calling 'getchildren' Nebula2 script command.

        for i in children do
        (
            cmd = i + ".getname"
            objName = nebula2.callv cmd
For each collected child, we get the each of the child object's name.

            o = tv.nodes.add parentTreeNodeIndex 4 "" objName[1]
Add retrieved name of the object to the TreeView for its item.

            addChild o.index i objName
        )
We recursively call addChild to collect all Nebula objects and add it to TreeView.

    on NOHTreeViewer open do
    (
When the rollout is opening (this is when the CreateDialog function is called)...

        nebula2.sel "/"
        root = tv.nodes.add()
        root.text = "/"
First, we add root node '/' for the TreeView item cause Nebula uses '/' for its root node.

        r = nebula2.callv ".getchildren"
This code collects all child objects of the root node.

        addChild root.index root.text root.text
    )
And we call addchild script function to recursively collect all child objects and add it for the TreeView item.

rollpage = newRolloutFloater "Nebula Object Viewer" 355 540
addRollout NOHTreeViewer rollpage 
Finally, we create a new Dialog using the rollout definition.

@section NMaxHowtoExposeNOHSeeAlso See Also

See Nebula2 3DS Max Expose Commands Reference for supported commands.

If you want to know more about MaxScript and supported TreeView ActiveX control, find the followings in a MaxScript Reference. (only available on 3DS Max7)