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

New to scripting/ Need help with some UI ideas

Community Beginner ,
Feb 06, 2025 Feb 06, 2025

Hello All!

 

Fairly new to scripting and I've run into a problem. I'm basically trying to make a floating window that doesn't interfere with a user. I have a pretty intensive Modular setup (I think its intensive at least lol). Maybe thats the root cause. I've done some resarch into it but a lot of the posts i see are from like 2012 so im not sure if those are relevant still or not. 

 

Some talked about BridgeTalk -(Not sure what that is exactly. Might need to do more home work on that.)

 

Right now I've tried basically a dialog window with uniquie properties. about 7 versions and the closest i got was being able to intereact with other windows in illustrator but notthing in the actual document. Like I could click on the tools in on left side, interact with the swatch panel, but nothing in the artboard would register until I closed my my UI.

 

Ive tried a Palette window but so far any time i try a palette window. It just closes immediately but I feel like Palette is probably the best description of what I need.

 

I was also using a script launcher plugin at one point just from the market place to get around the ui not being open all the time but once I added mac functionality. The script launcher plugin no longer worked. And the only way I can get it to work now is to launch via File- Scripts- Other scripts. I think the Plug in just uses a unique path finding for file searching and it didn't like the mac addtion to the script. But even if I could figure out a way to get that to work that would be way better! 

 

My UI basically modifys a die line to make a Proof layout. I'll put some examples below. of some of the outputs and how the UI moves. Not sure exactly what would be useful to share. Still going to keep testing in the mean time and will post my solution then.

 

The base UI:

ui look.PNGexpand image

 Example of a submitted file:

example ccomplex shape.PNGexpand image

 

Complex output:

most complex output.PNGexpand image

After proess template is completed:

most complex output after processing.PNGexpand image

 

Ideally jsut want the window to stay open so the user can process multiple tempaltes instead of having to load via other scripts every time. Let me know what information is needed.

 

Hopefully someone can help!

 

TOPICS
Experiment , Scripting
151
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

correct answers 1 Correct answer

Community Beginner , Feb 13, 2025 Feb 13, 2025

The key for me was using bridge talk to work with my current code: 

 

