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

Progress bar script running

Explorer ,
Apr 10, 2019 Apr 10, 2019

Copy link to clipboard

Copied

Hi,

I am trying to do a progress bar witch starts when I run the script and ends when the script finishes.

Can anyone help please?

Thanks!

TOPICS
Scripting

Views

6.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
Contributor ,
Apr 10, 2019 Apr 10, 2019

Copy link to clipboard

Copied

Hi,

you can learn about how to create a progressbar from Peter Kahrel's scripting guide "ScriptUI for dummies" PDF. Download link below.

ScriptUI for dummies | Peter Kahrel

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
Enthusiast ,
Apr 17, 2019 Apr 17, 2019

Copy link to clipboard

Copied

An example:

Define a function for progress...

function progress(steps) {

    var b;

    var t;

    var w;

    w = new Window("palette", "Progress", undefined, {closeButton: false});

    t = w.add("statictext");

    t.preferredSize = [450, -1]; // 450 pixels wide, default height.

    if (steps) {

        b = w.add("progressbar", undefined, 0, steps);

        b.preferredSize = [450, -1]; // 450 pixels wide, default height.

    }

    progress.close = function () {

        w.close();

    };

    progress.increment = function () {

        b.value++;

    };

    progress.message = function (message) {

        t.text = message;

    };

    w.show();

}

Use it like this...

// Example is ten things to do. That is the number of 'steps' to do.

var steps = 10;

progress(steps);

// Your loop of something to do...

for (var i = 0; i < steps; i++) {

    progress.message("Doing step " + i);

    // Do something.

    progress.increment();

}

// All done.

progress.close();

Make sense?

To see its use in context of an entire script, see the source section on this page, a simple script to export a folder of PDFs.

https://www.marspremedia.com/software/indesign/pdf-export-folder

William Campbell

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
New Here ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

Is there a way to create a progress bar without knowing the number of steps the function is going to take?

I'm working on a script which goes through all layers, including layer sets and smart objects, and since the files vary in size I can't know how many layers the function will be going through.

Anything that can be done?

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

Copy link to clipboard

Copied

Hi Dana,

the number of documents can be counted, the number of layers in each of the documents you like to access can also be counted. So in the end you could do a progress bar for that amount of layers if you want.

 

// Example for all open documents:
var numLayers = app.documents.everyItem().layers.everyItem().getElements().length;

 

Regards,
Uwe Laubender

( ACP )

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

Copy link to clipboard

Copied

LATEST

You mentioned smart objects:

We are talking of InDesign here.

Not PhotoShop…

 

Regards,
Uwe Laubender

( ACP )

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