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

Problems with selection.fill/pathItem.fillPath -- Ps CS6, JSX, Windows

Guest
Jan 30, 2013 Jan 30, 2013

Hi all,

First post here

I've started lately to play around with extended javascript (jsx) scripting on Photoshop CS6 (using 32-bit version on Windows 7 Ultimate).

I've had much trouble with 'fill' commands.

This one here gives me an

Error 1200: Internal error

Line: 5

->  app.activeDocument.selection.fill( myColor );

var myColor = new SolidColor();

app.documents.add( 100, 100, 72, "tmp", NewDocumentMode.RGB, DocumentFill.TRANSPARENT );
app.activeDocument.selection.selectAll();
app.activeDocument.selection.fill( myColor );

I read somewhere that giving all the parameters to the fill method could solve it, but it gave me the same result.

I've also tried the fillPath method from PathItem, but it gave also an internal error (1200).

var myColor = new SolidColor();

var docRef = app.documents.add(500, 700, 72, "Simple Line")

var lineArray = new Array()

lineArray[0] = new PathPointInfo

lineArray[0].kind = PointKind.CORNERPOINT

lineArray[0].anchor = Array(100, 100)

lineArray[0].leftDirection = lineArray[0].anchor

lineArray[0].rightDirection = lineArray[0].anchor

lineArray[1] = new PathPointInfo

lineArray[1].kind = PointKind.CORNERPOINT

lineArray[1].anchor = Array(150, 200)

lineArray[1].leftDirection = lineArray[1].anchor

lineArray[1].rightDirection = lineArray[1].anchor

lineArray[2] = new PathPointInfo

lineArray[2].kind = PointKind.CORNERPOINT

lineArray[2].anchor = Array(100, 200)

lineArray[2].leftDirection = lineArray[2].anchor

lineArray[2].rightDirection = lineArray[2].anchor

var lineSubPathArray = new Array()

lineSubPathArray[0] = new SubPathInfo()

lineSubPathArray[0].operation = ShapeOperation.SHAPEXOR

lineSubPathArray[0].closed = true

lineSubPathArray[0].entireSubPath = lineArray

var myPathItem = docRef.pathItems.add("A Line", lineSubPathArray)

myPathItem.fillPath(myColor, ColorBlendMode.NORMAL, 100, true, 0.0, true, true)

