Copy link to clipboard
Copied
Hello,
Is there a possibility to count (only) all sublayers in a given layer?
CountLayers from LayerSuite is only counting top-level layers and that isn't good enough.
Thanks in advance!
Edit: I am using CS SDK 5.
Copy link to clipboard
Copied
Hello,
I've managed to solve it by using GetNextPreorderLayer function within AILayerSuite.
Thanks to all who have read it/or gave it a thought.
Copy link to clipboard
Copied
Hi,
I wonder if you can give us a more detailed instruction? I downloaded SDK but still gotta learn a lot to understand this.
Many thanks
Copy link to clipboard
Copied
ASErr result = kNoErr;
try {
AILayerHandle layer;
result = sAILayer->GetNthLayer(layerIndex, &layer);
aisdk::check_ai_error(result);
AIArtHandle art;
AIArtSet artSet = NULL;
result = sAIArtSet->NewArtSet(&artSet);
aisdk::check_ai_error(result);
result = sAIArtSet->LayerArtSet(layer, artSet);
aisdk::check_ai_error(result);
ai::int32 count;
result = sAIArtSet->CountArtSet(artSet, &count);
int countSublayers = 0;
// ignore first art, it is a layer art
for ( ai::int32 i = 1; i < count; i++ )
{
sAIArtSet->IndexArtSet(artSet, i, &art);
AIBoolean isLayerGroup;
result = sAIArt->IsArtLayerGroup(art, &isLayerGroup);
aisdk::check_ai_error(result);
if ( isLayerGroup )
countSublayers++;
}
std::cout << "\tCOUNT SUBLAYERS = " << countSublayers << "\n";
} catch (ai::Error& ex) {
result = ex;
}