【问题标题】:Show and select all live text on the document in Illustrator?在 Illustrator 中显示并选择文档上的所有实时文本?
【发布时间】:2017-06-14 22:34:01
【问题描述】:

我正在尝试编写一个脚本来解锁所有图层,然后遍历所有图层,显示并选择活动文档中的实时文本,到目前为止我所写的只是解锁图层。有人可以帮忙吗?谢谢

这是我目前写的……

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

【问题讨论】:

    标签: javascript jsx adobe-illustrator


    【解决方案1】:

    我刚刚创建了一个要运行的操作,它将运行菜单命令“显示隐藏字符”,这就是我发现的解决问题的方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-15
      • 2019-01-17
      • 1970-01-01
      • 1970-01-01
      • 2017-07-25
      • 1970-01-01
      • 1970-01-01
      • 2011-11-21
      相关资源
      最近更新 更多