在 Illustrator 中显示并 select 文档中的所有实时文本?

Show and select all live text on the document in 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() {
 try{
  // Check if there is an active document of if one needs to be opened.
  OpenFile();
     // The Variable for the current document that is open.
     g.activeDoc = app.activeDocument;
     // Search though all the layers in the document and make sure that they are unlocked and visable.                                               
     UnlockLayers();
     // Outline all of the text to make it un-editable
     OutlineText(g.activeDoc.layers);
   }
   // Catch any errors that the script has thrown. 
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.
    for ( var i = 0 ; i < app.activeDocument.layers.length; i++ ) {

      // Unlock/Unhide layers here.
      app.activeDocument.layers[i].locked = false;
      app.activeDocument.layers[i].visible = true;
      
    }
    }

// 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;
          }
}

我刚刚为 运行 创建了一个操作,它将 运行 菜单命令 'Show Hidden Characters' 并且这就是我找到的解决问题的方法。