Tag: tips

  • Apply Live Effect – applyEffect (LiveEffectXML)

    Apply Live Effect – applyEffect (LiveEffectXML)

    Scripting Adobe Illustrator is painful at times, we don’t have access to some of the most useful features available to us manually using the UI, and we also don’t have the luxury of major upgrades to the DOM as ID or PS users have enjoyed for years. With the release of CS6 some years back, Adobe surprised us with a couple of new, although undocumented commands that seemed to have great potential. One of them was  executeMenuCommand(menuCommandString), the string syntax was missing, but fortunately it was quickly found out by some talented scripters, proving its value, and becoming one of the most, if not the most powerful command available.

    The other command released with CS6 was applyEffect(liveEffectXML), which also had its string syntax missing, till now…well, without further ado, here’s an example

    // apply offset path live effect to selected path
    var idoc = app.activeDocument;
    var ipath = idoc.selection[0];
     
    xmlstring = ‘<LiveEffect name=”Adobe Offset Path”><Dict data=”R mlim 4 R ofst 20 I jntp 2 “/></LiveEffect>’;
     
    ipath.applyEffect(xmlstring);

    the important part of the string is the data, mlim is the MiterLimit Value “4”, ofst is the Offset Value “20”, jntp is the Join Type “2” for Miter.

    liveEffect1

    How to get the XML string parameter

    To get the right xml string for a particular Effect, fire up Illustrator CS5 or CS6, draw a rectangle, apply a Live Offset Path as show above, then save your file as FXG

    liveEffect2

    Make sure “Save Illustrator Private Data” is selected, then click on “Show Code…”, you’ll get the xfg text file generated.

    liveEffect3

    Look for the LiveEffect tag and get the name and the Dict data from it as shown below

    <LiveEffect name=”Adobe Offset Path”><Dict data=”R mlim 4 R ofst 20 I jntp 2 “/></LiveEffect>

    that’s all, that’s the xml string you need to add to your script.

    I would like to thank Adobe’s Sanjay Kumar, without his input this command would have not seen the light of day.

Cookie Preferences

We use cookies to enhance your experience. Choose which types of cookies you want to allow.

Strictly Necessary

Required

Required for core site functions such as security, load balancing, login sessions and remembering your cookie choices. No data is shared with third parties. Cannot be disabled.

Functional

Remember choices you make (language, region, preferences) to provide enhanced, personalized features. May set cookies from embedded services you interact with, such as video players or maps.

Analytics

Measure how visitors use the site (pages viewed, time on page, referring source) so we can improve it. Data may be processed by analytics providers such as Google Analytics, generally in aggregated form.

Marketing

Build a profile of your interests to show relevant advertising on this and other sites, and measure ad performance. Data may be shared with advertising partners such as Google Ads and Meta (Facebook).