3dsmax , 3ds max nested layers hierarchy


3ds max nested layers hierarchy

Question:

Tag: 3dsmax

how can one enumerate hierarchy of nested layers using max 2015 sdk. Example: I have 3 layers named simply "1","2" and "3". 1 and 2 are at the root and 3 belongs in to 1.

How to find out this information using sdk.

I can find a layer where a node belongs:

layer = (ILayer*)(node->GetReference(NODE_LAYER_REF));

In the ILayer interface, I cannot find any information about it's parent. I can get some "extended" (?) properties of the layer:

props = (ILayerProperties*)layer->GetInterface(LAYERPROPERTIES_INTERFACE);

There isn't any relevant information to my problem either.

I can access layer manager:

            manager = (ILayerManager*) GetCOREInterface()->GetScenePointer()->GetReference(10);// don't remember where did I dig out the magic number 10

Here I can enumerate all layers by index, but not by hierarchy.

Any help would be appreciated. Thanks.

Milan


Answer:

The documentations says this:

Iterating over Layers by Index: The IFPLayerManager class is also an interface class that manages scene layers in 3ds Max. This class however is a function published interface, and thus is quite different from the previously discussed layer manager. This class is the C++ interfaces to the MAXScript LayerManager class. This class has a useful method fro returning a layer by integer index. Thus you can iterate over scene layers without knowing the names of the layers. To get a pointer to this object you call the GetCOREInterface() function.

IFPLayerManager* layer_manager = static_cast< IFPLayerManager*> GetCOREInterface( LAYERMANAGER_INTERFACE);

The LAYERMANAGER_INTERFACE identifies the IFPLayerManager interface. With the resulting pointer you can get a scene layer by integer index.

ILayerProperties* hLayer = layer_manager->getLayer(i);

This IFPLayerManager::getLayer() method returns a ILayerProperties pointer which has much less functionality than ILayer.

To get an ILayer pointer you can get a pointer to any object on that layer, and extract the ILayer pointer from it.

The ILayerProperties class has functions for child\parent layers:

virtual ILayerProperties* getChildLayerProperties  ( int  n ) const 

pure virtual

Remarks Returns a pointer to the Nth child Layer properties for this layer. Parameters: int n
The index of the child layer properties. Returns Returns a pointer to the Nth child layer properties.

virtual ILayerProperties* getParentLayerProperties  (  ) const 
 pure virtual  

Remarks Returns the parent Layer. This could be NULL meaning the layer is at the top level.

Which means you can loop through all by index, then check if it's a parent layer, if it is then loop through all it's child layers, then move on to the next one.

These functions are documented in the 'ILayerProperties Class Reference' in the 3dsmax SDK documentation.


Related:


Convert 3D models to patent digrams [closed]


3d,3dsmax,3ds
I want to convert 3dsmax file to patent diagrams in different perspectives. I am new to 3dsmax, and i want to know if there is any method to export it to line drawings like the ones that is available in patents

Any Button to Save Position and Rotation in Animation 3Ds Max


3dsmax
I have a problem in 3ds max. I build an animation based on bone with some controllers. Let say I have an arm controller (please see the attached image) and I want it to be animated from frame A, B, and C. http://tinypic.com/r/11i08iq/8 From A to B, I animated the...

3ds max nested layers hierarchy


3dsmax
how can one enumerate hierarchy of nested layers using max 2015 sdk. Example: I have 3 layers named simply "1","2" and "3". 1 and 2 are at the root and 3 belongs in to 1. How to find out this information using sdk. I can find a layer where a...

Pass by value / reference performance comparison in Maxscript?


performance,3dsmax,maxscript
How does it affect efficiency in Maxscript?. Maxscript is a slow one, but i wonder how much does it affect? I tried this script, it took a lot of time to execute the operations in the array, but later on the call to functions were fast returning 0 to the...

Safe frame calculation


3d,3dsmax
How safe frame is calculated in 3ds Max. I want to know the relationship between Viewport width and height, Render width and height(aspect ratio) in the calculation of safe frame width and height. My final goal is to find the distance between top left corner of the plane and top...