I'm trying to remove an objects from a page with a known name.
I've name the object theLine. It's a drawn line. Under certain conditions, I want to delete it.
Other object is a placed graphic name theImage. Under certain conditions, I want to delete it as well.
Keep trying various iterations, but not even coming close.
Disregarding the object and focusing on the lines, i keep trying iterations of this, but to no avail:
tell application "Adobe InDesign CS5.5"
set theTopRule to the graphic line "SolidSigLineTop"
set theBottomRule to the graphic line "SolidSigLineBottom"
if theSigLineCount = 2 and theSigMicroPrint = "Y" then
delete theTopRule
delete theBottomRule
end if
end tell
results in:
error "Adobe InDesign CS5.5 got an error: Can’t get graphic line \"SolidSigLineTop\"." number -1728 from graphic line "SolidSigLineTop"
try this
tell application "Adobe InDesign CS5.5"
set myDoc to active document
tell myDoc
try
set AllGraphicLines to {"SolidSigLineTop", "SolidSigLineBottom"} as string
set myGraphicline to (every graphic line whose label is in AllGraphicLines)
delete myGraphicline
on error
display dialog "no graphic line/s with this name exists"
end try
end tell
end tell
got the display dialog error in the on error portion of the try statement!
Is the line I drew on the page not a graphic line?!?!?!??!??!
I guess the other option is that the name is not right. I named the element under the layers, the same way I did with some Text Rectangles, etc. Assumed that was right.
the script assumes that you have a line/stroke on your page and that the stroke is labled in "Script Label", (window/utilities/Script Label), as we
are looking for it's label "every graphic line whose label is" .
you say you've named the layer, very differnt.
to label your stroke, select it, open "window/utilities/Script Label" enter your strokes name, deslect the stroke, run the script, works fine here
if you need to delete layers, let me no and ill alter the code for you.
kp
heres some code to delete specific layers
tell application "Adobe InDesign CS5.5"
activate
set myDoc to active document
tell myDoc
try
set AllLayers to {"SolidSigLineTop", "SolidSigLineBottom"} as string
set myLayer to every layer whose name is in AllLayers
delete myLayer
on error
display dialog "no layer/s with this name exists"
end try
end tell
end tell
I wasn't very clear - sorry.
I named the item under the layer.
Layer 1 in the layers window, expanded it, shows all the elements.
Named the items there. In this case, renamed the reference to the line.
Then I can manipulate each element by it's name.
I've used this with text rectangles tons, and it works fine. Never heard of the script label. Must be different for lines?
ahh, i see, sorry, try this, you need ot tell your doc to do what you need it ot do
tell application "Adobe InDesign CS5.5"
activate
set myDoc to active document
tell myDoc
set theTopRule to the graphic line "SolidSigLineTop"
set theBottomRule to the graphic line "SolidSigLineBottom"
delete theTopRule
delete theBottomRule
end tell
end tell
Wonderful. Sorry about the lack of clarity. Applescripting applications has me more than a little confused. Works, of course, now that I explained it completely!
What is the reference for an object placed on the page?? (tiff file added using the place command)
I need to perform the same function to that object as well - possible deletion.
Thanks again. This forum is EXCELLENT!
give this a spin
tell application "Adobe InDesign CS5.5"
activate
set myDoc to active document
tell myDoc
set theTopRule to the graphic line "SolidSigLineTop"
set theBottomRule to the graphic line "SolidSigLineBottom"
delete theTopRule
delete theBottomRule
--delete graphic
set PlacedImage to rectangle "TEST" -- the image is automatically place in a rectangle ![]()
delete PlacedImage
end tell
end tell
North America
Europe, Middle East and Africa
Asia Pacific