This example only works if there is not parameters at all given to fillPath (it's filling with black).

Does anyone know how I could work around this? Is it a known bug?

Thanks all!

TOPICS
Actions and scripting
3.4K
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

Community Expert , Jan 30, 2013 Jan 30, 2013

Hello Radsvid789,

your script:

var myColor = new SolidColor();

app.documents.add( 100, 100, 72, "tmp", NewDocumentMode.RGB, DocumentFill.TRANSPARENT );

app.activeDocument.selection.selectAll();

app.activeDocument.selection.fill( myColor );

cannot run.

At first you must define the new SolidColor e.g. like this:

var myColor = new SolidColor();

myColor.rgb.red = myColor.rgb.green = myColor.rgb.blue = 0;

Try this one:

var myColor = new SolidColor();

myColor.rgb.red = myColor.rgb.green = myColor.rgb.blue = 0;

app

...
Translate
Adobe
Community Expert ,
Jan 30, 2013 Jan 30, 2013

Hello Radsvid789,

your script:

var myColor = new SolidColor();

app.documents.add( 100, 100, 72, "tmp", NewDocumentMode.RGB, DocumentFill.TRANSPARENT );

app.activeDocument.selection.selectAll();

app.activeDocument.selection.fill( myColor );

cannot run.

At first you must define the new SolidColor e.g. like this:

var myColor = new SolidColor();

myColor.rgb.red = myColor.rgb.green = myColor.rgb.blue = 0;

Try this one:

var myColor = new SolidColor();

myColor.rgb.red = myColor.rgb.green = myColor.rgb.blue = 0;

app.documents.add( 100, 100, 72, "tmp", NewDocumentMode.RGB, DocumentFill.TRANSPARENT );

app.activeDocument.selection.selectAll();

app.activeDocument.selection.fill( myColor );

The same problem in your second example.

Have fun

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
Guest
Jan 30, 2013 Jan 30, 2013

Thanks, it does work indeed!

From what I read in the documentation, thought rgb colors were at 255 as their default color!

Seems something was missing there!

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
Guest
Jan 30, 2013 Jan 30, 2013

It turns out that with your answer, and using all but the last parameters of fillPath, the program does not complain anymore.

Not sure why, but the fillPath parameters do not seem to be very "optional".

Thanks again fr your answer!

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
Community Expert ,
Jan 30, 2013 Jan 30, 2013

You're welcome.

Additional you can the foreground color use to paint or fill or stroke selections.

var myColor = app.foregroundColor;

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
Guest
Jan 30, 2013 Jan 30, 2013

pixxxel schubser wrote:

You're welcome.

Additional you can the foreground color use to paint or fill or stroke selections.

var myColor = app.foregroundColor;

Oh, that's good to know!

Thanks again!

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
Guru ,
Jan 30, 2013 Jan 30, 2013

SolidColor does default to white so you can do things like

var myColor = new SolidColor;

alert(myColor.rgb.hexValue);

But it is really not that useful to use the defalut because it doesn't work with all Photoshop methods or properties. For example

myColor = new SolidColor();

backgroundColor = myColor;

will throw the same internal error message.

So if the color had be set someway like

myColor.rgb.hexValue = 'FFFFFF';

the code in the first posts works.

As far as fillPath parameters goes I think the guide is wrong and there should be just one bracket around all the arguments because it does seem to be all or nothing.

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
Community Expert ,
Jan 31, 2013 Jan 31, 2013

Hello Michael L Hale,

Michael L Hale wrote:

… But it is really not that useful to use the defalut because it doesn't work with all Photoshop methods or properties. For example

myColor = new SolidColor();

backgroundColor = myColor;

will throw the same internal error message …

understand fun?


//MakeNewDocFillWithBGColor.jsx

var Syntax = false;

var docRef = app.documents.add(300, 300, 72, null, NewDocumentMode.RGB, DocumentFill.TRANSPARENT);

var selRef = app.activeDocument.selection;

var myAlert = null;

try {

    myColor = new SolidColor();

    backgroundColor = myColor;

    Syntax = true;

    selRef.fill( backgroundColor, ColorBlendMode.NORMAL, 100, false );

    myAlert = "No No No";

    }

catch (e) {

    $.sleep (999);

    if (Syntax == false) {

        var MakeSyntax = true;       

        myColor = new SolidColor();

        backgroundColor.rgb.hexValue = myColor.rgb.hexValue;

        selRef.fill( backgroundColor, ColorBlendMode.NORMAL, 100, false );

        myAlert = "Script runs, if MakeSyntax == "+MakeSyntax;

        }

    }

alert(myAlert,"Have Fun")

greetings


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
Guest
Feb 01, 2013 Feb 01, 2013

Yeah, that would work for development/debugging purpose, but I hardly see this technique as a standard usage. Just defining a colour every time you need one is perfectly acceptable IMO.

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
Community Expert ,
Feb 01, 2013 Feb 01, 2013

Oh no, what have I done?

That should be a joke. As response to the contribution of Michael L Hale.

Michael L Hale wrote:

… For example

myColor = new SolidColor();

backgroundColor = myColor;

will throw the same internal error message …

He has right. A solid color hex value is default 'FFFFFF'

But you can pass the default value to the background color and fill the document with the correct syntax like this:

myColor = new SolidColor();

backgroundColor.rgb.hexValue = myColor.rgb.hexValue;

app.activeDocument.selection.fill( backgroundColor, ColorBlendMode.NORMAL, 100, false );

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
Guest
Feb 05, 2013 Feb 05, 2013
LATEST

Clearly, Adobe programmers should stop smoking wierd things...

Message was edited by: Radsvid789 - Fixed a typo

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