Create new portfolio using script?

Post Reply
mjbiggs
Posts: 10
Joined: 01 Oct 10 21:50

Create new portfolio using script?

Post by mjbiggs » 22 Aug 20 8:52

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: 6369
Joined: 13 Sep 03 7:24

Re: Create new portfolio using script?

Post by Hert » 22 Aug 20 9:08

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 which means that users post questions here for other users.
Feature requests, change suggestions, or bugs can be logged in the ticketing system

mjbiggs
Posts: 10
Joined: 01 Oct 10 21:50

Re: Create new portfolio using script?

Post by mjbiggs » 22 Aug 20 9:37

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