loonghao / photoshop-python-api

Python API for Photoshop.
https://loonghao.github.io/photoshop-python-api/
MIT License
598 stars 68 forks source link

How to import data group txt file and export data group as file #326

Open benjamenhe opened 7 months ago

benjamenhe commented 7 months ago

Hello. I need to use photoshop's import data group and export data group api, but I can't find this, I have an error in photoshop js code writing. Can you help me ? Many thanks

My code: with Session(action="new_document") as ps:

ps.app.load(psd_path)

Import a dataset from a text file

ps.app.activeDocument.importDataSets(data_path, eraseAll=True)

Export the dataset with specific file naming rules

    file_naming_rules = [
        constants.FileNamingComponent.NONE,
        constants.FileNamingComponent.DATASET_NAME,
        constants.FileNamingComponent.NONE,
        constants.FileNamingComponent.NONE,
        constants.FileNamingComponent.NONE,
        constants.FileNamingComponent.NONE,
        constants.FileNamingComponent.LOWERCASE_EXTENSION,
    ]

    ps.app.activeDocument.exportDataSets(export_folder, fileNamingRules=file_naming_rules)

Code error: NameError: Name importDataSets not found AttributeError: module 'photoshop.api.constants' has no attribute 'FileNamingComponent'