Article View: adobe.scripting.indesign
Article #18800Re: Creating objects won't listen to "Properties:..." [AS]
From: CouponBoy
Date: Tue, 18 Feb 2003 20:02
Date: Tue, 18 Feb 2003 20:02
146 lines
8826 bytes
8826 bytes
Hi Olav,
no, that doesn't seem to work properly either. I also tried adding quotes around 1, and using "swatch" instead of "color" to specify the color. Perhaps it is because it's inside of a "tell page" statement? Its what's inside of the script that you had sent me a while back.
Short rant: I've been scripting for a couple years now, but today I am getting really frustrated. So many statements that seem to be so logical to put together get nothing but the circular argument (like I described above). Is there a way to make statements more flexible in how they are interpreted? It seems like every time I try 1 thing, it doesn't work the way a different program would interpret it, or even a similar command for a different object in the same program. Maybe my brain is fried, I don't know.
It's big, but here is the whole script as I have it so far:
Thank for your help :-)
-------------------------
--PlaceAllFilesWithFileName
--This script attempts to place all files found in a specified folder and adds a label
--to each frame containing the file name only (is possible to add full path to image).
--Set up the page layout by entering the number of rows and columns you want.
display dialog "How many rows down do you need?" default answer "4" with icon 1
set myNumberOfRows to (text returned of result) as number
display dialog "How many columns across do you need?" default answer "4" with icon 1
set myNumberOfColumns to (text returned of result) as number
--If you don't want to remove empty frames, set myRemoveEmptyFrames to false.
set myRemoveEmptyFrames to true
display dialog "Do you want to keep extra unfilled boxes or delete them?" buttons {"Keep", "Delete"} with icon 1 default button 2
if button returned of result is "Keep" then set myRemoveEmptyFrames to false
--ask for the title box on top
display dialog "What title do you want on the top of the page?" with icon 1 default answer "Catalog"
set myTitle to text returned of result
--myOffset defines the height of the text frame for the labels.
set myOffset to 18
set myFramesPerPage to (myNumberOfRows * myNumberOfColumns)
--Display a "Choose Folder" dialog box.
set myFolder to choose folder with prompt "Select the folder containing the files you want to place."
tell application "Finder"
set myNumberOfFrames to (count files in folder myFolder)
set myFiles to files of myFolder
--The following line used to work in Mac OS 9.x, but doesn't seem to in OS 10.1.5/AppleScript 1.8.3
set myFiles to sort files of myFolder by name
end tell
tell application "InDesign 2.0.2"
activate
set myDocument to make document
--Set the measurement units to points if they're not already set to points.
set myViewPreferences to view preferences of myDocument
if horizontal measurement units of myViewPreferences is not points then
set myOldXUnits to horizontal measurement units of myViewPreferences
set myResetXUnits to true
set horizontal measurement units of myViewPreferences to points
else
set myResetXUnits to false
end if
if vertical measurement units of myViewPreferences is not points then
set myOldYUnits to horizontal measurement units of myViewPreferences
set myResetYUnits to true
set vertical measurement units of myViewPreferences to points
else
set myResetYUnits to false
end if
--Create a paragraph style for the label
tell document 1 --tell doc 1 or else this stuff sets app prefs!
set myParagraphStyle to make paragraph style with properties {name:"Label", point size:9, applied font:"Helvetica Neue", font style:"86 Heavy Italic", horizontal scale:75}
set myParagraphStyle2 to make paragraph style with properties {name:"Header", point size:18, applied font:"Helvetica Neue", font style:"86 Heavy Italic", fill color:swatch "Paper"}
set myParagraphStyle2 to make paragraph style with properties {name:"PageNum", point size:9, applied font:"Helvetica Neue", font style:"86 Heavy Italic", fill color:swatch "Paper", justification:right}
set myDocumentPreferences to document preferences of myDocument
set myNumberOfPages to round (myNumberOfFrames / myFramesPerPage) rounding up
set pages per spread of myDocumentPreferences to 1
set pages per document of myDocumentPreferences to myNumberOfPages
tell every page
tell margin preferences
set margin top to "6p"
end tell
end tell
set myMarginPreferences to margin preferences of page 1 of myDocument
set myLeftMargin to margin left of myMarginPreferences
set myRightMargin to margin right of myMarginPreferences
set myTopMargin to margin top of myMarginPreferences
set myBottomMargin to margin bottom of myMarginPreferences
set myLiveWidth to (page width of myDocumentPreferences) - (myLeftMargin + myRightMargin)
set myLiveHeight to (page height of myDocumentPreferences) - (myTopMargin + myBottomMargin)
set myFrameWidth to (myLiveWidth / myNumberOfColumns)
set myFrameHeight to (myLiveHeight / myNumberOfRows)
set myPages to pages of myDocument
tell text frame preferences
set inset spacing to "3pt"
end tell
end tell
repeat with myCounter from (count myPages) to 1 by -1
set myPage to item myCounter of myPages
repeat with myRowCounter from myNumberOfRows to 1 by -1
set myY1 to myTopMargin + (myFrameHeight * (myRowCounter - 1))
set myY2 to myTopMargin + (myFrameHeight * myRowCounter) - 6 --6 is point space between boxes
repeat with myColumnCounter from myNumberOfColumns to 1 by -1
set myX1 to myLeftMargin + (myFrameWidth * (myColumnCounter - 1))
set myX2 to myLeftMargin + (myFrameWidth * myColumnCounter) - 6
tell myPage
set myBox to make rectangle with properties {geometric bounds:{myY1, myX1, myY2 - myOffset + 1, myX2}}
set myText to make text frame with properties {geometric bounds:{myY2 - myOffset, myX1, myY2, myX2}}
end tell
--setting this outside of the rest of the make box statement is extremely fucked up!
set stroke weight of myBox to "1"
set stroke color of myBox to swatch "Black" of document 1
set stroke weight of myText to "1"
set stroke color of myText to swatch "Black" of document 1
end repeat
end repeat
end repeat
repeat with myCounter from 1 to myNumberOfFrames
set myFileName to item myCounter of myFiles as string
set myRectangle to rectangle myCounter of myDocument
tell myRectangle
place myFileName
end tell
--Position/fit the graphic in the frame.
fit myRectangle given content to frame
fit myRectangle given proportionally
fit myRectangle given center content
--Add the file name to the text frame.
tell text frame myCounter of myDocument
tell application "Finder" --remove this Finder tell for full path
set myImagesName to get name of file myFileName as string
end tell
set contents to (myImagesName as string) --change myImagesName to myFileName for full path
set applied paragraph style of paragraph 1 to paragraph style "Label" of myDocument
end tell
end repeat
--make a text box and put the title in it
repeat with W from 1 to myNumberOfPages
tell document 1
tell page W
set myBigNameTextBox to make text frame with properties {geometric bounds:{36, 36, 60, 576}, contents:myTitle}
end tell
set fill color of myBigNameTextBox to swatch "Black"
end tell
--JC! this needs to be so specific outside of other references
set applied paragraph style of paragraph 1 of myBigNameTextBox to paragraph style "Header" of document 1
end repeat
--make a text box and put the page number in it
repeat with W from 1 to myNumberOfPages
tell document 1
tell text frame preferences
set vertical justification to bottom
end tell
tell page W
set myPNBox to make text frame with properties {geometric bounds:{36, 432, 60, 576}, contents:"page " & W & " of " & myNumberOfPages}
end tell
set fill color of myPNBox to swatch "No
Technical Details
Message-ID:
<1de7e876.1@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!easynet-quince!easynet.net!feed1.news.be.easynet.net!skynet.be!skynet.be!bnewspeer00.bru.ops.eu.uu.net!lnewspeer00.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<1de7e876.-1@WebX.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,5f85c984a949f4e X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-02-18 12:08:07 PST From: CouponBoy <chris.paveglio@clippermagazine.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!easynet-quince!easynet.net!feed1.news.be.easynet.net!skynet.be!skynet.be!bnewspeer00.bru.ops.eu.uu.net!lnewspeer00.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: Creating objects won't listen to "Properties:..." [AS] Message-ID: <1de7e876.1@WebX.la2eafNXanI> Date: Tue, 18 Feb 2003 12:02:50 -0800 References: <1de7e876.-1@WebX.la2eafNXanI> Lines: 187 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit