Ok here is another ??? When I run a script it will load swatches in INDESIGN, but every time I run it I do NOT want it to keep loading the swatches over and over again. Here is what I have so far and it keeps loading the swatches. How do i get this to work?
tell application "Adobe InDesign CS6"
set default display settings of display performance preferences to high quality
if swatches contains "Secondary - Green, Primary - Blue, Secondary - Blue, Secondary - LT Green, Accent - Blue, Accent - LT Blue, Accent - Grey, Accent - Charcol, Primary - White, Primary - Grey" then
return "these are loaded" -- basicly i dont want the script to do anything if these swatches are present
else
load swatches from ("Web Design 1/Users/scottmemberg/Desktop/LennarSwatches.ase")
end if
tell view preferences
set horizontal measurement units to inches
set vertical measurement units to inches
end tell
set fontRef to font "Soho Gothic Std"
set properties of text defaults to {applied font:fontRef, font style:"Regular"}
do script "app.applyWorkspace('Scott');" language javascript
activate
end tell
HI thanks for your tip! What if no document is loaded?
tell application "Adobe InDesign CS6"
if swatches's name contains "Secondary - Green" and it contains "Primary - Blue" and it contains "Secondary - Blue" and it contains "Secondary - LT Green" and it contains "Accent - Blue" and it contains "Accent - LT Blue" and it contains "Accent - Grey," and it contains "Accent - Charcol" and it contains "Primary - White" and it contains "Primary - Grey" then
return "these are loaded"
else
load swatches from ("Web Design 1/Users/scottmemberg/Desktop/LennarSwatches.ase")
end if
end tell
Since i dont have an active document can it be done like this?
Yes, but that operation can only be performed once to the default, which retains swatch settings; you could just load it once and be done with it, in the time that it takes to test the names.
tell application "Adobe InDesign CS6"
if swatches's name contains "Secondary - Green" and it contains "Primary - Blue" and it contains "Secondary - Blue" and it contains "Secondary - LT Green" and it contains "Accent - Blue" and it contains "Accent - LT Blue" and it contains "Accent - Grey," and it contains "Accent - Charcol" and it contains "Primary - White" and it contains "Primary - Grey" then
return "these are loaded"
else
load swatches from ("Web Design 1/Users/scottmemberg/Desktop/LennarSwatches.ase")
end if
end tell
this didnt work it keeps loading the swatch file… ;(
Yes unfortunately Since i am very nubish to this Im a bit confused.
Here is the modified code:
tell application "Adobe InDesign CS6"
tell swatches's name to if it contains "Secondary - Green" and it contains "Primary - Blue" and it contains "Secondary - Blue" and it contains "Secondary - LT Green" and it contains "Accent - Blue" and it contains "Accent - LT Blue" and it contains "Accent - Grey," and it contains "Accent - Charcol" and it contains "Primary - White" and it contains "Primary - Grey" then
"loaded"
else
load swatches from ("Volumes:Betty:Lennar Homes:assets:Reference:Swatch-Colors:LennarSwatches.ase")
end if
End tell
WHen running the script it doesn’t load anything even if the swatches are not present
copy and paste this into script editor, save it as an application, then drop your .ase file onto it from the location
it is stored, once done then paste the result into your code, it will give the exact path to your file, it’s saved my bacon
on numerous occasions.
on open _theseItems
set _location to _theseItems as text
set the clipboard to _location
display dialog "The path to the item has been copied " & return & ¬
"to the clipboard." with icon note giving up after 5
end open
Hmm. My example works in CS3, but perhaps CS6 is less flexible; it may require explicitly re-referencing the application, to escape the current object. If the path is correct and you can manually load that file, then I see no other reason it could fail.
I offer you my interpretation of your question.
With load swatch you can basically load all colors saved in .ase document.
If for any reason there are 9 colors present and 1 not present you can’t restore your colors swatches because you load them only if all reference colors are not present.
If you have a limited number of colors (not 1,000) and you save them individually the following routine can check the presence of each color and restore it from disk.
Is also possible to define an array or text files with RGB or CMYK values and generate color on the fly without load them from .ase
set officialColorList to {"Secondary - Green", "Primary - Blue", "Secondary - Blue", "Secondary - LT Green", "Accent - Blue", "Accent - LT Blue", "Accent - Grey", "Accent - Charcol", "Primary - White", "Primary - Grey"}
tell application "Adobe InDesign CS6"
tell active document
set colorsList to name of every swatch
repeat with j from 1 to count officialColorList
set theColor to item j of officialColorList
if theColor is not in colorsList then
set swatchName to theColor & ".ase"
load swatches from ("Macintosh HD:Users:adminosx:Desktop:" & swatchName)
-- Change the path starting with Macintosh HD... with path of folder where are saved .ase files
end if
end repeat
end tell
end tell
Stefano - Ame
Browser: Safari 537.74.9
Operating System: Mac OS X (10.8)
a much more elegant solution without load .ase from disk:
tell application "Adobe InDesign CS6"
set officialColorList to {}
-- Colors Definition
set secondaryGreen to {name:"Secondary - Green", model:process, space:CMYK, color value:{50.0, 0.0, 100.0, 0.0}}
set primaryBlue to {name:"Primary - Blue", model:process, space:CMYK, color value:{100.0, 80.0, 0.0, 0.0}}
set primaryGrey to {name:"Primary - Grey", model:process, space:CMYK, color value:{46.0, 37.0, 37.0, 23.0}}
-- Copy each definition to array officialColorList
copy secondaryGreen to end of officialColorList
copy primaryBlue to end of officialColorList
copy primaryGrey to end of officialColorList
tell active document
set colorsList to name of every swatch
repeat with j from 1 to count officialColorList
set colorName to name of item j of officialColorList
if colorName is not in colorsList then
make color with properties (item j of officialColorList)
end if
end repeat
end tell
end tell
Stefano - Ame
Browser: Safari 537.75.14
Operating System: Mac OS X (10.8)