Skip to main content
Participant
February 11, 2019
Answered

Changing Bevel/Emboss Setting for an Object via Script (help request)

  • February 11, 2019
  • 3 replies
  • 1360 views

I am a scripting novice in need of guidance.

I am laying out a rule and scenario books for an "old-fashioned wargame" that uses a printed map with a hex grid overlaid on the artwork, and cardboard tokens that represent military units such as tanks, infantry, artillery, and more. The scenario book missions need to show these counters in a manner that stands out from the map, and the game's inventor wants the tokens beveled, with shadow falling off them.

Each token "faces" one of six directions (i.e., 0 degrees, 60 degrees, 120 degrees, etc., one "side" of the hexagon it resides in). With global lighting there's no issue with where shadows fall, the light source is locked down. But the bevel/emboss settings are not locked down, and rotate with the object's rotation. A token rotated from its import orientation (0 degrees) to 120 degrees causes the bevel effect to appear "lit" from the 120 degree angle -- no matter what the shadow angle is set to. So you get conflicting lighting effects.

There are a LOT of tokens, at any of 6 directions, to adjust manually. I can see two approaches to a script to correct this, but it appears I'm too much a novice to make either work!

First Approach:

A script like the one below that affects the transparency of an object, that simply sets a value.

app.selection[0].transparencySettings.blendingSettings.opacity=10;

With 6 scripts I can cover the 6 possible facing settings for a token. However I cannot find the correct way to express the value I need to address. Variations on this script ( all resulted in an "Error 55 Object does not support property or method."

app.selection[0].BevelAndEmbossSetting.angle=270;

and

app.selection[0].transparencySettings.BevelAndEmbossSetting.angle=270;

Both of these failed, yet I could not locate any examples that provided clues as to what I am missing. I thought this would be simpler. How do I find out HOW to refer to the correct setting for such a script?

Second Approach:

This one's beyond my current abilities. A script that queries the values from InDesign for the objects Drop Shadow angle and its Rotation angle, calculates the appropriate "end result" for a matching bevel appearance, and sets that Shading angle for the bevel effect. While I can see a LOT of options making this more complex (offsets, distances, or other options), the specific need here is merely to make the bevel lighting "right" for the object's facing and the drop shadow angle.

Some years ago this script was posted to address a user's need to have the shadow rotate WITH an object. I thought perhaps I could reverse engineer some of this to fit my needs... in fact, this is what gave me the idea for the Second Approach. Alas, I can conceive of more ideas than I can code

    function main(){ 

      var sel = app.selection; 

      if(!sel){return} 

      if(sel.length==0){return} 

      var d=app.dialogs.add({name:"Change Angle With Drop Shadow"}); 

      d.dialogColumns.add().staticTexts.add({staticLabel:"Rotation Angle:"}); 

      var angleBox = d.dialogColumns.add().angleEditboxes.add({editValue:0,smallNudge:1,largeNudge:15}); 

      var result = d.show(); 

      if(!result){d.destroy();return} 

      var angle = angleBox.editValue; 

      for (var i=0;i<sel.length;i++){ 

        var rotation = sel.rotationAngle; 

        rotation=rotation+angle; 

        if(rotation>=360){rotation=rotation-360} 

        sel.rotationAngle = rotation; 

        var dropAngle = sel.transparencySettings.dropShadowSettings.angle; 

        dropAngle = dropAngle+angle; 

        if(dropAngle>=360){dropAngle=dropAngle-360} 

        sel.transparencySettings.dropShadowSettings.angle = dropAngle; 

      } 

    } 

    main(); 

Can anyone offer any guidance, or referrals to consult?

Thank you,

James

This topic has been closed for replies.
Correct answer TᴀW

So close!

Try:

myObject.transparencySettings.bevelAndEmbossSettings.angle = 99;

... all I've changed is the lowercase b for bevel, and a plural s for bevelAndEmbossSettings.

Note that the angle must be express as a value between -180 and 180 degrees.

Also, if needed, there's the property

contentTransparencySettings

... if you want to apply bevel to the content itself.

HTH,

Ariel

3 replies

Participant
February 13, 2019

Ariel and Uwe, thank you very much for sharing your knowledge with me here.

I have learned much about InDesign's settings that I never needed to know in the past, but they matter now. Your replies opened up my limited understanding and whetted the desire for more.

If you don't mind plumbing the depths of ID knowledge a bit further, I'd like to ask them below in this same thread... I hope that's okay. If not, let me know.

Also, I am new here and am not sure of the etiquette for indicating "the answer" was provided. Ariel solved my immediate need, and Uwe showed me "more exists". (grin) You're both at fault! I've no wish to disrespect anyone, so how's that feature work here?

Respectfully,

James

Community Expert
February 13, 2019

Hi James,

the etiquette would be that you give Ariel's reply the Correct Answer.

Everything else is OK. :-)

Ah, for new topics, not revolving around scripting transparency it would be better to do a new thread.

Regards,
Uwe

Community Expert
February 12, 2019

Hi James,

also note that there are four settings regarding transparency of an object on the page:

 

transparencySetting

https://www.indesignjs.de/extendscriptAPI/indesign8/#TransparencySetting.html

 

contentTransparencySetting

https://www.indesignjs.de/extendscriptAPI/indesign8/#ContentTransparencySetting.html

 

fillTransparencySetting

https://www.indesignjs.de/extendscriptAPI/indesign8/#FillTransparencySetting.html

 

strokeTransparencySetting

https://www.indesignjs.de/extendscriptAPI/indesign8/#StrokeTransparencySetting.html

 

Regards,
Uwe Laubender

 

EDITED: Links were dead.

TᴀW
TᴀWCorrect answer
Legend
February 12, 2019

So close!

Try:

myObject.transparencySettings.bevelAndEmbossSettings.angle = 99;

... all I've changed is the lowercase b for bevel, and a plural s for bevelAndEmbossSettings.

Note that the angle must be express as a value between -180 and 180 degrees.

Also, if needed, there's the property

contentTransparencySettings

... if you want to apply bevel to the content itself.

HTH,

Ariel

Visit www.id-extras.com for powerful InDesign scripts that save hours of work — automation, batch tools, and workflow boosters for serious designers.