Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
1

Script to Check for Existing DataSets? (Variables, Data-driven Graphics)

Community Expert ,
Mar 02, 2025 Mar 02, 2025

Copy link to clipboard

Copied

I have been extending the original code from the late Mike Hale here:

 

https://community.adobe.com/t5/photoshop-ecosystem-discussions/using-datasets/td-p/2665594/page/2

 

I am currently using a confirm dialog for the user to OK to run the script, which relies on them knowing that the file already has Variables/Data Sets defined.

 

Ideally, the script would check for the existence of Data Sets and terminate if none were found.

 

Unfortunately, the action manager code is beyond me, so I was wondering if anyone knew how to check for this.

TOPICS
Actions and scripting , macOS , Windows

Views

173
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Mar 06, 2025 Mar 06, 2025

Copy link to clipboard

Copied

I couldn’t identify the information via AM-code so far. 

Reading the image-file itself might offer an approach (if the image has been saved since the creation of the datasets at least). 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 06, 2025 Mar 06, 2025

Copy link to clipboard

Copied

@c.pfaffenbichler - Thank you for your time, I appreciate that this is a rather esoteric niche for scripting.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 07, 2025 Mar 07, 2025

Copy link to clipboard

Copied

I suspect UXP Scripting might offer a better handle on the feature … but I don’t know. 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 09, 2025 Mar 09, 2025

Copy link to clipboard

Copied

Tried UXP, can apply but not get a Deta Set. And it needs to specify the name exactly when applying, not the index.

const { app, core, action } = require('photoshop') ;

try {
  await core.executeAsModal(async () => 
    {
      const dataSetName = 'set 1' ;
      const result = await action.batchPlay(
        [
          {
            _obj: 'apply',
            _target: [
              {
                _name: dataSetName,
                _ref: 'dataSetClass'
              }
            ]
          }
        ], 
        
        {}
      ) ;
  
      app.showAlert(JSON.stringify(result)) ;
    }, 
    
    {
      commandName: 'Apply Dataset'
    }
  ) ;
} catch(e) {
  app.showAlert(e) ;
}

 

This is similar to the structure of Workspace, which can select but not get.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 09, 2025 Mar 09, 2025

Copy link to clipboard

Copied

Thank you for trying!

 

Looks like I'll need to stick with the confirm prompt and put the onus on the user (not to mention that rewriting this script in UXP isn't possible for me).

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 09, 2025 Mar 09, 2025

Copy link to clipboard

Copied

LATEST

Applying to a non-existent dataset will return [{}] in the result.

If you know the name of the dataset, you can determine whether it succeeded or was ignored by trying to apply it. In other words, it is possible to know indirectly whether the dataset exists or not.

 

If it succeeds, the result will look like this.

 

[
  {
    "_obj": "apply",
    "_target": [
      {
        "_ref": "dataSetClass",
        "_name": "set 1"
      }
    ]
  }
]

 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines