Highlighted

Placing a snippet

Explorer ,
Feb 12, 2014

Copy link to clipboard

Copied

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

Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

@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

TOPICS
Scripting

Views

1.6K

Likes

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

Placing a snippet

Explorer ,
Feb 12, 2014

Copy link to clipboard

Copied

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

Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

@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

TOPICS
Scripting

Views

1.6K

Likes

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
Feb 12, 2014 0
Adobe Community Professional ,
Feb 12, 2014

Copy link to clipboard

Copied

@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

Likes

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
Reply
Loading...
Feb 12, 2014 0
Explorer ,
Feb 13, 2014

Copy link to clipboard

Copied

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?

Likes

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
Reply
Loading...
Feb 13, 2014 0
Adobe Community Professional ,
Feb 13, 2014

Copy link to clipboard

Copied

@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

Likes

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
Reply
Loading...
Feb 13, 2014 0
Adobe Community Professional ,
Jan 04, 2019

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Jan 04, 2019 1
tjinnz LATEST
Community Beginner ,
May 07, 2020

Copy link to clipboard

Copied

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.

Likes

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
Reply
Loading...
May 07, 2020 0