Article View: adobe.scripting.indesign
Article #9006Re: Select Layer by Name?
From: Shane_Stanley
Date: Mon, 11 Sep 2006 22:28
Date: Mon, 11 Sep 2006 22:28
53 lines
3041 bytes
3041 bytes
Your main problem is that you're still addressing your rectangle when you
get to the layer bit; you need to address the document for getting the
reference to the layer, and the application for setting the active layer of
the active window. You also need to unlock the layer if it already exists.
Try this:
tell application "Adobe InDesign CS2"
activate
set myDocument to active document
set LayerName to "Keyline Box"
set myPageHeight to page height of document preferences of myDocument
set myPageWidth to page width of document preferences of myDocument
--make layer
tell myDocument
try
-- Does this layer exist ?
set myLayer to layer LayerName
-- if so, unlock it
set the properties of myLayer to {locked:false}
on error
-- No? -> create it
set myLayer to make layer with properties {name:LayerName, layer
color:red, visible:true}
end try
end tell
--make keyline box
tell myDocument
tell page 1
set MyKeylineFrame to make rectangle
tell MyKeylineFrame
set the geometric bounds to {"0", "0", myPageHeight,
myPageWidth} -- Needs to fit to the page size
set the fill color to swatch "None" of myDocument
set the stroke color to swatch "Black" of myDocument
set the stroke tint to 100
set the stroke weight to 1
set the label to "MyKeylineFrame"
set item layer to myLayer
set the properties of myLayer to {locked:true}
end tell
end tell
-- *********************
-- Here is where I need to select "Layer 1 so I can continue working
by hand, not script"
set LayerToActive to layer "Layer 1"
end tell
set active layer of active window to LayerToActive
-- *********************
end tell
--
Shane Stanley <sstanley@myriad-com.com.au>
Technical Details
Message-ID:
<C12C2012.2F9AB%sstanley@myriad-com.com.au>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news.astraweb.com!newsrouter-eu.astraweb.com!feeder.news-service.com!newsfeed.freenet.de!news.albasani.net!news.motzarella.org!news.isoc.lu!webcrossingReferences:
<3bc19367.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,5adc33cad37aeca X-Google-Attributes: gidf939a,public X-Google-Language: ENGLISH,ASCII-7-bit From: Shane_Stanley@adobeforums.com Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news.astraweb.com!newsrouter-eu.astraweb.com!feeder.news-service.com!newsfeed.freenet.de!news.albasani.net!news.motzarella.org!news.isoc.lu!webcrossing Newsgroups: adobe.scripting.indesign Subject: Re: Select Layer by Name? Message-ID: <C12C2012.2F9AB%sstanley@myriad-com.com.au> Date: Mon, 11 Sep 2006 15:28:02 -0700 References: <3bc19367.-1@webcrossing.la2eafNXanI> Lines: 61 Return-Path: <sstanley@myriad-com.com.au> User-Agent: Microsoft-Entourage/11.2.5.060620 Thread-Topic: Select Layer by Name? Thread-Index: AcbV8YrZyWrQDkHkEduPoQARJHm3nA== MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit