3 Replies Latest reply on Jun 24, 2016 2:59 AM by Toto RoToTO

    How to find embeded art in document

    patilpralhad

      Hi,

       

      I want to warn the user if there are any linked images in the AI document. I tried to find placed arts using MatchinArt suite and after that I'm not sure how to proceed to find embedded art.

       

      Below is code snippet to show what I'm doing. I'm using C++ to achieve this task by reading file specification.

       

      My Question here is, Is there any particular property we need to check for the embedded images.

       

      AIArtHandle **artStore = NULL;

      ai::int32 artCount = 0;

      AIMatchingArtSpec spec[2] = {{kPlacedArt,0,0},{kRasterArt,0,0}};

      sAIMatchingArt->GetMatchingArt(spec,2,&artStore,&artCount);

      if(artStore != NULL)

           {

           for(int i = 0; i< artCount; i++)

           {

                  AIArtHandle artHandle = (*artStore)[i];

                  ai::UnicodeString filePath;

                  sAIPlaced->GetPlacedFilePathFromArt(artHandle,filePath);

       

                  if(!filePath.empty())

                  {

                       documentHasLinkedImages = true;

                       break;

                  }

           }

        }

       

      Thanks for your help,

      Pralhad

        • 1. Re: How to find embeded art in document
          Toto RoToTO Level 3

          Here is a sample:

           

          AIArtHandle **matchingArt = NULL;

          ai::int32 numMatches;

          error = sAIMatchingArt->GetSelectedArt(&matchingArt, &numMatches);

          aisdk::check_ai_error(error);

           

          for (ai::int32 i = 0; i < numMatches; i++){

           

                AIArtHandle art;

                art = (*matchingArt)[i];

           

               if (type == kTextFrameArt) {                                   //or any other art type!

               // do whatever you want with that art!

               ..........

               .........

               }

          }

           

          Thomas

          • 2. Re: How to find embeded art in document
            btempleton1982 Level 2

            I think they're looking for specifically embedded art. But many art types when they're embedded turn into group art with other art types contained. Maybe the Raster art suite has some functions that'd be useful?

            • 3. Re: How to find embeded art in document
              Toto RoToTO Level 3

              AIArtHandle **artStore = NULL;

              ai::int32 artCount = 0;

                             

              AIMatchingArtSpec spec;

              spec.type = kRasterArt;

              spec.whichAttr = 0;

              spec.attr = 0;

               

              // Ignore the error, we could be searching when there is no document

              // and we don't want that error reported, just let the null artStore

              // take over and silently quit the routine.

              sAIMatchingArt->GetMatchingArt( &spec, 1, &artStore, &artCount );

                             

              if ( artStore != NULL ){

                   for ( ai::int32 x = 0; x < artCount; x++ ){

                    AIArtHandle artHandle = (*artStore)[x];

                                 

                   AIRasterLink rasterLink

                   sAIRaster->GetRasterLink(artHandle, &rasterLink);    

               

                      //check link states first.

                      if(rasterLink.linkstate == kAIRasterEmbedded)

                      {   

                          //Do something here

                      }

                      else if(_rasterLink.linkstate == kAIRasterLinked)

                      {        

                            //Do something else here

                      }

                   }

              }

              This should help.