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

Apply Live Effect: Inner Glow with color

Valorous Hero ,
Feb 02, 2017 Feb 02, 2017

Copy link to clipboard

Copied

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.

TOPICS
Scripting

Views

2.1K

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 , Feb 03, 2017 Feb 03, 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>';

Votes

Translate

Translate
Adobe
Community Expert ,
Feb 03, 2017 Feb 03, 2017

Copy link to clipboard

Copied

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.

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
Valorous Hero ,
Feb 03, 2017 Feb 03, 2017

Copy link to clipboard

Copied

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.

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 ,
Feb 03, 2017 Feb 03, 2017

Copy link to clipboard

Copied

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>';

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
Valorous Hero ,
Feb 03, 2017 Feb 03, 2017

Copy link to clipboard

Copied

Oh cool, so the "Def" thing becomes an <Entry name=""> and the FillStyle becomes <Fill color=""> ?

So then, in your color="" string, there's 6 numbers - are you able to elaborate a little more on how this string transfers to this format:

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

I am going to assume this:

color="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"

Is that right? I'll test soon too.

-----------------------------------------------

Yea that long number string of mine did not work. But it looks like all of those letters and numbers are not really necessary. Now I wonder which of those correspond with your 6 numbers and as a bonus, what the other ones do.

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 ,
Feb 03, 2017 Feb 03, 2017

Copy link to clipboard

Copied

for color info only this is relevant, those are your cmyk values in percentages of 1

0.03 0 0.29 0 k

I have no idea about the other numbers.

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
Valorous Hero ,
Feb 03, 2017 Feb 03, 2017

Copy link to clipboard

Copied

So for yours, what do the other 2 numbers mean?

<Fill color="5 0 1 0.818 0"/>

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 ,
Feb 03, 2017 Feb 03, 2017

Copy link to clipboard

Copied

it's only 5 numbers, not sure what the first number means, the next 4 are your cmyk values.

this should yield the cmyk values exactly as you'll see them in the UI (c:25, m:100, y:50, k:0)

<Fill color="1 0.25 1 0.5 0"/>

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
Valorous Hero ,
Feb 03, 2017 Feb 03, 2017

Copy link to clipboard

Copied

Okay, I don't know the oracles you speak with to get this information, but thank you once again for the great revelation!

By the way, for me Overlay works just fine. It may be that you are just not visually noticing the effect? The shape I used the effect on, I made to have the basic black-to-white gradient and the blending mode's appearance was evident.

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 ,
Feb 04, 2017 Feb 04, 2017

Copy link to clipboard

Copied

hahaha no oracles, just looking at the fxg file.

where are my emojis? several of them

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
Valorous Hero ,
Feb 04, 2017 Feb 04, 2017

Copy link to clipboard

Copied

What? How could I forget!

So, it appears the FXG file has better description of the live effect XML string because the one from a non-compressed .ai file is more cryptic when it comes to the nested elements.

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
Valorous Hero ,
Oct 06, 2018 Oct 06, 2018

Copy link to clipboard

Copied

Is there any way to get FXG out in CC2018? It always saves me a .ai file even though I used FXGSaveOptions...

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 ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

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

- Mark

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
Participant ,
Apr 09, 2021 Apr 09, 2021

Copy link to clipboard

Copied

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 ,

 

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 ,
Apr 09, 2021 Apr 09, 2021

Copy link to clipboard

Copied

Good question! I also wondered if we could sneak in some stroke or fill effects via the applyEffect method but I haven't been able to get it to work. As far as I know, no-one has yet, but it seems like it might be just a matter of getting the right XML structure.

 

The extra number at the start of the color specification denotes the color type:

0 = GrayColor, 1 = CMYKColor, 5 = RGBColor

(There's an internal convenience function called 'LE.formatColor' in LE.js in my LE_Functions repo I mentioned above.)

 

Please let us know if you achieve anything on this!

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
Participant ,
Apr 09, 2021 Apr 09, 2021

Copy link to clipboard

Copied

So, if '0' refers to greyscale and my uncompressed .ai file had a stroke with 100 Cyan and 100 Yellow but the line '/StrokeStyle : 0 R' uses a '0', am I getting my colour space number from the wrong place? Surely it should be '1', if so, which line of the code is this coming from?

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 ,
Apr 09, 2021 Apr 09, 2021

Copy link to clipboard

Copied

what's the filter name you're trying to apply?

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
Participant ,
Apr 12, 2021 Apr 12, 2021

Copy link to clipboard

Copied

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>'

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 ,
Apr 12, 2021 Apr 12, 2021

Copy link to clipboard

Copied

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.

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
Participant ,
Apr 12, 2021 Apr 12, 2021

Copy link to clipboard

Copied

Sorry, yes, I am trying to apply a stroke via the 'Appearance' panel.

Screenshot 2021-04-12 at 09.50.14.png

 

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 ,
Apr 12, 2021 Apr 12, 2021

Copy link to clipboard

Copied

yeah I'm not sure if we can hack the ApplyEffect() described in this post to make it work with Appearance colors/strokes

 

why don't you start a new post describing what you're trying to accomplish with the Appearance panel in more detail?

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
Participant ,
Apr 13, 2021 Apr 13, 2021

Copy link to clipboard

Copied

Will do, thanks.

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 ,
Apr 13, 2021 Apr 13, 2021

Copy link to clipboard

Copied

LATEST

It's a tantalizing idea, and by no means crazy. Good luck!

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