Understanding the DOM

Participant ,
Dec 07, 2020

Copy link to clipboard

Copied

I'm just trying to understand the DOM and I'm not sure how to do this. 

I was just trying to take a selected image and apply the effect innerGlowSettings with a grey color to it. 

I'm able to take the selection and apply most of the settings with the exception of the color. When I look at the DOM it shows a property of effectColor and the type is Swatch(how do you understand that?). The description shows I can add it multiple ways, I just want 50% grey. How do I know how to apply this property? 

 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#InnerGlowSetting.html#d1e397456

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Swatch.html#d1e67936

 

This was my attempt but unsuccessful. Thank you for any insight.

 

app.selection[0].transparencySettings.innerGlowSettings.applied = true;
app.selection[0].transparencySettings.innerGlowSettings.opacity = 100;
app.selection[0].transparencySettings.innerGlowSettings.spread = 0;
app.selection[0].transparencySettings.innerGlowSettings.source = (InnerGlowSource.CENTER_SOURCED);
app.selection[0].transparencySettings.innerGlowSettings.blendMode = (BlendMode.NORMAL);
app.selection[0].transparencySettings.innerGlowSettings.opacity = 100;
app.selection[0].transparencySettings.innerGlowSettings.spread = 0;
app.selection[0].transparencySettings.innerGlowSettings.size = 0;
app.selection[0].transparencySettings.innerGlowSettings.effectColor = (Swatch = [0,0,0,40]);

 

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

Hi @davidn5918184,

The DOM documentation seems to be misleading, I was not able to get it work with an array argument as well. However, you can do it by first adding your color if it's not already added and then using it. Try the following

var col = app.documents[0].colors.itemByName("My Gray")
if(!col.isValid)
	col = app.documents[0].colors.add({colorValue:[0,0,0,40], name:"My Gray", space:ColorSpace.CMYK})
	
app.selection[0].transparencySettings.innerGlowSettings.properties = {

    applied: true,
    opacity: 100,
    spread: 0,
    source: (InnerGlowSource.CENTER_SOURCED),
    blendMode: (BlendMode.NORMAL),
    opacity: 100,
    spread : 0,
    size : 0,
    effectColor: col
};

-Manan

 

TOPICS
Scripting

Views

58

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Understanding the DOM

Participant ,
Dec 07, 2020

Copy link to clipboard

Copied

I'm just trying to understand the DOM and I'm not sure how to do this. 

I was just trying to take a selected image and apply the effect innerGlowSettings with a grey color to it. 

I'm able to take the selection and apply most of the settings with the exception of the color. When I look at the DOM it shows a property of effectColor and the type is Swatch(how do you understand that?). The description shows I can add it multiple ways, I just want 50% grey. How do I know how to apply this property? 

 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#InnerGlowSetting.html#d1e397456

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Swatch.html#d1e67936

 

This was my attempt but unsuccessful. Thank you for any insight.

 

app.selection[0].transparencySettings.innerGlowSettings.applied = true;
app.selection[0].transparencySettings.innerGlowSettings.opacity = 100;
app.selection[0].transparencySettings.innerGlowSettings.spread = 0;
app.selection[0].transparencySettings.innerGlowSettings.source = (InnerGlowSource.CENTER_SOURCED);
app.selection[0].transparencySettings.innerGlowSettings.blendMode = (BlendMode.NORMAL);
app.selection[0].transparencySettings.innerGlowSettings.opacity = 100;
app.selection[0].transparencySettings.innerGlowSettings.spread = 0;
app.selection[0].transparencySettings.innerGlowSettings.size = 0;
app.selection[0].transparencySettings.innerGlowSettings.effectColor = (Swatch = [0,0,0,40]);

 

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

Hi @davidn5918184,

The DOM documentation seems to be misleading, I was not able to get it work with an array argument as well. However, you can do it by first adding your color if it's not already added and then using it. Try the following

var col = app.documents[0].colors.itemByName("My Gray")
if(!col.isValid)
	col = app.documents[0].colors.add({colorValue:[0,0,0,40], name:"My Gray", space:ColorSpace.CMYK})
	
app.selection[0].transparencySettings.innerGlowSettings.properties = {

    applied: true,
    opacity: 100,
    spread: 0,
    source: (InnerGlowSource.CENTER_SOURCED),
    blendMode: (BlendMode.NORMAL),
    opacity: 100,
    spread : 0,
    size : 0,
    effectColor: col
};

-Manan

 

TOPICS
Scripting

Views

59

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Dec 07, 2020 0
Participant ,
Dec 07, 2020

Copy link to clipboard

Copied

and now I see I can combine them, and I can use the black swatch but I don't know how to build it in CMYK. Mostly I'm interested in how by looking a the DOM I would know how to do it as CMYK.

app.selection[0].transparencySettings.innerGlowSettings.properties = {

    applied: true,
    opacity: 100,
    spread: 0,
    source: (InnerGlowSource.CENTER_SOURCED),
    blendMode: (BlendMode.NORMAL),
    opacity: 100,
    spread : 0,
    size : 0,
    effectColor: "Black"
};

  

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 07, 2020 0
Adobe Community Professional ,
Dec 07, 2020

Copy link to clipboard

Copied

Hi @davidn5918184,

The DOM documentation seems to be misleading, I was not able to get it work with an array argument as well. However, you can do it by first adding your color if it's not already added and then using it. Try the following

var col = app.documents[0].colors.itemByName("My Gray")
if(!col.isValid)
	col = app.documents[0].colors.add({colorValue:[0,0,0,40], name:"My Gray", space:ColorSpace.CMYK})
	
app.selection[0].transparencySettings.innerGlowSettings.properties = {

    applied: true,
    opacity: 100,
    spread: 0,
    source: (InnerGlowSource.CENTER_SOURCED),
    blendMode: (BlendMode.NORMAL),
    opacity: 100,
    spread : 0,
    size : 0,
    effectColor: col
};

-Manan

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 07, 2020 1
Participant ,
Dec 09, 2020

Copy link to clipboard

Copied

This works. I'm really trying to figure out how to understand the DOM and script using it but it is so confusing. Thanks for the help.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 09, 2020 0