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

How to set gradient/pattern by name to the default Fill?

Contributor ,
Dec 01, 2025 Dec 01, 2025

Hello everyone,
I'm trying to write a script that changes the default fill content. It is pretty straightforward for RGBColor and CMYKColor (and NONE), but I'm finding difficulty finding a way to place a gradient or a fill by name (they exist in the swatches so a if there's a way to set a swatch to the fill can be a solution.

TOPICS
How-to , Scripting
52
Translate
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

correct answers 1 Correct answer

Contributor , Dec 01, 2025 Dec 01, 2025

this worked

    var doc = app.activeDocument;
    var tmp = doc.pathItems.add();
    tmp.setEntirePath([[0,0],[0,0]]);
    tmp.filled = true;
    var sw = doc.swatches.getByName(patternName);
    tmp.fillColor = sw.color;
    doc.defaultFilled = true;
    doc.defaultFillColor = tmp.fillColor;
    tmp.remove();
Translate
Adobe
Contributor ,
Dec 01, 2025 Dec 01, 2025
LATEST

this worked

    var doc = app.activeDocument;
    var tmp = doc.pathItems.add();
    tmp.setEntirePath([[0,0],[0,0]]);
    tmp.filled = true;
    var sw = doc.swatches.getByName(patternName);
    tmp.fillColor = sw.color;
    doc.defaultFilled = true;
    doc.defaultFillColor = tmp.fillColor;
    tmp.remove();
Translate
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