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

CS5 JS-Apply Transparency Question

New Here ,
Jul 29, 2011 Jul 29, 2011

Copy link to clipboard

Copied

Hello,

I am having trouble applying transparency to some ovals I'm creating with a script. I've used script in the past to apply drop shadows but this seems a little different. I'm trying to apply Feathering and Glows and I just can't seem to figure this out. The current script I am running does some basic document preperation and the ovals are going to be used by the person who builds the page. If you could help me apply the inner glow, hopefully I will be able to figure out the feathering. Thanks for any help in advance.

The Inner Glow Presets:

InnerGlow.png

And the Script:

var myDoc = app.activeDocument; //Set measurement units to inches myDoc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches; myDoc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches; myDoc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin; //Zero out the document myDoc.zeroPoint = [0,0] //Unlock any of the locked layers     boolean myDoc.layers.everyItem().locked=false //Create layer and move it to the bottom, name New Layer, Set color to Charcoal var myLayer = myDoc.layers.add(); myLayer = myLayer.move(LocationOptions.atEnd) myLayer.name = "New Layer"; myLayer.layerColor = UIColors.CHARCOAL; //Find swatches with values 0,0,0,100 and merge with Black swatch var myColors = myDoc.colors; var myBlack = myDoc.swatches.itemByName("Black"); for (i = myColors.length-1; i >= 0; i--) {     var myColor = myColors;     if (myColor.colorValue == "0,0,0,100" && myColor.name != "Black"){         myColor.remove(myBlack);     } } // Add 25% Black swatch      try{ myDoc.colors.item("25% Black").name; } catch (myError){ myDoc.colors.add({name:"25% Black", model:ColorModel.process, colorValue:[0, 0, 0, 25]}); } //What Pages should the ovals be put on-All Spreads var myPage = myDoc.spreads.everyItem(); //Create the ovals and specify their size and location... var myLeftOval = myPage.ovals.add({geometricBounds:[2, -3, 2.75, -.75], fillColor:myDoc.colors.item("25% Black"),strokeColor:myDoc.swatches.item("None"), itemLayer:myDoc.layers.item("New Layer")}); var myCenterOval = myPage.ovals.add({geometricBounds:[3, -3, 3.75, -.75], fillColor:myDoc.colors.item("25% Black"),strokeColor:myDoc.swatches.item("None"), itemLayer:myDoc.layers.item("New Layer")}); var myRightOval = myPage.ovals.add({geometricBounds:[4, -3, 4.75, -.75], fillColor:myDoc.colors.item("25% Black"),strokeColor:myDoc.swatches.item("None"), itemLayer:myDoc.layers.item("New Layer")});

Thanks again for any help with this, I am at a dead end.

Danny

TOPICS
Scripting

Views

1.8K
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

Contributor , Aug 01, 2011 Aug 01, 2011

Hi

I think you should use ObjectStyle!

create an Object Style and set some transparency settings, and apply this to objects

var my_obj_style; try {    my_obj_style = myDoc.objectStyles.add({name:"inner glow setting"}); } catch(e){   my_obj_style = myDoc.objectStyles.item("inner glow setting"); } with (my_obj_style.transparencySettings.innerGlowSettings){   applied = true;   blendMode = 1852797549/*BlendMode.NORMAL*/;   opacity = 100;   noise = 0;   effectColor = "Paper";   technique = 2020618338/

...

Votes

Translate
Contributor ,
Jul 29, 2011 Jul 29, 2011

Copy link to clipboard

Copied

Hi

You can get current value of inner glow settings with this snippet in javascript console.

var obj=app.activeDocument.selection[0];
$.writeln(obj.transparencySettings.innerGlowSettings.properties.toSource().replace(/,/g,",\n"));

And then, edit value what you want.

You can edit other transparency settings like this.

with (obj.transparencySettings.innerGlowSettings){
  applied = true;
  blendMode = 1852797549/*BlendMode.NORMAL*/;
  opacity = 100;
  noise = 0;
  effectColor = "Paper";
  technique = 2020618338/*GlowTechnique.PRECISE*/;
  spread = 79;
  size = '0.125in';
  source = 2020618594 /*InnerGlowSource.EDGE_SOURCED*/;  
}

Thankyou

mg.

Votes

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
New Here ,
Aug 01, 2011 Aug 01, 2011

Copy link to clipboard

Copied

Thanks for your reply milligramme. I didn't realize I needed to get the current vallue of the applied transparency before applying transparency. But I was hoping to add this script to the script I originally posted. If I could apply these settings to myLeftOval, myCenterOval and myRightOval it would be great. I have attempted to change the your supplied scripts "selection" to "my""Oval" but am not having any luck. Could you possibley show me how to do this?

Thanks again,

Danny

Votes

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
Contributor ,
Aug 01, 2011 Aug 01, 2011

Copy link to clipboard

Copied

Hi

I think you should use ObjectStyle!

create an Object Style and set some transparency settings, and apply this to objects

var my_obj_style; try {    my_obj_style = myDoc.objectStyles.add({name:"inner glow setting"}); } catch(e){   my_obj_style = myDoc.objectStyles.item("inner glow setting"); } with (my_obj_style.transparencySettings.innerGlowSettings){   applied = true;   blendMode = 1852797549/*BlendMode.NORMAL*/;   opacity = 100;   noise = 0;   effectColor = "Paper";   technique = 2020618338/*GlowTechnique.PRECISE*/;   spread = 79;   size = '0.125in';   source = 2020618594 /*InnerGlowSource.EDGE_SOURCED*/;  } //Create the ovals and specify their size and location... var myLeftOval = myPage.ovals.add({geometricBounds:[2, -3, 2.75, -.75], fillColor:myDoc.colors.item("25% Black"),strokeColor:myDoc.swatches.item("None"), itemLayer:myDoc.layers.item("New Layer"),appliedObjectStyle:my_obj_style}); var myCenterOval = myPage.ovals.add({geometricBounds:[3, -3, 3.75, -.75], fillColor:myDoc.colors.item("25% Black"),strokeColor:myDoc.swatches.item("None"), itemLayer:myDoc.layers.item("New Layer")}); var myRightOval = myPage.ovals.add({geometricBounds:[4, -3, 4.75, -.75], fillColor:myDoc.colors.item("25% Black"),strokeColor:myDoc.swatches.item("None"), itemLayer:myDoc.layers.item("New Layer"),appliedObjectStyle:my_obj_style});

I didn't apply object style to center oval, on purpose.

Thankyou

mg.

Votes

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
New Here ,
Aug 02, 2011 Aug 02, 2011

Copy link to clipboard

Copied

LATEST

This worked great, the only change I had to make was to add the fill color, stroke color etc. to the object style otherwise the ovals came up with no fills.

Thanks milligramme. You've been a tremendous help with this!

Danny

Votes

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