🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.scripting.indesign
4 messages
4 total messages Started by Justin_Monsees Mon, 29 Dec 2008 00:40
Retrieving index of a selected Rectangle/Image
#2339
Author: Justin_Monsees
Date: Mon, 29 Dec 2008 00:40
7 lines
1173 bytes
I am currently working on a project in which I need to import images and attach captions to them. I would like to create a script that would allow me to select an image and then run the script to attach a textbox beneath it with a caption. In order to do this I need the index number of the select Image/Rectangle. I tried using the Document.selection property but that returns a Rectangle. Using Document.selection.index only returns "undefined."

What is the proper syntax to retrieve the index number of Rectangle/Image that is currently selected in a document?

Thanks,

Justin M.
Re: Retrieving index of a selected Rectangle/Image
#2340
Author: Dave_Saunders
Date: Mon, 29 Dec 2008 01:01
5 lines
914 bytes
Why do you need the index? Isn't a reference derived from the selection good enough?

It would help you get specific advice if you mentioned which version of InDesign and which scripting language. Perhaps if you posted some code or a more detailed description of what you have in mind.

Dave
Re: Retrieving index of a selected Rectangle/Image
#2341
Author: Justin_Monsees
Date: Mon, 29 Dec 2008 04:23
13 lines
1597 bytes
Dave,

you're right. I'm trying to accomplish this using Javascript. Essentially I'm trying to modify the "LabelGraphics.jsx" file that I was able to download as a sample script. This script adds a text box underneath all of graphics. I just want it to add a text box to the one that is currently selected. Here's the piece of code that I'm trying to modify. Let me know if you need more information.

function myAddLabels(myLabelType, myLabelHeight, myLabelOffset, myLabelStyleName){
	var myDocument = app.documents.item(0);
	var myGraphics = myDocument.allGraphics;
	myLabelStyle = myDocument.paragraphStyles.item(myLabelStyleName);
	for(var myCounter = 0; myCounter < myGraphics.length; myCounter++){ 		myAddLabel(myDocument, myGraphics[myCounter], myLabelType, myLabelHeight, myLabelOffset, myLabelStyle); 	} }

Instead of using a "for" loop I only want to reference the currently selected rectangle.

Justin M.
Re: Retrieving index of a selected Rectangle/Image
#2342
Author: Robert Tkaczyk
Date: Mon, 29 Dec 2008 09:37
8 lines
1014 bytes
I'm not JS man, but this should work for you:

  myAddLabel(myDocument, myDocument.selection.item(0), myLabelType, myLabelHeight, myLabelOffset, myLabelStyle);

robin

-- 
www.adobescripts.com
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads