在Illustrator中显示并选择文档上的所有实时文本?

时间:2017-06-14 08:55:00

标签: javascript jsx adobe-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;
          }
}
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

我刚刚创建了一个要运行的操作,该操作将运行菜单命令“显示隐藏字符”#39;这就是我找到解决问题的方式。