Skip navigation
vstantic
Currently Being Moderated

Count Sublayers in a layer

Aug 12, 2013 5:40 AM

Tags: #sublayers #sublayer

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.

 
Replies
  • Currently Being Moderated
    Aug 26, 2013 5:18 AM   in reply to vstantic

    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;

    }

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points