Resource

Resource Basics

Resource Name Create Catalog Labels for Areas
Resource Version 2.0
Category Catalog
Downloads 1173
Release Date 1/10/2016 1:53:17 PM
 

Resource Details

Description This script will find areas in the catalog and if there's a relevant name for the area then a catalog label is create and linked to the area.

You have the option to either process *all* areas in the catalog or just those for the selected thumbnails.

Note; if a catalog with the same name already exists in the People, Objects, or Miscellaneous category then that label will be used and linked.
Installation Instructions Download the script to your hard drive
Usage Instructions 1. Click Tools->Scripter
2. Load the downloaded script
3. Run the script by clicking the Run icon in the toolbar
Changes in this version n.a.
Special Requirements
 

Author Information

Author Name IDimager Support
 

Script

{
  Version 2.0; Added option to process all areas or just
               those areas for the selected thumbnails
}
  procedure HandleAreas(AAreas: TCatalogAreas);
  var
    i, ALinked, ACreated: Integer;
    AProp: TCatalogItemProp;
  begin
    ALinked := 0;
    ACreated := 0;
    for i := 0 to AAreas.Count - 1 do
    begin
      // unlinked and with a relevant caption?
      if (AAreas.Items[i].PropGUID = '') and
         (not WideSameText(AAreas.Items[i].Caption, Translate('(New Area)')))
      then
      begin
        // unlinked area... create a catalog for it but only if it has a name
        AProp := TCatalogItemProp.Create(nil);
        if (not PublicCatalog.FindPropByName(AAreas.Items[i].Caption, AProp, '{750A8DF3-1242-4B5D-90F4-4C1E4FCBF110}', True)) and  // people
           (not PublicCatalog.FindPropByName(AAreas.Items[i].Caption, AProp, '{D37056E1-AAD7-4D77-A884-B86095D224E3}', True)) and  // others
           (not PublicCatalog.FindPropByName(AAreas.Items[i].Caption, AProp, '{2AD216A8-9A52-482B-87A1-547F0D6C6F6B}', True))   // objects
        then
        begin
          // create a People label for the caption
          AProp.GUID := NewGUID;
          AProp.PropName := AAreas.Items[i].Caption;
          PublicCatalog.StorePropToDatabase(AProp, '{750A8DF3-1242-4B5D-90F4-4C1E4FCBF110}', False);
          Inc(ACreated);
        end;

        // link to the catalog label
        AAreas.Items[i].PropGUID := AProp.GUID;
        PublicCatalog.UpdateArea(AAreas.Items[i]);
        Inc(ALinked);

        AProp.Free;
      end;
    end;

    Say('Finished' + CrLf2 +
        'Created: ' + IntToStr(ACreated) + CrLf +
        'Linked: ' + IntToStr(ALinked) + CrLf +
        ''
        );
  end;

var
  AAreas: TCatalogAreas;
  i: Integer;
begin
  AAreas := TCatalogAreas.Create(TCatalogArea, '');
  if Ask('Are you sure you want to link all unlinked areas to Catalog Labels?') then
    PublicCatalog.EnumAllAreas(AAreas)
  else if Selected.Count > 0 then
  begin
    if Ask('Would you like to link all unlinked areas to Catalog Labels for the currently selected images?') then
    for i := 0 to Selected.Count - 1 do
      PublicCatalog.EnumAreasForImage(Selected.Items[i], AAreas);
  end;

  if AAreas.Count > 0 then
    HandleAreas(AAreas)
  else
    Say('No areas to process');
  AAreas.Free;
end;