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

Placing a snippet

Explorer ,
Feb 12, 2014 Feb 12, 2014

How can I make a simple script that places a spesific InDesign snippet in the document, at cursor point?

Just like when draging a snippet in to a document.

Im on a Mac

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

correct answers 1 Correct answer

Community Expert , Feb 12, 2014 Feb 12, 2014

@David André – populate the placeGun with a file (one IDMS file) or with an array of files (more than one IDMS files).

In ExtendScript terms something like the snippets below (dummy code, will not run before defining the variables myEntireFilePath1 etc.):

For more than one file to be placed use an array:

var myFileArray = [myEntireFilePath1, myEntireFilePath2, myEntireFilePath3];

app.documents[0].placeGuns.loadPlaceGun(myFileArray);

One file example:

var myFile = File(myEntireFilePath1);

app.documents[

...
Translate
Community Expert ,
Feb 12, 2014 Feb 12, 2014

@David André – populate the placeGun with a file (one IDMS file) or with an array of files (more than one IDMS files).

In ExtendScript terms something like the snippets below (dummy code, will not run before defining the variables myEntireFilePath1 etc.):

For more than one file to be placed use an array:

var myFileArray = [myEntireFilePath1, myEntireFilePath2, myEntireFilePath3];

app.documents[0].placeGuns.loadPlaceGun(myFileArray);

One file example:

var myFile = File(myEntireFilePath1);

app.documents[0].placeGuns.loadPlaceGun(myFile);

Also see:

http://jongware.mit.edu/idcs6js/pc_PlaceGun.html

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
Explorer ,
Feb 13, 2014 Feb 13, 2014

Perfect! Thank you!

What if you want to place a snippet at the same location that it was made - like when holding down the option-key when placing the snippet?

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 13, 2014 Feb 13, 2014

@David André – hm, good question…

You mean with the place() command, not with the placeGun?

I guess you have to examine (read out) the IDMS file for the original coordinates of the snippet.

Never had done this…

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
Community Expert ,
Jan 04, 2019 Jan 04, 2019

I have to revive this thread.

What if you want to place a snippet at the same location that it was made - like when holding down the option-key when placing the snippet?

Today I had different results when using spread.place( idmsFile.idms ) in a loop through gathered IDMS files of a folder. One spread was added by every iteration of the loop for every snippet placed.

In my first attempt all objects in the placed idms file were positioned at the zero point of a spread.

Now I see that the original positions of the objects are maintained.

I'm coming back when I found the reason.

All tests running with InDesign CC 2019 version 14.0.1.209 on Windows 10.

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
Community Beginner ,
May 07, 2020 May 07, 2020
LATEST

I understand that when there is only one snippet to be placed in an inDesign document using JavaScript, we could do:

var myFile = File(myEntireFilePath1);

app.documents[0].placeGuns.loadPlaceGun(myFile);

 

Now my question is, what if I want to delete myFile after it's placed? How do I do that using JavaScript?

I'm thinkg maybe an eventListener like "afterPlace" would do the job,  but I really have very limited knowledge of scripting, could somebody please help?

 

Thanks heaps.

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