0
我試圖編寫一個解鎖所有圖層的腳本,然後通過所有圖層顯示並選擇活動文檔中的活動文本,到目前爲止我所寫的內容僅解鎖圖層。任何人都可以幫忙嗎?由於在Illustrator中顯示並選擇文檔上的所有生動文字?
這是我至今寫...
// Make script launchable via double-click/CMD + O.
#target illustrator
// Create an object to hold global variables.
var g = {}
// Call main function.
main();
// Destoying global variables.
g = null;
// Main function will call all the usable functions in order.
function main() {
\t try{
\t \t // Check if there is an active document of if one needs to be opened.
\t \t OpenFile();
\t // The Variable for the current document that is open.
\t g.activeDoc = app.activeDocument;
\t // Search though all the layers in the document and make sure that they are unlocked and visable.
\t UnlockLayers();
\t // Outline all of the text to make it un-editable
\t OutlineText(g.activeDoc.layers);
}
// Catch any errors that the script has thrown. \t
catch(e){
alert(e + " ...An error has risen...")
}
}
// Make sure that file is accessable and open.
function OpenFile(){
//check if there are any files already open
if (app.documents.length == 0) {
// If there is not, let the user choose an illustrator file and open that file.
var fileToOpen = File.openDialog ("Please select illustrator file", "*.ai",false);
// Open the file.
app.open (File (fileToOpen));
}
}
// Unlock all layers.
function UnlockLayers(){
// Loop through the docs layers and capture the locked states of each one.
\t \t \t \t for (var i = 0 ; i < app.activeDocument.layers.length; i++) {
\t \t \t \t \t \t // Unlock/Unhide layers here.
\t \t \t \t \t \t app.activeDocument.layers[i].locked = false;
\t \t \t \t \t \t app.activeDocument.layers[i].visible = true;
\t \t \t \t \t \t
\t \t \t \t }
}
// Search through and select all live text.
function OutlineText(objArray) {
for (var i = 0; i < objArray.length; i++) {
// Record previous value with conditional change.
var l = objArray[i].locked;
if (l) objArray[i].locked = false;
// Record previous value with conditional change.
var v = objArray[i].visible;
if (!v) objArray[i].visible = true;
}
}