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.