Skip to main content
Participant
August 12, 2013
Question

Count Sublayers in a layer

  • August 12, 2013
  • 3 replies
  • 2020 views

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.

This topic has been closed for replies.

3 replies

Participant
August 26, 2013

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;

}

vstanticAuthor
Participant
August 15, 2013

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.

Participant
June 5, 2024

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