Hi Folks-
Does anyone know why this snippet runs correctly on its own but not when at [beginning/middle/end] of the full script?
alone:
tell application "Adobe InDesign CS2"
set fontRef to font "Avenir"
set properties of text defaults to {applied font:fontRef, font style:"35 Light"}
end tell
result: Default font set to Avenir 35 Light (correct)
full script:
tell application "Adobe InDesign CS2"
set fontRef to font "Avenir"
set properties of text defaults to {applied font:fontRef, font style:"35 Light"}
end tell
set vmyDesktop to alias ((path to desktop as string))
tell application "Adobe InDesign CS2"
set vdocName to name of front document as string
end tell
do shell script "echo " & quoted form of vdocName & " | /usr/bin/grep -o '^[0-9]*'"
set vdigits to result
tell application "Finder"
set vLocationFile to ((vmyDesktop as string) & vdigits as string) & "_pp.pdf"
set vcompare to 10000 --starts with 10,000s folder
repeat
set vcompare to vcompare + 1000 -- increments by 1000
if vcompare > vdigits then exit repeat -- gets out of comparision loop when comparison number is 1000 greater than file number
end repeat
set vfolder to ((vcompare as integer) - 1000) -- subtracts 1000 from comparison number to get correct folder number to save to
set vtens to vfolder / 1000 as integer -- cuts off 3 zeros from folder number to prep number for comma addition
set vactualfolder to (vtens as string) & "," & "000" --adds comma and three zeros to make folder number user friendly and compatible with our system
set vfullpath to "Users:SHARED:_PDF Page Proofs (low res):PDF Page Proofs #" & vactualfolder -- takes partial path and adds correct thousands folder to complete path
set vpartialnewfoldername to "PDF Page Proofs #" -- sets up first part of folder name
set vnewfoldername to vpartialnewfoldername & vactualfolder --creates full folder name
vnewfoldername as string
tell application "Finder"
if not (exists folder vfullpath) then --checks to see if folder exists
make new folder at "Users:SHARED:_PDF Page Proofs (low res)" with properties {name:vnewfoldername} -- if no folder exists, creates new one
end if
end tell
set vexport to ((vfullpath as string) & ":" & vdigits as string) & "_pp.pdf"
tell application "Adobe InDesign CS2"
set vjobpath to file path of active document
set vjobexport to ((vjobpath as string) & vdigits as string) & "_pp.pdf"
set page range of PDF export preferences to all pages
export document 1 format PDF type to vexport using PDF export preset "[Smallest File Size]" without showing options -- exports to pp folder
export document 1 format PDF type to vLocationFile using PDF export preset "[Smallest File Size]" without showing options -- exports to desktop
export document 1 format PDF type to vjobexport using PDF export preset "[Smallest File Size]" without showing options -- exports to job folder
end tell
end tell
result: Default font set to Avenir [Regular] (incorrect)
thanks,
Ralph
Hi Ralph,
here’s the definition from InDesignCS3 Scripting Guide:
[i]Setting Text Defaults
You can set text defaults for both the application and each document. Text defaults for the application determine the text defaults in all new documents; text defaults for a document set the formatting of all new text objects in that document. (For the complete script, see TextDefaults.)[/i]
One note:
alias ((path to desktop as string)) is tautologous.
path to desktop is an alias
Thanks Stephan et al-
I was hoping to put this default setting into scripts as a sort of ‘reset’ because we’ve found that the font setting will sometimes revert to Times, despite having set it previously to our company standard of Avenir (with no documents open). This sometimes results in the first insertion point retaining the Times font, which has proven to be problematic for one of our vendors’ RIPs. Ideally, this would be done with no documents open (as stipulated in InDesign instructions), but nobody here runs my scripts with no documents open, so I was hoping to give the application a gentle reset whenever they run a script.
Here’s the odd thing- I’ve been testing the scriptlet and full script identically: one document open in InDesign. Only difference is, in one case there’s a full script executed, in the other case it simply runs the ‘reset’ function. I then close the open document, and in the case of the scriptlet, the default font setting now set to “Avenir 35 Light” whereas in the case of the full script it’s set to “Avenir [Normal]”.
I don’t understand why this would be different between the two cases.
Also, I’m still working on CS2, and in the CS2 scripting manual the following code is stipulated:
tell application "Adobe InDesign CS2"
tell text defaults
set applied font to font "Avenir"
set font style to "35 Light"
end tell
end tell
However, this code generates an error highlighting “applied font”: Adobe InDesign CS2 got an error: Invalid value for set property ‘applied font’. Expected font or string, but received nothing.
whereas, this code (cribbed from the “Applescripting Indesign CS1” book does work (with a document open, but only in script-fragment form)
tell application "Adobe InDesign CS2"
set fontRef to font "Avenir"
set properties of text defaults to {applied font:fontRef, font style:"35 Light"}
end tell
Thanks- I’ll remove the gratuitous code…
throughly confusedly,
-Ralph
Hi Folks (and sorry to Stefan for misspelling his name)-
I figured out how to make this script work. It appears that when the default font is set to something that only has one style “regular” it takes two incantations (repetitions) of the style setting to get it to set correctly. I know this is completely bogus, but it works.
tell application "Adobe InDesign CS2"
set fontRef to font "Avenir"
set properties of text defaults to {applied font:fontRef, font style:"35 Light"}
set properties of text defaults to {applied font:fontRef, font style:"35 Light"}
end tell
I initially thought that the problem was that the scriptlet was embedded within a larger script that was causing it to fail, but when I set the default font to, for example, Ayuthaya, which only has one style (regular), running the script would only set the Avenir part of the default. Repeating the script (or as I discovered, repeating only the style part of the script) would fix the style as well. This works now, also embedded within the larger script.
Maybe Applescript is acting like a small child “Don’t make me tell you again!”?
cheers,
Ralph