(function() {
    // Get the script directory
    var scriptFile = new File($.fileName);
    var scriptDir = scriptFile.parent.fsName.replace(/\\/g, '/');
   
    // Create the BridgeTalk message
    var bt = new BridgeTalk();
    bt.target = "illustrator";
   
    // Set the current directory for includes
    bt.body = "$.evalFile('" + scriptDir + "/TemplateModifier.jsx');";
   
    bt.onError = function(err) {
        alert("Error launc
...
Translate
Adobe
Participant ,
Feb 06, 2025 Feb 06, 2025

I think the best way to achieve what you want is via an extension. Check this tutorial out, which achieves a dockable panel for script launching. This may do what you want, but if not it may provide some insight to expand upon what you may actually want. 

 

Alternative, and I am unsure what your goal is for your script, but you could look into making it more robust such that you do not need to interact with it at any point. may need to do things in batches.

 

https://youtu.be/1MirbjuLgSI?si=aya_FWS1ixUN_M47

 

 

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
Community Beginner ,
Feb 06, 2025 Feb 06, 2025

We made something close to what I'm looking for it to do. Basically looking for a persistent ui that stays open between different orders. We do a lot of transactional orders so every order is unique and needs different end objectives based on what the customer order so the template varies based on instruction provided. Basically the end goal is just to make the ui persistent but not interfere with the artist. Basically trying to save time by avoiding loading via other script every time the script is run. Right now the script closes after every use in illustrator. This code is the cloeset we've made to a working UI that is persistent. Just have to figure out the magic of why the other code cant utilize it. We might just make a persistent script launcher that jsut launches the other one instead.  

//@target illustrator
//@targetengine LauncherEngine
//@strict on

(function () {
    // 1) Reference the folder where this script resides:
    //    This helps us find the other scripts in the same folder.
    //    (You can change these paths as needed.)
    var thisFile   = new File($.fileName);
    var thisFolder = thisFile.parent; // the folder containing Launcher.jsx

    // 2) Build a small helper to launch an external .jsx script
    //    via BridgeTalk (so the palette remains open).
    function runScript(fileName) {
        var scriptFile = new File(thisFolder + "/" + fileName);
        if (!scriptFile.exists) {
            alert("Cannot find: " + fileName);
            return;
        }

        // Read the script's text
        scriptFile.open("r");
        var code = scriptFile.read();
        scriptFile.close();

        // Build a BridgeTalk message that targets Illustrator
        var bt = new BridgeTalk();
        bt.target = "illustrator";
        bt.body = code;  // Directly eval the script's contents
        bt.onError = function(err) {
            alert("Error running " + fileName + ":\n" + err.body);
        };
        bt.send(); // run asynchronously
    }

    // 3) Create the "Launcher" palette window
    //    â€¢ "palette" type keeps it modeless, so you can use Illustrator freely
    //    â€¢ We used `@targetengine LauncherEngine` so it remains open.
    var win = new Window("palette", "Launcher", undefined, {
        resizeable: true,
        closeButton: true
    });
    win.orientation = "column";
    win.alignChildren = ["fill", "top"];
    win.margins = 10;

    // 4) Add three buttons for the three scripts
    var btn1 = win.add("button", undefined, "Create New Die");
    btn1.onClick = function() {
        runScript("NewDieWIP.jsx");
    };

    var btn2 = win.add("button", undefined, "Run Script 2");
    btn2.onClick = function() {
        runScript("myScript2.jsx");  // runs myScript2.jsx
    };

    var btn3 = win.add("button", undefined, "Run Script 3");
    btn3.onClick = function() {
        runScript("myScript3.jsx");  // runs myScript3.jsx
    };

    // 5) Show the palette. It will stay open, letting you:
    //    â€¢ Use these buttons any time
    //    â€¢ Continue drawing on the artboard and using tools
    win.show();
})();

 

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
Community Beginner ,
Feb 06, 2025 Feb 06, 2025

These may be of use, although for photoshop

 

// Create a dockable panel

    var win = (this instanceof Panel) ? this : new Window("palette", "Photoshop Actions", undefined, { resizeable: true }); win.orientation = "column"; win.alignChildren = ["fill", "top"];

 

// Make the panel dockable

if (win instanceof Window) { win.show();

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
Community Beginner ,
Feb 13, 2025 Feb 13, 2025
LATEST

The key for me was using bridge talk to work with my current code: 

 

(function() {
    // Get the script directory
    var scriptFile = new File($.fileName);
    var scriptDir = scriptFile.parent.fsName.replace(/\\/g, '/');
   
    // Create the BridgeTalk message
    var bt = new BridgeTalk();
    bt.target = "illustrator";
   
    // Set the current directory for includes
    bt.body = "$.evalFile('" + scriptDir + "/TemplateModifier.jsx');";
   
    bt.onError = function(err) {
        alert("Error launching Template Modifier. Please try again.");
    };
   
    bt.send();
})();
 
 
This code also was significant help:
//@target illustrator
//@targetengine LauncherEngine
//@strict on

(function () {
    // 1) Reference the folder where this script resides:
    //    This helps us find the other scripts in the same folder.
    //    (You can change these paths as needed.)
    var thisFile   = new File($.fileName);
    var thisFolder = thisFile.parent// the folder containing Launcher.jsx

    // 2) Build a small helper to launch an external .jsx script
    //    via BridgeTalk (so the palette remains open).
    function runScript(fileName) {
        var scriptFile = new File(thisFolder + "/" + fileName);
        if (!scriptFile.exists) {
            alert("Cannot find: " + fileName);
            return;
        }

        // Read the script's text
        scriptFile.open("r");
        var code = scriptFile.read();
        scriptFile.close();

        // Build a BridgeTalk message that targets Illustrator
        var bt = new BridgeTalk();
        bt.target = "illustrator";
        bt.body = code;  // Directly eval the script's contents
        bt.onError = function(err) {
            alert("Error running " + fileName + ":\n" + err.body);
        };
        bt.send(); // run asynchronously
    }

    // 3) Create the "Launcher" palette window
    //    â€¢ "palette" type keeps it modeless, so you can use Illustrator freely
    //    â€¢ We used `@targetengine LauncherEngine` so it remains open.
    var win = new Window("palette""Launcher", undefined, {
        resizeable: true,
        closeButton: true
    });
    win.orientation = "column";
    win.alignChildren = ["fill""top"];
    win.margins = 10;

    // 4) Add three buttons for the three scripts
    var btn1 = win.add("button", undefined, "Create New Die");
    btn1.onClick = function() {
        runScript("NewDieWIP.jsx");
    };

    var btn2 = win.add("button", undefined, "Run Script 2");
    btn2.onClick = function() {
        runScript("myScript2.jsx");  // runs myScript2.jsx
    };

    var btn3 = win.add("button", undefined, "Run Script 3");
    btn3.onClick = function() {
        runScript("myScript3.jsx");  // runs myScript3.jsx
    };

    // 5) Show the palette. It will stay open, letting you:
    //    â€¢ Use these buttons any time
    //    â€¢ Continue drawing on the artboard and using tools
    win.show();
})();
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