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

Understanding the DOM

Engaged ,
Dec 07, 2020 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]);

 

TOPICS
Scripting

Views

349

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
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 07, 2020 Dec 07, 2020

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: t
...

Votes

Translate

Translate
Engaged ,
Dec 07, 2020 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"
};

  

Votes

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
community guidelines
Community Expert ,
Dec 07, 2020 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

 

Votes

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
community guidelines
Engaged ,
Dec 09, 2020 Dec 09, 2020

Copy link to clipboard

Copied

LATEST

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.

Votes

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
community guidelines