Hallo!
Vielleicht kann mir hier jemand weiterhelfen?
Ich hab keine Ahnung von Javascript mich davon aber nicht entmutigen lassen und versucht mit einem Script meinen Workflow zu verbessern.
Ziel des Script ist es alte Dateien für die Übersetzung vorzubereiten.
Dazu will ich:
• alle Ebenen entsperren
• alle Hilfslinien löschen
• alten Text aktualisieren (legacy Text)
• Absatzmarken entfernen und durch ein Leerzeichen ersetzen
• Auswahl zentrieren und zoomen
Ich habe einige andere Scripte genommen, zusammengesetzt und soweit klappt es (für meine Verhältnisse) auch ganz gut.
Es scheitert jedoch am alten Text.
Diesen Teil des Scriptes konnte ich bislang nicht so modifizieren, dass er das macht was ich will.
Vielleicht hat hier jemand eine Idee wie sich mein Vorhaben umsetzten lässt. Ich wäre für jeden Hinweis dankbar.
Hier ist der Code:
Code / // BAUSTELLE! Das aktualisieren von altem Text klappt noch nicht. // // Unlock all layers (and their sublayers) processLayersRecursive(app.activeDocument.layers); // Process all layers under variable "parent" (including sublayers on all levels). function processLayersRecursive(parent){ for (var iLayer = 0; iLayer < parent.length; iLayer++){ var curLayer = parent[iLayer]; // Unlock the current layer if (curLayer.locked){ curLayer.locked = false; } processLayersRecursive(curLayer.layers); } } // Remove all guides var doc = app.activeDocument; for (var i = doc.pathItems.length-1; i >= 0; i--) { var p = doc.pathItems[i]; if (p.guides == true) { p.remove(); } } doc.selectObjectsOnActiveArtboard(); // ----------------------------------------------------------------------------- zweiter Teil // script.name = legacyTextConvertToNative.jsx; // script.description = converts Legacy Text to Native from all layers, except from 2 layers, hard codes below. // script.required = 2 layers named the sames as the names shown below in skipLayer1 & 2 // script.parent = CarlosCanto // 7/23/11; // script.elegant = false; // var skipLayer1 = "Layer 3"; // replace with your own layer name // var skipLayer2 = "Layer 1"; // replace with your own layer name for (i=0; i<doc.layers.length; i++) { var ilayer = doc.layers[i]; // if (ilayer.name!=skipLayer1 && ilayer.name!=skipLayer2) { for (j=0; j<ilayer.groupItems.length; j++) { var igroup = ilayer.groupItems[j]; for (k=igroup.legacyTextItems.length-1; k>=0; k--) { var ilegacy = igroup.legacyTextItems[k]; ilegacy.convertToNative(); } } } } // ----------------------------------------------------------------------------- dritter Teil // Absatzmarken entfernen // https://forums.adobe.com/thread/2597426 var active_doc = app.activeDocument; var search_string = /\r/g; // g for global search, remove i to make a case sensitive search var replace_string = ' '; // pour "\n" var text_frames = active_doc.textFrames; var this_text_frame, this_text_frame; if (text_frames.length > 0) { for (var i = 0 ; i < text_frames.length; i++) { this_text_frame = text_frames[i]; new_string = this_text_frame.contents.replace(search_string, replace_string); this_text_frame.contents = new_string; } } // ------------------------------------------------------------------------------ dritter Teil ///////////////////////////////////////////////////////////////// //Zoom and Center to Selection v2. -- CS, CS2 //>=-------------------------------------- // // Zooms active view to selected object(s). // // New in v.2: // If nothing is selected; sets view to 100% at current location. // // Simple but REALLY cool! // //>=-------------------------------------- // JS code (c) copyright: John Wundes ( [email protected] ) www.wundes.com //copyright full text here: http://www.wundes.com/js4ai/copyright.txt ////////////////////////////////////////////////////////////////// if ( documents.length > 0) { if(activeDocument.selection.length >0){ mySelection = activeDocument.selection; //if object is a (collection of) object(s) not a text field. if (mySelection instanceof Array) { //initialize vars initBounds = mySelection[0].visibleBounds; ul_x = initBounds[0]; ul_y = initBounds[1]; lr_x = initBounds[2]; lr_y = initBounds[3]; //check rest of group if any for (i=1; i<mySelection.length; i++) { groupBounds = mySelection[i].visibleBounds; if (groupBounds[0]<ul_x){ul_x=groupBounds[0]} if (groupBounds[1]>ul_y){ul_y=groupBounds[1]} if (groupBounds[2]>lr_x){lr_x=groupBounds[2]} if (groupBounds[3]<lr_y){lr_y=groupBounds[3]} } } //get x,y/x,y Matrix for 100% view activeDocument.views[0].zoom = 1; ScreenSize = activeDocument.views[0].bounds; ScreenWidth= ScreenSize[2] - ScreenSize[0]; ScreenHeight=ScreenSize[1] - ScreenSize[3]; screenProportion =ScreenHeight/ScreenWidth; //Determine upperLeft position of object(s) cntrPos = [ul_x,ul_y]; //mySelection[0].position; //cntrPos[0] += (mySelection[0].width /2); //cntrPos[1] -= (mySelection[0].height /2); //offset by half width and height mySelWidth=(lr_x-ul_x); mySelHeight=(ul_y-lr_y); cntrPos[0] = ul_x + (mySelWidth/2); cntrPos[1] = ul_y - (mySelHeight/2); //alert("ul point is "+cntrPos); //center to screen to the object activeDocument.views[0].centerPoint = cntrPos; //alert("objWidth="+mySelection[0].width+", actualWidth="+ActualWidth); //alert("objHeight="+mySelection[0].height+", actualHeight="+ActualHeight); //set zoom for height and width zoomFactorW = ScreenWidth/mySelWidth; zoomFactorH = ScreenHeight/mySelHeight; //alert("zoomFactorW = "+zoomFactorW+"\r zoomFactorH = "+zoomFactorH); //decide which proportion is larger... if((mySelWidth*screenProportion) >= mySelHeight){ zF = zoomFactorW; //alert("zoomFactorW = "+zoomFactorW); }else{ zF = zoomFactorH; //alert("zoomFactorH = "+zoomFactorH); } //and scale to that proportion minus a little bit. activeDocument.views[0].zoom = zF *.85; }else{ //alert("Please select an object on the page."); activeDocument.activeView.zoom=1; } } Gruß
Oliver