Skip to main content
Flowgun
Inspiring
December 8, 2025
Answered

How to set default Fill to a gradient using scripting?

  • December 8, 2025
  • 1 reply
  • 134 views

Hello everyone,
I want to write a script that for whatever fill color I have selected, it would create a gradient that goes from 100% to 0% of that same color. I kinda successfully done it with the help of chatGPT, but the code keeps on creating new gradient swatches every time, piling up in the swatches panel.

Is there a way to place the gradient directly into the defaultFill without using swatches? I tried giving the swatch a name, and then deleting it before recreating another with the same name, but that also removes the color from items using it (they turn to black). Weirdly enough, when I delete the swatch from the UI, that doesn't do that. 

Any help would be appreciated...

Correct answer CarlosCanto

Indeed, I couldn't delete the swatch without deleting the gradient.

 

Record an Action to delete the swatch, then have the script run the action. It's a bit inconvenient but it works

1 reply

CarlosCanto
Community Expert
CarlosCantoCommunity ExpertCorrect answer
Community Expert
December 9, 2025

Indeed, I couldn't delete the swatch without deleting the gradient.

 

Record an Action to delete the swatch, then have the script run the action. It's a bit inconvenient but it works