Sg2.9
Pattern Swatches
Recent RSS
Pattern Swatches
From:  Keegan Green
Date:  7. September 2007, 05:04

I have a question about working with pattern swatches. I am working on a script (attached) to randomly assign selected objects a color from the documents swatches. I have it working fine with gradient and color swatches but when it attempts to use a pattern swatch. I get the error:

java.lang.NoSuchMethodException: com.scriptographer.ai.Pattern.(int)

The code I tried to use is (among other things):

art.style.fill.pattern = randswatch;

I don't want to simply ignore the pattern swatches, I would really like the script to use them. When running the attached script, select the option to use document swatches and make sure you have pattern swatches in your document to replicate the error.

Anyone else run into this? anyone know how to use pattern swatches in this way?

Thanks in advance. Once I sort this issue, I'll be posting the working script,

Keegan

Re: Pattern Swatches
Date:  7. September 2007, 13:05

Well I would expect randswatch.color to return a patternColor and not null - so it might be a bug..

From what I can tell from the reference art.style.fill.pattern does not exist..
Basically patternColor should work the same as the other colors:

art.style.fill.color = swatch.color

Re: Pattern Swatches
From:  Keegan Green
Date:  10. September 2007, 01:14

Thanks,

Yeah, I thought it would work the same as a color swatch, eg

art.style.fill.color = randswatch.color

and I tried that too, but it creates the same error. Oh well.

Anyone else have any ideas?

Re: Pattern Swatches
Date:  11. February 2013, 17:35

I see this is way out of date, but this seems to work:

myPath.fillColor = document.swatches['Fish Pattern'].color;

Obviously replace “myPath” with the name of your path and “Fish Pattern” with the name of your swatch, pattern or otherwise.

Scripts
08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
Posts
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19
Script of the Moment
Shape Contours V2 26.04.12