Skip to main content
Silly-V
Legend
February 2, 2017
Answered

Apply Live Effect: Inner Glow with color

  • February 2, 2017
  • 2 replies
  • 3745 views

With help of some great information, Prometheus-like, we have been given the access to the syntax which makes pageItem.applyEffect(); work

Re: PageItem.applyEffect(LiveEffectXML)

This is great to start out with when the components which make up the 'Dict data="' string are in a straight-forward syntax where there is a data type, a name key and a value to form each component. They just need to be strung together like so:

  1. xmlstring = '<LiveEffect name="Adobe Offset Path"><Dict data="R mlim 4 R ofst 20 I jntp 2 "/></LiveEffect>'

I am able to almost accomplish my goal of applying an Inner Glow, but I can't figure out the syntax needed to supply the glow color to go along with it. It always defaults to white.

Here is the code so far which applies a glow only with white default:

#target illustrator

function test(){

  var effectStr = 

   '<LiveEffect name="Adobe Inner Glow">' + 

       '<Dict data="' + 

           'I gtyp 0 ' + 

           'R blur 14.4 ' +

           'I blnd 3 ' +

           'R opac 1 ' +

           '" ' +

       '/>' +

   '</LiveEffect>';

  var doc = app.activeDocument;

  var s = doc.selection[0];

  s.applyEffect(effectStr);

};

test();

Here is the string inside the .AI file I saved without compression and opened it as text:

/BasicFilter :

(Adobe Inner Glow) 1 0 /Filter ,

1 /Visible ,

(Adobe Illustrator.app) /PluginFileName ,

(Inner Glow) /Title ,

/Dictionary : /NotRecorded ,

0 /Int (gtyp) ,

/FillStyle : 0 O

0.03 0 0.29 0 k

0 1 0 0 0 Xy

0 J 0 j 1 w 10 M []0 d

0 XR

0 1 Xd

/Def ;

(gclr) ,

14.4 /Real (blur) ,

1 /Real (opac) ,

3 /Int (blnd) ,

; /Dict ;

The color information is located here:

/FillStyle : 0 O

0.03 0 0.29 0 k

0 1 0 0 0 Xy

0 J 0 j 1 w 10 M []0 d

0 XR

0 1 Xd

/Def ;

(gclr) ,

While the rest of the 4 properties are working in my attempt above, I can't get the right syntax for putting in that color.

By the way, when applying this effect with experimentation strings added, the result could be an error-less application of the effect with default white or a MRAP, depending on whether you crossed some line of what the acceptable syntax is. I have tried adding new attributes and tags, and it still worked in the default way. Then I tried to add a nested tag inside the Dict tag, and got a MRAP. Whoever is able to solve this puzzle shall be rewarded with several emojis.

This topic has been closed for replies.
Correct answer CarlosCanto

sorry I meant the different blending modes didn't seem to make a noticeable difference in my testings.

this works for me

xmlstring14 = '<LiveEffect name="Adobe Inner Glow"><Dict data="R opac 0.75 R blur 9 I blnd 10 I gtyp 0 "><Entry name="gclr" valueType="F"><Fill color="5 0 1 0.818 0"/></Entry></Dict></LiveEffect>';

2 replies

m1b
Community Expert
Community Expert
February 4, 2021

Update: these free functions make applying Live Effects easier: AI Live Effect Functions.

- Mark

Inspiring
April 9, 2021

This is a very interesting thread (although it looks like I am a little late to the party) and has made me delve a little deeper to try to assign a stoke or fill through the same principle. I have managed to extract the data for the stroke of an object from the uncompressed .ai file (see below). I have tried to follow the thread and feed this into a script but I am not sure how to apply the values from the line '0 J 0 j 1.234 w 4 M []0 d' as this appears to be the join, cap, corner, mitre, stroke width and dashed line information required.

Regarding the colours, I have been playing around with the extra number at the start and it seems like '0' has relevance to greyscale whilst '1' has relevance to CMYK values, but from the extrated data below I appear to have a '0' (in the line '/StrokeStyle : 0 R') on a CMYK colour of 100 Cyan and 100 Yellow (in the line '1 0 1 0 K'), or am I pulling the additional extra number from the wrong place?

/BasicFilter :
(Stroke Style Filter) 0 0 /Filter ,
1 /Visible ,
2 /FillOrStroke ,
/Dictionary : /NotRecorded ,
/StrokeStyle : 0 R
1 0 1 0 K
0 1 0 0 0 Xy
0 J 0 j 1.234 w 4 M []0 d
0 XR
1 0 Xd
/Def ;
 (StrokeStyle) ,
; /Dict ;
 /Part ,

 

CarlosCanto
Community Expert
Community Expert
April 12, 2021

I am just looking at adding a stroke at the moment and the data I have extracted gives the following info '(Stroke Style Filter) 0 0 /Filter ,', so I presume the filter name is 'Stroke Style Filter', see below for what I have in my script so far, but this is not working:

<LiveEffect name="Stroke Style Filter"><Stroke color="1 1 0 1 0"/><StrokeStyle = 0 J 0 j 1 w 4 M []0 d></Entry></Dict></LiveEffect>'

I meant I wanted to know the name of the effect in the Effects Menu you were trying to apply to try to get the right data.

But I just realized you're not doing that. You're trying to do something else.

CarlosCanto
Community Expert
Community Expert
February 3, 2017

you're using Overlay Blending Mode, I couldn't get that to work even manually. Use Normal or Difference for proof of concept, those work fine.

Silly-V
Silly-VAuthor
Legend
February 3, 2017

The blending mode seems to work (at least to the point of setting the correct item in the dropdown), but it is the color which eludes me.

CarlosCanto
Community Expert
CarlosCantoCommunity ExpertCorrect answer
Community Expert
February 3, 2017

sorry I meant the different blending modes didn't seem to make a noticeable difference in my testings.

this works for me

xmlstring14 = '<LiveEffect name="Adobe Inner Glow"><Dict data="R opac 0.75 R blur 9 I blnd 10 I gtyp 0 "><Entry name="gclr" valueType="F"><Fill color="5 0 1 0.818 0"/></Entry></Dict></LiveEffect>';