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

Scripting roughen with live effect

New Here ,
Feb 28, 2024 Feb 28, 2024
I'm trying to apply roughen with a script. The executeMenuCommand gives a popup, but I want the options to be automated. 
The script below works (applies the roughen), but I don't now which data I can put in the Dict. Does somebody now what variables there are for LiveEffect roughen?
 
#target illustrator
 
function test() {
    var doc = app.activeDocument;
    var p = doc.selection[0];
roughendetail = 2;
    var effectStr = '<LiveEffect name="Adobe Roughen"><Dict data="R RoughenDetail 50 R RoughenAbsoluteSize 1 R RoughenPoints 2 R RoughenDetail 50 R RoughenSize 10 "/></LiveEffect>';
//var effectStr = '<LiveEffect name="Adobe Roughen"><Dict data="R Detail #RoughenDetail#"/></LiveEffect>'.replace(/#RoughenDetail#/, roughendetail);
    p.applyEffect(effectStr);
 
    //radius = 3;
    //var xml = '<LiveEffect name="Adobe Fuzzy Mask"><Dict data="R Radius #Radius# "/></LiveEffect>'.replace(/#Radius#/, radius);
    //p.applyEffect(xml);
};
 
test();
TOPICS
Scripting
338
Translate
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
Adobe
Community Expert ,
Feb 28, 2024 Feb 28, 2024

Hi @ircoony, it might help to have a look through the code I wrote here.

 

For example, here is the function for applying roughen:

function LE_Roughen(item, options) {
    try {
        var defaults = {
            amount: 5,
            absoluteness: 0,     /* 0 or false = relative, 1 or true = absolute */
            segmentsPerInch: 10,
            smoothness: 0,       /* 0 = corners, 1 = smooth, 0.5 = halfway, 1.5 = too much? */
            expandAppearance: false
        }
        var o = LE.defaultsObject(item, defaults, options, arguments.callee)
        var xml = '<LiveEffect name="Adobe Roughen"><Dict data="R asiz #1 R size #2 R absoluteness #3 R dtal #4 R roundness #5 "/></LiveEffect>'
            .replace(/#1/, o.amount)
            .replace(/#2/, o.amount)
            .replace(/#3/, Number(o.absoluteness))
            .replace(/#4/, o.segmentsPerInch)
            .replace(/#5/, o.smoothness);
        LE.applyEffect(item, xml, o.expandAppearance);
    } catch (error) {
        LE.handleError(error);
    }
};

 

Note: that this example won't work by itself (it is designed for use with the other code file), but it explicitly shows you how to populate the Dict. Let me know if you get stuck.

- Mark

Translate
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 ,
Feb 28, 2024 Feb 28, 2024

You're the best Mark! It helped me a lot to see how to populate the Dict. My code is now working without any popups 🙂

Translate
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 ,
Nov 08, 2024 Nov 08, 2024
LATEST

HI! I'm an illustrator who doe'sn't know much about JSX sady but I m trying to figure out how to make a script that will automatically apply the roughen effect to a an object. I have to do this repeatedly at work and I would love to automate the prosess. Any help would be greatfully recieved!

Thanks.

J

Translate
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