InDesign CS2 Checking Contents on Layers

Hi All,

I have a document, in which only two layers exist, one is GrapLayer, and another is TxtLayer. On GrapLayer only Graphics should be there and on TxtLayer only text element should be there. How can be check it through Applescript.

I have post the same message at Adobe forum. So please don’t get confused.

Thanks
Pooja

Hi All,

I try to do it, but here is some problem.

ell application “Adobe InDesign CS2”
set theDoc to the front document
tell theDoc
set CMYKLayer to layer “CMYK”
set theList to every graphic of page 1 whose item layer is CMYKLayer
end tell
end tell
theList

Regards
Pooja

This should do it for you.

tell application "Adobe InDesign CS2"
	set theDoc to the front document
	tell theDoc
		set CMYKLayer to all graphics of layer "CMYK"
	end tell
end tell

Chris,

Your script does indeed return a list of graphics placed on the layer indicated. What might work better is to get a list of all page items that are not text and not on the designated layer and move those, then do the same for the text that is not on the designated layer. The below should do the former and with slight adjustments the latter as well.

tell application "InDesign CS"
	set theDoc to the front document
	tell theDoc
		set CMYKLayer to layer "CMYK"
		set item layer of (every page item of page 1 whose content type is not text type and item layer is not CMYKLayer) to CMYKLayer
	end tell
end tell

yes - i was simply trying to help him out with the part he was getting stuck on. Indesign can be extremely confusing with Applescript - and sometimes you just need that one peice of information.

One thing you didn’t put in your script was a reference to testlayer

set testlayer to layer "testlayer"

should be added in right after the doc tell

Thanks
Chris

:)Hi All

Thanks a lot to every one’s input.

Jerome moving on the particular layer is fine, but first I want to check it and display dialog for the user, please read below:

I want to check that no text frame should lie on GrapLayer and no graphics should lie on TxtLayer. If any graphic present on TxtLayer it shows a dialog that “Graphics not proper placed” else dialog shows “garphics are ok”.
And here we can ask to user you want to move or not if they say yes then it should move, other reume next.

And same for the text frame. If any text frame exist on GrapLayer it shws dialog “Text Frame not proper placed” else dialog will show “Text Frames are ok”.
And here we can ask to user you want to move or not if they say yes then it should move, other reume next.

I have try to run your script, but it is not wroking error is on the below line:

set item layer of (every page item of page 1 whose content type is not text type and item layer is not CMYKLayer) to CMYKLayer

And error is:

Cann’t set item layer of every page item of page 1 of document “tt.indd” whose content type is not equal to text type and item layer is not equal to layer id 123 of document “tt.indd”

Thanks
Pooja

Hi All

Below is my code it is working fine. But few problem is there, if I place any graphics on TxtLayer it not show “Graphic Yes”.


tell application "Adobe InDesign CS2"
	set theDoc to the front document
	tell theDoc
		set GrapList to all graphics of layer "GrapLayer"
		set TxtList to text frames of layer "TxtLayer"
		if (exists graphics of layer "TxtLayer") is true then
			display dialog "Graphics Yes"
		else
			display dialog "Graphics NO"
		end if
		if (exists text frames of layer "GrapLayer") is true then
			display dialog "Frame Yes"
		else
			display dialog "Frame NO"
		end if
	end tell
end tell

And here I want to move on desired layer.

Thanks
Pooja

The reason that you were getting the error with the code I posted earlier is probably because there were no objects that met the test. This could be cought and dealt with in a try statement, or using an if exists statement as you do in your code. The next question would be in how you want to deal with the offending objects, move them one at a time or as a group. If you want to move them one at a time then you need to get a list of the objects and step through them one at a time…ie potentially lots of dialog boxes. If you want to move them all at once then you should be able to modify the statement I gave earlier to do it without much trouble to handle this. You would probably want to change your dialog box statement’s to more accuratly reflect what you need them to do as well.

The one potential problem with stepping through the offending objects one at a time is giving the user feedback as to what object is being referred to. You might be able to get acceptable results from making it the current selection and ensuring that the selection is visible in the window, more code to add and trouble shoot since InDesign allows you to set a selection outside of the visible area of the window. If this were the route that you were looking to take it would also be good to add an “Undo Last” option so that the opperator could undo a move that had unexpected results.