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

New at scripting in JS

New Here ,
Feb 10, 2008 Feb 10, 2008
Hello, I want to do a script that help me to make repetitive tasks.

I have to open several INDP documents in the same folder of my INDD document; and I want to copy all the contents of everydocument, and paste it in my InDesign file.

Any idea?

TIA.
TOPICS
Scripting
2.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
Contributor ,
Feb 11, 2008 Feb 11, 2008
Hi pescoxuto
welcome to the world of InDesign scripting. The question is do you need a script or do you want to "do" the script? If the latter you should try working through the tutorials and some of the threads here. You will soon get the idea how to accomplish your task.
And if there are some concrete problems you can come back and there will be some people here ready to help you.
Give it a try. It is well worth it. And good luck.

Ralf
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
New Here ,
Feb 11, 2008 Feb 11, 2008
Hello... I need help to do the script.

I would like to see some examples (open a document, select all...). I have read some tutorials, but I think that some script would be very helpful.

Thank you.
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 Beginner ,
Feb 11, 2008 Feb 11, 2008
you have many example scripts installed with InDesign

robin

--
www.adobescripts.com
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 11, 2008 Feb 11, 2008
The InDesign Scripting guide http://www.adobe.com/products/indesign/scripting/pdfs/InDesignCS3_ScriptingGuide_JS.pdf contains examples of all basic functionality.

A hint to start with: in scripts, don't bother with 'selected text' (well, unless you're writing an interactive thingy). You can copy and move just about anything to anything -- most objects have copy and move methods.
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
New Here ,
Feb 12, 2008 Feb 12, 2008
I have been looking in the tutorials, and some sample scripts (mainly at http://jsid.blogspot.com/) but I just want to know how to work with assignments.

Is it possible to Update or Remove all the assignments in a document with a JS script?

Thank you.
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 12, 2008 Feb 12, 2008
The ESTK 2 Help is your friend. In the Help menu, there is an item called "InDesign CS3 Object Model". Without looking very hard, under 'Assignment' I find these:

Assignment remove ()
Deletes the assignment and its file.

void update ([versionComments: string][, forceSave: bool=false])
Updates the assignment file.
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
New Here ,
Feb 14, 2008 Feb 14, 2008
Hello,

I almost finished my script, but I am having problems with the update script.

I want to know how to fix this code:

if (app.documents.assignment.userName() == "johnny") {
app.documents.assignment.update();
}

Thank you
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 14, 2008 Feb 14, 2008
>app.documents.assignment.userName()

userName is not a function, it's a property. Perhaps that'll help.
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 14, 2008 Feb 14, 2008
If userName is a property you wouldn't expect the parentheses.
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
New Here ,
Feb 14, 2008 Feb 14, 2008
But I am still having problems with the line:

if (app.documents.assignment.userName == "johnny")

it doesn't work.
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 14, 2008 Feb 14, 2008
For the current document you need
>if (app.activeDocument.assignment.userName == "johnny")
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
New Here ,
Feb 14, 2008 Feb 14, 2008
I am afraid it doesn't work.

JavaScript Error!
Error Number: 55
Error String: Object does not support the property or method "assignment"
Line: 13
Source: if (app.activeDocument.assignment.userName == "johnny") {

any idea¿?

Thanks.
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 14, 2008 Feb 14, 2008
Check the ESTK help -- it shows that the Document class (of which app.activeDocument is an instance) indeed does not have a property (or method) "assignment". What it
i does
have, is a property "assignments" ("A collection of assignments." -- note the 's' at the end). Which makes perfect sense, because there can be more than a single assigment (singular) per document.
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
Participant ,
Feb 14, 2008 Feb 14, 2008
Just like a page or a spread (and lots of other objects), an assignment is one of a collection. A document can have any number of assignments.

If you look at the Document property names, you'll see that the property is named:

assignments

Plural.

To refer to one of them, you need to indicate which one. If you know there is but one, then you can write:

if (app.activeDocument.assignments[0].userName == "johnny") {

But if there are more than just the one, you'll need to pick out the one you want. I see that Assignment objects have names, so, if you know the name, you could write:

if (app.activeDocument.assignments.item("TheName").userName == "johnny") {

Dave
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 14, 2008 Feb 14, 2008
To tell you the truth, I haven't a clue what an assignment is. But anyway, if you check the scripting reference -- which you will do if you're new at scripting InDesign -- you'll see that there is a collection called "assignments". The first assignment in that collection is addressed as "assignments[0]", the second as "assignment[1]", etc. So what you actually need is
>if (app.activeDocument.assignments[0].userName == "johnny")

to check the username of the first assignment.

Peter
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
New Here ,
Feb 15, 2008 Feb 15, 2008
I am using ESTK 2, but it's quite complicated for me to achieve something.

Now I created the if sentence, and it is working, but I don't know how to force this assignmet to be updated.

I tried with assignment.update(); but it doesn't seem to work.

Thanks for all your help.
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
Explorer ,
Feb 15, 2008 Feb 15, 2008
>To tell you the truth, I haven't a clue what an assignment is.

An assignment is a collection of things you exported to be worked on in InCopy. Usually a bunch of text files in XML syntax, similar to tagged text files.
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 16, 2008 Feb 16, 2008
Thanks Gerald.

Peter
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
New Here ,
Feb 21, 2008 Feb 21, 2008
Any idea about running the assingment.update(); script?

Now I have:

if (app.activeDocument.assignments.item("np3n1f-Text") ) {
Assignment.update ();
}

But it does't work.

thank you
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
Valorous Hero ,
Feb 21, 2008 Feb 21, 2008
Hi pescoxuto,

if (app.activeDocument.assignments.item("np3n1f-Text") != null ) {
app.activeDocument.assignments.item("np3n1f-Text").update();
}

Kasyan
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
New Here ,
Feb 23, 2008 Feb 23, 2008
Hi everybody,

the last version of my code still doesn't work:

if (app.activeDocument.assignments.length()) {
app.activeDocument.assignments.everyItem().update();
app.activeDocument.assignments.everyItem().remove();
}

any idea?

TIA
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 23, 2008 Feb 23, 2008
It would really REALLY help if you state the error and possibly the line number of that error.

app.activeDocument.assignments.length is not a function.
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
Participant ,
Feb 23, 2008 Feb 23, 2008
The degrees of "not working" are vast any many.

When checking the size of a collection (of any object) use either:

Collection.length

or

Collection.count()

They return the same result. But:

Collection.length()

returns an error because length is a property, not a method.

Dave
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
New Here ,
Feb 24, 2008 Feb 24, 2008
Hello,

All I want to get is while exists any assignment, update the content of the stories and then remove the assignment, to keep only the text of the story and unlink from the assignment.

The error is:

JavaScript Error!
Error Number: 24
Error String: app.activeDocument.assignments.length is not a function
Line 13
Source: if (app.activeDocument.assignments.length()) {

Thank you very much.
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