Back

If your email is not recognized and you believe it should be, please contact us.

Forum Replies Created

Viewing 15 posts - 31 through 45 (of 47 total)
  • Author
    Posts
  • in reply to: Problems with array.sort() in ExtendScript #14323805
    Brian Pifer
    Participant

    Disregard, I found the bug, which was unrelated to my sorting.

    in reply to: Export pages to jpg with custom filenames #116271
    Brian Pifer
    Participant

    Sorry for the delayed reply.

    Add this somewhere in your code:

    var myPrompt = prompt(“Name your folder to create on the desktop”);

    var f = new Folder(‘~/Desktop/’ + myPrompt);

    if (!f.exists)
    f.create();

    Then you will want to update the myFilePath variable to:

    var myFilePath = f.fsName + myPageName + “.jpg”;

    Note: I do not have Indesign installed and am a bit rusty. I may be forgetting some slash marks in there, and can’t remember if you will want to use f.fsName or f.fullName. But play with that.

    in reply to: Save the selected frame data to a separate json file #116347
    Brian Pifer
    Participant

    Great! Glad I was able to help.

    in reply to: Export pages to jpg with custom filenames #116128
    Brian Pifer
    Participant

    Alain, you can set the file destination by setting the path you desire in this line of the original code. Change Desktop to the destination you want:

    var myFilePath = “~/Desktop/” + myPageName + “.jpg”;

    in reply to: Save the selected frame data to a separate json file #115987
    Brian Pifer
    Participant

    Something like this might work for images in a given active document. Note, I’m a bit rusty and don’t have access to ID currently to check. For more info on the properties you can write to the file, check: https://jongware.mit.edu/idcs6js/pc_Graphic.html

    /////////////////////////

    var graphicsArr = app.activeDocument.allGraphics;
    var path = ‘~/Documents/’;
    var filename = app.activeDocument.name.split()[0] + ‘.json’;
    var file = new File(path + filename);

    file.encoding = ‘UTF-8’;
    file.open(‘w’);

    for (var i = 0; i < graphicsArr.length; i++) {
    var g = graphics.Arr[i];
    if (g.itemLink.isValid) {
    file.write(g.itemLink.name + “\r”);
    }

    //the graphic’s info
    file.write(g.horizontalScale.toString() + “\r”);
    file.write(g.verticalScale.toString() + “\r”);
    file.write(g.geometricBounds.toString() + “\r”); //this comes in as an array of four numbers
    file.write(g.rotationAngle.toString() + “\r”); //second return mark to separate different graphics

    //the parent’s info (rectangle object, most likely)
    file.write(g.parent.horizontalScale.toString() + “\r”);
    file.write(g.parent.verticalScale.toString() + “\r”);
    file.write(g.parent.geometricBounds.toString() + “\r”); //this comes in as an array of four numbers
    file.write(g.parent.rotationAngle.toString() + “\r”); //second return mark to separate different graphics

    }

    file.close();

    in reply to: Redefine Paragraph and Character Style Script? #115971
    Brian Pifer
    Participant

    Not sure this will work as I don’t have access to ID currently and am a bit rusty, but I would try something along the lines of:

    var myPars = app.document.paragraphs.everyItem();

    for (var num = 0; num < myPars.length; num++) {
    var revisedPointSize = myPars[num].texts.anyItem().pointSize;
    myPars.appliedParagraphStyle.pointSize = revisedPointSize;
    }

    It could be made more elegant by skipping styles already fixed, or I could be approaching it totally backward or incorrectly, but that’s how I would start. This only accounts for point size and not other properties that might be changing, or character styles, but hopefully it helps you start to tackle it.

    in reply to: Find differences in several paragraph styles #115970
    Brian Pifer
    Participant

    What kind of differences might you be looking to compare, and is the point of the comparison to identify the ones that need to be changed in the second part of your question?

    For the second part here is a brute Force solution (I’m a bit rusty):

    var myPars = app.document.paragraphs.everyItem();

    for (var i = 0; i < myPars.length(); i++) {
    if (myPars[i].appliedParagraphStyle == “styleToChange” {
    myPars[i].applyParagraphStyle(“styleToApply”), true));
    //Repeat other if statements as necessary

    in reply to: Save the selected frame data to a separate json file #115968
    Brian Pifer
    Participant

    There might be other ways to approach without getting so complicated, ie, does it have to be a menu command, or could you just run a script on a given document if there were some unique characteristics about the frames you wanted to export the data on. For instance, some pseudocode would be:

    For the frames in a doc,
    If the frame has a linked file name,
    Append that frame’s data to the json doc

    Would something like that work, or do you only want to export some specific linked files. Are there any commonalities between them that could be identified?

    in reply to: Save the selected frame data to a separate json file #115946
    Brian Pifer
    Participant

    This is not quite a trivial matter. You’ll be dealing with the application’s menu objects, script menu objects as well as event listeners, along with the code to provide the export you seek. The following article may be helpful to start wrapping your brain around it, but it would be a somewhat complex script.

    https://www.indiscripts.com/post/2010/02/how-to-create-your-own-indesign-menus

    in reply to: Script to automate layout creation #89452
    Brian Pifer
    Participant

    Hi Dragos,

    Not sure where the “vtsnsinsicpg…” line would be coming from, if the code I provided is the only thing in the .jsx file, unless you have another script that is appending some kind of root filename into other scripts. Sorry I can’t be of more help.

    in reply to: Script to automate layout creation #89395
    Brian Pifer
    Participant

    Hi Dragos,

    Something like this should work for the first part of the problem you’re trying to solve. It assumes you have the main frame you want resized selected with the black arrow. It should resize the frame to the edge of the page. I don’t have much familiarity with bleeds so couldn’t help you too much there. Hopefully this is a useful start.

    var theDoc = app.activeDocument;
    var theSelection = app.selection[0];
    var bounds = [0, 0, theDoc.documentPreferences.pageHeight, theDoc.documentPreferences.pageWidth];
    theSelection.geometricBounds = bounds;

    in reply to: script needed to remove background colour #89371
    Brian Pifer
    Participant

    Hi Philip, Paul’s code from Jan. 28 should work. If you need help with how to set up a script with a snippet you found here, check out this post: https://creativepro.com/how-to-install-a-script-in-indesign-that-you-found-in-a-forum-or-blog-post.php

    in reply to: First freelance scripting opportunity – questions #89368
    Brian Pifer
    Participant

    Thank you for the response, Jake. You definitely provided a lot of food for thought. I probably wouldn’t have charged if the client hadn’t offered to pay, since I, too, script for the love of it. I think I set a fair price and developed a contract that covers my bases. I appreciate your insight.

    in reply to: Loop through findGrep #64621
    Brian Pifer
    Participant

    No problem. I realized my explanation about using Join wouldn’t work, since you’re not working with strings with FindGrep(); rather, they’re an array of Text objects. So yes, you would need to loop through regardless.

    in reply to: Loop through findGrep #64588
    Brian Pifer
    Participant

    Because you are not performing a task for each find within the “for” loop. All you’re doing is setting the TocTitles variable inside the loop; after you set it the first time, it immediately moves and assigns that variable to the next find. Then, when you exit the loop, you have TocTitles assigned to just one find. You basically need to be doing all the work in the loop, like so:

    var docTitles = myDoc.findGrep();
    var myPage = myDoc.pages.item(1); //fyi, a shorthand for this call is “myDoc.pages[1];”
    var tocFrame = myPage.textFrames.add();
    tocFrame.geometricBounds = [78.911, 273.75, 237.987, 360.25];

    for ( i = 0; i < docTitles.length; i++ ) {
    var tocTitles = docTitles[a];
    tocFrame.contents += tocTitles.contents + “\r”;
    }

    Or you could forget the for loop entirely, and use the array’s join method to combined all the finds into one big chunk, then add them to the text frame.

    var myFinds = …findGrep();
    var myJoin = myFinds.join(“\r”); //the “\r” puts a return mark between each array entry.
    myFrame.contents = myJoin;

Viewing 15 posts - 31 through 45 (of 47 total)