Skip to main content
Known Participant
October 9, 2020
Answered

javascript / pen tool / help!

  • October 9, 2020
  • 3 replies
  • 993 views

hi. Help me!

JavaScript Inserts Image into a rectangles Made of Pan tool

 

var i = 0;
for (var p = 1; p <= myPages.length - 1; p++) {
for (var n = 1; n <= 10; n++) {
if (i <= myOutGroupPics1.length - 1) {
myPages[p].rectangles
.item("myOutdoorGroup" + n)
.place(File(myOutGroupFolder1 + "/" + myOutGroupPics1[i].name));
i++;
}
}
}

This topic has been closed for replies.
Correct answer Manan Joshi

If you have the selection of the object you can place the image into it as follows

app.selection[0].place(File("/Users/manan/Downloads/download.jpeg")) //Change the path

 If you have a name applied to the object that will help you identify it, similar to what you are doing in your code, you could do the following

app.documents[0].pageItems.itemByName("test").place(File("/Users/manan/Downloads/download.jpeg"))

Here test is the name of the object(visible in the layers panel, you can change it to anything that you want)

-Manan

3 replies

Manan JoshiCommunity ExpertCorrect answer
Community Expert
October 12, 2020

If you have the selection of the object you can place the image into it as follows

app.selection[0].place(File("/Users/manan/Downloads/download.jpeg")) //Change the path

 If you have a name applied to the object that will help you identify it, similar to what you are doing in your code, you could do the following

app.documents[0].pageItems.itemByName("test").place(File("/Users/manan/Downloads/download.jpeg"))

Here test is the name of the object(visible in the layers panel, you can change it to anything that you want)

-Manan

-Manan
Known Participant
October 13, 2020

Thank you for your help. Manan
I solved the problem because of you.

Have a nice day.

Community Expert
October 10, 2020

What are you trying to do, can you send the sample document and show me what you are trying to place and into which element?

-Manan

-Manan
Known Participant
October 10, 2020

Known Participant
October 10, 2020

var i = 0;
for (var p = 1; p <= myPages.length - 1; p++) {
for (var n = 1; n <= 10; n++) {
if (i <= myOutGroupPics1.length - 1) {
myPages[p].rectangles(What should I change this place to?)
.item("myOutdoorGroup" + n)
.place(File(myOutGroupFolder1 + "/" + myOutGroupPics1[i].name));
i++;
}
}
}