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

What chooses the page setup in this script

Mentor ,
Feb 19, 2018 Feb 19, 2018

I'm going nuts trying to find the rational explanation of what one of the sample scripts in InDesign does.

The script is the ImageCatalog.jsx included in the Javascript samples.

When you invoke the script it asks you to point to a folder of images and then creates a new ID document with the images arranged neatly.

Can someone look at the script and tell me if there is something in there that defines the page setup? I've copied the script into its own link in case you need it: Dropbox - ImageCatalog copy.jsx

TOPICS
Scripting
1.4K
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 Expert , Feb 19, 2018 Feb 19, 2018

Hi Sandee,

Robert is right. The script uses what's already there in the preferences.

The only thing it might change is the ruler units to Points:

var myDocument = app.documents.add();

myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;

myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;

To control what will happen to your new document you best do the following:

1. Close all documents

2. Go to Document Setup and do a new named setup.

3. Add a new doc

...
Translate
Engaged ,
Feb 19, 2018 Feb 19, 2018

Don't see anything. My guess is that it's starting with whatever you've got in your current application preferences.  What do you get when you create a new document manually?

Actually, a better question is: What do you want the script to do differently? The document is created in the function myMakeImageCatalog() so that's where you change the things you do not like.

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 Expert ,
Feb 19, 2018 Feb 19, 2018

Hi Sandee,

Robert is right. The script uses what's already there in the preferences.

The only thing it might change is the ruler units to Points:

var myDocument = app.documents.add();

myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;

myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;

To control what will happen to your new document you best do the following:

1. Close all documents

2. Go to Document Setup and do a new named setup.

3. Add a new document with the New Document dialog.

Chose the new named setup.

4. Close the new document without saving.

Now run the three lines of code above and see, if the new named setup is used.

Hope, that helps…

Regards,
Uwe

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
Mentor ,
Feb 20, 2018 Feb 20, 2018

Unfortunately I can only mark one answer as correct so I marked Uwe's because he gave me the three lines to test and the steps to prove what's going on.

Couple of comments:

Instead of Document Setup, I chose Document Presets so I can show my students how to save the settings.

"New named setup" is what I think is document preset. (Translation difference?)

InDesign really needs a button that runs a script in the background that changes the current document preset to a different one. Without having to create a new document and then closing that document.

Thank you both. I started by asking about the script, but got more information about setting the new document preset for other documents.

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
Engaged ,
Feb 20, 2018 Feb 20, 2018
LATEST

Not entirely sure what you mean by a button that runs a script in the background.

Here's a script that creates a new document after first asking the user to select a document preset (You have to create the presets in advance, of course). If you save it as a .jsx file in your scripts folder, you can run it from the Scripts Panel. Kinda like a button. There are probably a zillion examples of this kind of thing on the internet.

If '"in the background" means you want something that happens automagically, then you probably want an event listener, one that fires on the "beforeNew" event.

Bob (still angling for that "correct answer" tag; Uwe's got plenty )

var presetNames = app.documentPresets.everyItem().name;

var userSelected = chooseFromList("Choose a Document Preset",presetNames,-1);

var myDocument = app.documents.add(true,app.documentPresets.item(userSelected));

function chooseFromList(windowName,theList,defaultItem) {

var win = new Window("dialog",windowName);

var myGroup = win.add("group");

myListBox = myGroup.add ("listbox",undefined,theList);

myListBox.selection = defaultItem;

var listboxDepth = theList.length * 25;

if (listboxDepth > 800) {

listboxDepth = 800;

} //end if

myListBox.preferredSize = [250,listboxDepth];

win.myButtonsGroup = win.add ("group");

win.myButtonsGroup.orientation="row";

win.myButtonsGroup.buttonOK = win.myButtonsGroup.add ("button",undefined, "OK");

if (defaultItem < 0) {  

win.myButtonsGroup.buttonOK.enabled = false;

} // end if

win.myButtonsGroup.buttonCancel = win.myButtonsGroup.add ("button",undefined, "Cancel");

//OK button will be disabled until user selects an item in the listbox

myListBox.onChange = function () {

win.myButtonsGroup.buttonOK.enabled = true;

}

var userClicked = win.show();

if (userClicked == 1) {

var userSelected = myListBox.selection.text;

}

else {

var userSelected = undefined;

}

return userSelected;

} // end chooseFromList

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