-
1. Re: [JS][CC] Help needed with targeting pasted item
Trevorׅ Nov 28, 2013 10:21 AM (in response to Roy Marshall)Hi Roy,
Seems to me you are using copy instead of duplicate, if so don't!
a=app.selection[0]
b = a.duplicate([3,3])
b.fillColor = "Black"
Works for me
Trevor
-
2. Re: [JS][CC] Help needed with targeting pasted item
Roy Marshall Nov 28, 2013 12:07 PM (in response to Trevorׅ)Hi Trevor.
Thanks for the advise.
I tried using that, but as I am copying a selected chunk of text, this method doesn't seem to work for me.
Any other pointers?
Cheers
Roy
-
3. Re: [JS][CC] Help needed with targeting pasted item
Laubender Nov 28, 2013 1:36 PM (in response to Roy Marshall)@Roy – Does the following snippet work for you (tested in InDesign CS5.5)?
Selection must be a text selection:
app.copy(app.selection[0]); app.select(null); app.paste(); var myNewTextFrame = app.documents[0].windows[0].activePage.textFrames[0]; myNewTextFrame.fillColor = "Yellow";
Of course, you could run into trouble, if the selection exceeds the current spread…
Uwe
-
4. Re: [JS][CC] Help needed with targeting pasted item
Laubender Nov 28, 2013 1:42 PM (in response to Laubender)And my snippet is not bullet proof, if the pasted text will land outside a page on the pasteboard…
Ok. Back to the drawing board.
Uweq
-
5. Re: [JS][CC] Help needed with targeting pasted item
Laubender Nov 28, 2013 2:06 PM (in response to Laubender)Now, the following should work:
app.copy(app.selection[0]); app.select(null); app.paste(); var d=app.documents[0]; var mySpread = d.windows[0].activeSpread; var textFramesIDArray = new Array(); for(var n=0; n<mySpread.textFrames.length;n++){ textFramesIDArray[n] = mySpread.textFrames[n].id; }; textFramesIDArray.sort().reverse(); myNewTextFrame = d.pageItems.itemByID(textFramesIDArray[0]); myNewTextFrame.fillColor = "Yellow";Uwe
-
6. Re: [JS][CC] Help needed with targeting pasted item
Laubender Nov 28, 2013 2:08 PM (in response to Laubender)Better use that line:
myNewTextFrame = d.pageItems.itemByID(textFramesIDArray[0]).getElements()[0];
Uwe
-
7. Re: [JS][CC] Help needed with targeting pasted item
Roy Marshall Nov 28, 2013 2:44 PM (in response to Laubender)Aha!
I will give this a go as soon as I can.
I was thinking about a similar method in getting an array with the ID's before, and after the paste, and comparing to get the new ID, but your method looks cleaner, and probably less processor heavy!
I will feedback as son as I get to apply this.
Thanks again Uwe,
Roy
-
8. Re: [JS][CC] Help needed with targeting pasted item
Roy Marshall Nov 28, 2013 3:30 PM (in response to Roy Marshall)Awesome! Thanks again Uwe
-
9. Re: [JS][CC] Help needed with targeting pasted item
Trevorׅ Nov 28, 2013 5:08 PM (in response to Roy Marshall)Roy,
I'm glad you got your answer but I don't understand what you gain by using the copy and pase method and not the duplicate method like this:
a=app.selection[0]
b=app.activeDocument.pages[0].textFrames.add({geometricBounds:[50,50,150,150]})
a.duplicate(LocationOptions.AT_BEGINNING,b)
b.strokeColor="Black"
Trevor
-
10. Re: [JS][CC] Help needed with targeting pasted item
Laubender Nov 29, 2013 2:10 AM (in response to Trevorׅ)@Trevor – I'm not sure either…
There are occasions where copy/paste results are different from duplicated ones.
But this is rare and touches things (call it "limitations" or maybe "bugs") that have to do with button objects inside MultiStateObjects or something… (don't want to go into details here).Uwe


