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

Improved Hello World script error?

New Here ,
Mar 07, 2019 Mar 07, 2019

Copy link to clipboard

Copied

Hey all, was asked by my job to learn AppleScript for some automation and I've been butting my head against the wall with the tutorial Improved Hello World script.  I'm having difficulty identifying what exactly is incorrect in both the script I wrote following the tutorial as well as the script provided by Adobe as they both return the same error.  Any help would be appreciated.  The error is as follows:

Error Number: -10006

Error String: Adobe InDesign CC 019 got an error: Can't set geometric bounds of text frame 1 of page 1 of document id 1 to {0.5, 0.5, 10.5, 8.0}.

Here's the script:

Screen Shot 2019-03-07 at 4.26.45 PM.png

TOPICS
Scripting

Views

1.2K

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

correct answers 1 Correct answer

Community Expert , Mar 07, 2019 Mar 07, 2019

It looks that you are working on the open document, and try to set the geometric bounds of the textframe on the first page. Can you check if the page indeed has a textframe on it.

-Manan

Votes

Translate

Translate
Community Expert ,
Mar 07, 2019 Mar 07, 2019

Copy link to clipboard

Copied

It looks that you are working on the open document, and try to set the geometric bounds of the textframe on the first page. Can you check if the page indeed has a textframe on it.

-Manan

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 ,
Mar 08, 2019 Mar 08, 2019

Copy link to clipboard

Copied

Lord help me, Manan.  Sure enough even the documentation mentions to make sure you've run the original sample HelloWorld script to make it work.  It works fine if you've run that first, and just makes that size larger.  Given the name "Improved" instead of "Improve" I thought it would be making a new text box even though looking at it again clearly there's not even content set for it.  I have since been attempting to tweak the improved script to also create a text box with those properties.  I have successfully gotten it to create the text frame to the right size and print text in it, but I can't get the set point size and set justification to work properly.  Do I have something in the wrong place?  I've tried moving a few things.  Screen Shot 2019-03-08 at 1.35.35 PM.png

Specifically the error reads as follows: Can't set point size of text frame 1 of page 1 of document id 23 to 72

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 ,
Mar 09, 2019 Mar 09, 2019

Copy link to clipboard

Copied

Hi,

I don't know Applescript at all, but playing around with the code that you gave, i have a working version. Setting the property of parentStory would work. Try something like the following

 

  set contents of myTextFrame to "You did it"

  set myStory to parent story of myTextFrame

  tell myStory

       set applied font to myFont

       set point size to 72

       set justification to center align

  end tell

Hope this helps

-Manan

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 ,
Mar 11, 2019 Mar 11, 2019

Copy link to clipboard

Copied

Hi again,

Just reading through the script you wrote, here are some problems:

