Skip navigation
PrntScr
Currently Being Moderated

What could block a script, when there's nothing wrong with it?

Jun 20, 2012 9:41 AM

Hello, again

 

I've just wasted some hours trying to get a script to execute. It threw an error saying that the 'object wasn't valid' I decided to give up, wen't home, and later at home started up again to see if I could sort it out.

 

It executed well on the first run.

 

Same computer. No changes to the script. ESTK was set to InDesign 5, I checked it a million times.

 

What could cause this to happen? Caches overflowing? "Blocks" between InDesign and ESTK?
The script isn't callng for any URIs or such.

 

Here's the bit I was having trouble with:

 

 

 

app.activeDocument.groups.everyItem().ungroup();    

 

app.activeDocument.layers.everyItem().locked = false;

 

app.activeDocument.pageItems.everyItem().locked = false;

 

 

MoveTextFrame();

 

function MoveTextFrame() {

    var doc = app.activeDocument;

    var stories = doc.stories;

    var STYLE = doc.paragraphStyles.item("Some Style");

    for (var i = stories.length-1; i >= 0; i--) {

        if (stories[i].appliedParagraphStyle == STYLE && stories[i].paragraphs[0].parentTextFrames[0].parentPage.name == 1) stories[i].paragraphs[0].parentTextFrames[0].geometricBounds = ([38.8, 15, 48.249, 130]);  

        if (stories[i].appliedParagraphStyle == STYLE && stories[i].paragraphs[0].parentTextFrames[0].parentPage.name == 2) stories[i].paragraphs[0].parentTextFrames[0].geometricBounds = ([9.2, 15, 18.6, 130]);               

        if (stories[i].appliedParagraphStyle == STYLE && stories[i].paragraphs[0].parentTextFrames[0].parentPage.name == 3 && app.activeDocument.documentPreferences.facingPages == true) stories[i].paragraphs[0].parentTextFrames[0].geometricBounds = ([9.2,225, 18.6, 340]);

        if (stories[i].appliedParagraphStyle == STYLE && stories[i].paragraphs[0].parentTextFrames[0].parentPage.name == 3 && app.activeDocument.documentPreferences.facingPages == false) stories[i].paragraphs[0].parentTextFrames[0].geometricBounds = ([9.2,15, 18.6, 130]);

        if (stories[i].appliedParagraphStyle == STYLE && stories[i].paragraphs[0].parentTextFrames[0].parentPage.name == 4) stories[i].paragraphs[0].parentTextFrames[0].move([15,9.2]);

    }

}

 
Replies
  • Currently Being Moderated
    Jun 20, 2012 11:52 AM   in reply to PrntScr

    In ESTK, next to the dropdown where you select which app to target,

    there's that little chain icon. If the chain is broken, even if the app

    is selected, it won't run. The chain has to be closed. Sometimes (not

    sure when) the chain gets broken even if you've got the app targeted.

     

    Might that be it?

     

    Ariel

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 20, 2012 12:38 PM   in reply to PrntScr

    You're probably trying to ungroup groups that do not exist. Once you ungrouped everything, there are no groups, so app.activeDocument.groups.everyItem() is invalid...

     

    Harbs

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 20, 2012 1:43 PM   in reply to PrntScr

    Is the text frame on the pasteboard?

     

    Do you have an inline frame that's overset?

     

    No need to do a lot more error checking...

     

    Harbs

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 20, 2012 1:50 PM   in reply to PrntScr

    If the entire frame is overset, you cannot get its geometricBounds -- because it does not have any...

     

    You'll need to flow your text beforehand if that's the issue.

     

    Harbs

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 20, 2012 1:57 PM   in reply to PrntScr

    Did not get that...

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 20, 2012 2:55 PM   in reply to PrntScr

    Try: var stories = doc.stories.everyItem().getElements();

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points