Create new portfolio using script?

Post Reply
mjbiggs
Posts: 22
Joined: 01 Oct 10 20:50

Create new portfolio using script?

Post by mjbiggs »

Hello

Is it possible to create a new portfolio using a script? In particular, within Photo Supreme, a new portfolio is easily created in the 'Portfolios' tab by clicking on the '+ New Portfolio' button. How can this action be duplicated in a script?

I have been able to create a new portfolio by using the GUIDs (and procedure CheckPortfolio) as given in the script 'Migrate EM-iView CatalogSets to Portfolio.psc' but I wish to be able to create a new named portfolio with it's own unique GUID(s).

Any help appreciated.
Hert
Posts: 7871
Joined: 13 Sep 03 6:24

Re: Create new portfolio using script?

Post by Hert »

Here's a snipped that creates a portfolio in the catalog;

Code: Select all

var
  APortfolio: TImageModel;
begin
  APortfolio := TImageModel.Create(nil);
  try
    APortfolio.ModelName := 'A scripted portfolio';
    PublicCatalog.StoreModelToDatabase(APortfolio);
    Say('Portfolio ' + APortfolio.ModelName + ' was created');
  finally
    APortfolio.Free;
  end;
end;
A few things to be aware of when you're working with Portfolios using the Object Model:

1. Over the years, a Portfolio have changed name from Model to Album to Portfolio. You'll find traces of all three in the codebase
2. In the first implementation, a Portfolio used to have three levels: portfolio, gallery, collection (and sub collections). Over the years, the Gallery level got eliminated. But in the Object Model that level still exists. Every Portfolio now always has exactly one Gallery. The gallery level is ignored in the User Interface. But be aware that the top level Collections have this (implicit) gallery as the parent, and not the Portfolio.
This is a user-to-user forum. If you have suggestions, requests or need support then please send a message
mjbiggs
Posts: 22
Joined: 01 Oct 10 20:50

Re: Create new portfolio using script?

Post by mjbiggs »

That's great Hert. Just tried your snippet, which does exactly what I wanted. Excellent.

Many thanks for the details regarding the Object Model too. Hadn't really understood the Portfolio-Gallery connection before. And didn't know about the legacy naming either - very useful info - can make more sense of the codebase now.

Many thanks for your help.
Regards
Mike
Post Reply