1. You did not define the variable for myFont (but it is inside a try statement so it won't error).

2. You are trying to set properties for the text frame that can only be set to a text reference (paragraph 1)

3. Point size needs to be a string value if the measurement units for your document is not points

So here it is (without the handler to get the live bounds for the page-you can add that):

tell application "Adobe InDesign CC 2019"

  set myFont to font "Helvetica"

  set myDocument to make document

  tell myDocument

     set myPage to page 1

     set myTextFrame to make text frame

  end tell

  set myBounds to my myGetBounds(myDocument, myPage)

  set geometric bounds of myTextFrame to myBounds

  set contents of myTextFrame to "You did it!"

  tell paragraph 1 of myTextFrame

        set applied font to myFont

        set point size to "72 pts"

        set justification to center align

   end tell

end tell

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 ,
Mar 11, 2019 Mar 11, 2019

Copy link to clipboard

Copied

Hi,

In order for the script to work you need a text frame on page 1 of an open document that has text (a paragraph).

What you also need to be aware of is the measurement unit that is in effect when you are running the script.

If the current measurement unit is inches, trying to set point size to 72 won't work. Make sure the current measurement unit in effect for  setting font point size is points. For this, add the following for the first line after the tell application statement at the top of your script:

  set measurement unit of script preferences to points

Script preferences are persistent so you need to be aware of its settings.  If you prefer the script to work in another measurement system, you can use picas, inches, millimeters, centimeters, or inches decimal. But with any measurement setting other than points, your font point size will need to be specified as a string value:

  set point size to "72 pts"

Hope this helps,

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 ,
Apr 22, 2021 Apr 22, 2021

Copy link to clipboard

Copied

why doesen't the hello world script work?  I'm trying to use the js one it it has an error.  the answer for apple script dosen't help me.  any ideas?

 

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 ,
Apr 22, 2021 Apr 22, 2021

Copy link to clipboard

Copied

Do you mean this one from the ID Scripting document? 

var myDocument = app.documents.add();
var myTextFrame = myDocument.pages.item(0).textFrames.add();
myTextFrame.geometricBounds = ["6p", "6p", "24p", "24p"];
myTextFrame.contents = "Hello World!";

If so, what's the error? Does your code exactly match this code? 

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 ,
Apr 22, 2021 Apr 22, 2021

Copy link to clipboard

Copied

Hello,

I was referring to the "Improved Hello World" script. A couple of things:
the pdf file is protected, so I wasn't able to just copy and paste from the
pdf file, so I used the files that came from the downloaded
file C:\Users\johnm\Downloads\scripting_sdk_16.1.0.020.zip\scripting\scripts\scripting_tutorial\indesign\javascript
that
I copied to the scripts folder and was able to run; with an error. I am
attaching copies of what happened on my windows computer.

I hope scripting is worth it, I'm getting off to bad start. If for
whatever reason your documentation is protected, the download files should
work. it could be that an experienced user could unlock the pdf file; the
best I could do was print the page to a pdf the convert it to Word, then
copy past it into notepad (bad start huh?),

If I continue to use InDesign, the last three hours with the product will
be forgotten, but my feedback on my last three hours should somehow creep
into your documentation and customer support. Lastly, in the title to my
query, I stated "Improved Hellow World" script. You wasted our time by
answering a question that wasn't asked.

This product is twenty years old, so I must be missing something, so clue
me in.

Thanks,
- John

[John. This is a public forum. Your personal contact inforamtion was removed for your protection.]

 

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 ,
Apr 22, 2021 Apr 22, 2021

Copy link to clipboard

Copied

John, 

 

1) We are not Adobe employees. You are in a user forum. ACPs are just active members of these forums who try to help folks like you. 

2) Extendscripting has a pretty steep learning curve, and is not well-documented, as you are discovering. 

3) Sorry I missed the title of the post; I don't see any error files posted. Are you running the script with a document open? Not sure about the file protected status of the PDF. The best way to learn to script though, I think, is to tghe type the code out. 

 

Hope that helps, and good luck. 

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 ,
Apr 22, 2021 Apr 22, 2021

Copy link to clipboard

Copied

Hello,

No worries, I understand.

Thanks,
- John

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 ,
Apr 23, 2021 Apr 23, 2021

Copy link to clipboard

Copied

I copied to the scripts folder and was able to run; with an error. I am
attaching copies of what happened on my windows computer.

 

I think you forgot to add the screen capture of your error message—click the picture icon when you post to share a capture.

 

The HelloWorld script worked fine for me from ExtendScript Toolkit:

 

Screen Shot 18.png

 

To compile scripts you will need a script editor like ExtendScript Toolkit or Visual Studio Code with the ExtendScript extention—Visual Studio is a 64 bit app, ExtendScript is 32-bit. You can also save JavaScripts with a .jsx extention from a plain text editor—if the code is not saved as plain text you will get an error running from the Scripts panel

 

You can find the entire InDesign API here:

 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#about.html

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 ,
Apr 23, 2021 Apr 23, 2021

Copy link to clipboard

Copied

LATEST
Hello Rob,

Thanks for your comments, but I’m going to just do I the non- scripting way for now.
- John


Sent from my iPad

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