Removing shadows and/or strokes from rectangles in InDesign

I have several InDesign documents with several images on a page, some have drop shadows applied, some have strokes, and some have both. What I want to do is remove the shadows and strokes (or one or the other) from each rectangle or page item that matches the applescript label supplied. Below is my attempt using ‘page item’ which resulted in nothing - no error and no stroke or shadow removal. I also tried ‘rectangle’ in place of ‘page item’, moved it into the ‘tell lProjectDocument’ block, removed the brackets from around “[None]”, and tried setting other properties like stroke weight or shadow opacity to 0 but get only errors or nothing.

Any ideas where I’m going off the rails here?

set lItemLabel to "IMG001" -- Applescript Label
set i to 1 -- Increments within repeat loop
set lProjectDocument to "Macintosh HD:Users:eric:Desktop:TestDoc.indd"
set gDropShadow to ""
set gStroke to ""

on sSSRemover(lItemLabel, i, lProjectDocument, gDropShadow, gStroke)
	tell application "InDesign CS"
		tell lProjectDocument
			tell page i
				if (gDropShadow ≠ "y") then
					tell page item lItemLabel
						set it's shadow color to "[None]" -- Remove drop shadow
					end tell
				end if
				
				if (gStroke ≠ "y") then
					tell page item lItemLabel
						set it's stroke color to "[None]" -- Remove stroke
					end tell
				end if
			end tell
		end tell
	end tell
end sSSRemover

down and dirty solution, you will have to use the examples to finesse it into what you need:

tell application "Adobe InDesign CS2"
	tell document 1
		set x to selection
		set y to item 1 of x
		set stroke color of y to swatch "None"
		set shadow mode of y to none
	end tell
end tell

Would have replied sooner but I wanted to try several variations before I posted, plus I got roped in to house sitting for my brother.

on sRemover(lItemLabel, i, lProjectDocument, gDropShadow, gStroke)
	tell application "InDesign CS"
		tell lProjectDocument
			set X to rectangle lItemLabel
			set y to item 1 of X
			
			if (gDropShadow ≠ "y") then
				set shadow mode of y to none
			end if
			
			if (gStroke ≠ "y") then
				set stroke color of y to swatch "None"
			end if
			
			tell page i
			end tell
		end tell
	end tell
end sRemover

I tried this and it worked perfectly… on the first page of the document ONLY. Unfortunately every page thereafter was unaffected by either the drop shadow or the stroke removal. So I reworked it so I could take it out of the document tell block and put it in the page tell block because I had a similar problem with resizing that was fixed in this way. Below is what I came up with


on sRemover(lItemLabel, i, lProjectDocument, gDropShadow, gStroke)
	tell application "InDesign CS"
		tell lProjectDocument
			tell page i
				
				if (gDropShadow ≠ "y") then
					set shadow mode of (item 1 of rectangle lItemLabel) to none -- Remove drop shadow -- WORKS!
				end if
				
				if (gStroke ≠ "y") then
					set stroke color of (item 1 of rectangle lItemLabel) to "None" -- Set color to None						
				end if
				
			end tell
		end tell
	end tell
end sRemover

However when I run it I get the error Indesign got an error. Some parameter wasn’t understood. BUT the drop shadow was removed. So I commented out the line –set stroke color of (item 1 of rectangle lItemLabel) to “None” – Set color to None and NO errors occurred when the script was run and ALL shadows were removed on every page. Then, just for shits and giggles I tried the line set stroke weight of (item 1 of rectangle lItemLabel) to 0.1 – Add stroke and ran the script - no errors again AND it resized the weight of the stroke.

The problem SEEMS to be with the ‘stroke color’, or at least that is my guess. I tried [None] and none as variants of “None” for the swatch color to no avail. I also tried omitting the word ‘swatch’, tried adding ‘swatch color’, and tried a different swatch name - but nothing works.

Why does the shadow mode line work perfectly but the stroke color line won’t work at all? Is there some way to make the stroke invisible without changing it’s color (tried tint, no dice)?

Back to the drawing board… :smiley:

I will have to see if I can find a version of CS, I think I have one at work. What I wrote works fine in CS2 so there might have been a change to the syntax.

OK the problem is with the color inside the tell block for page i. This changes the reference of the color to read a swatch of page 2. Since swatches are document properties ID does not know how to handle it. To correct the problemm I add in the object reference for the document after the swatch name.

on sRemover(lItemLabel, i, lProjectDocument, gDropShadow, gStroke)
	tell application "InDesign CS"
		tell lProjectDocument
			tell page i
				
				if (gDropShadow ≠ "y") then
					set shadow mode of rectangle lItemLabel to none -- Remove drop shadow -- WORKS!
				end if
				
				if (gStroke ≠ "y") then
					set stroke color of rectangle lItemLabel to swatch "None" of lProjectDocument
				end if
				
			end tell
		end tell
	end tell
end sRemover

tell application "InDesign CS" to set lProjectDocument to document 1

sRemover("One", 2, lProjectDocument, "n", "n")

Thanks Jerome, it works perfectly. I never would have gotten this especially since the stroke weight seemed to execute without incident - it locked me into rigid thinking.