Photoshop: How to handle numbering a large amount of disorganized items?

↘锁芯ラ 提交于 2021-02-08 11:40:39

问题


Suppose I have a large campsite like "seating" chart with several hundred lots sectioned off and outlined in photoshop. (each lot is roughly a square) Every lot needs to be numbered in photoshop and also editable in the future in case of changes. The lots are scattered and curve around the landscape so entering text in one layer seems out since for example lot 27 with be on the right and rotate 20 degrees to match the lot and yet lot 185 might be way over on the left at a far different angle.

Is there an elegant way to do this or at least quickly import a large number sequence that places one number per layer so I can grab them and orient them to their corresponding lot quickly instead of typing out and then positioning ever number individually? I'm having trouble thinking up an elegant/fast way to handle this in Photoshop...


Edit 1 - picture: http://i.imgur.com/UT3DRBi.jpg


回答1:


You can do it with Extendscript. I am not the best of Extendscript programmers, but the following script will ask you for the number of text labels you want and add that many numbers on sepearate layers. Of course, you can diddle around with the font, colour, position, size etc. but it should get you started.

Here is an example - I turned off layers 4 and 5 so you can see each number is on a new layer.

Here it asks how many numbers you want:

// Setchell - AddNumbers - Adobe Photoshop Script
// Description: Asks user for number of numbers to add, each in own layer   
// Version: 0.1
// Author: Mark Setchell (mark@thesetchells.com)
// Web: http://www.thesetchells.com
// ============================================================================
// Installation:
// 1. Place script in 'C:\Program Files\Adobe\Adobe Photoshop CS#\Presets\Scripts\'
// 2. Restart Photoshop
// 3. Choose File > Scripts > AddNumbers
// ============================================================================

// enable double-clicking from Mac Finder or Windows Explorer
// this command only works in Photoshop CS2 and higher
#target photoshop

// bring application forward for double-click events
app.bringToFront();


///////////////////////////////////////////////////////////////////////////////
// AddNumbers
///////////////////////////////////////////////////////////////////////////////
function AddNumbers() {

    // Change Debug=1 for extra debugging messages
    var Debug=1;

    // Get user to enter common stem for JPEG names
    var dialog = new Window('dialog', 'Setchell - AddNumbers');
    dialog.size = {width:500, height:100};
    dialog.stem = dialog.add('edittext',undefined, '<Enter ending number>');
    dialog.stem.size = {width:400,height:25};
    dialog.stem.value = true;
    dialog.stem.buildBtn = dialog.add('button', undefined,'OK', {name:'ok'});
    dialog.show();

    // Pick up what user entered - just digits
    var limit=dialog.stem.text.match(/\d+/);

    // Debug
    if(Debug)alert(limit);
    var cnt;


    var n=0;
    var nPer=10;
    var deltaX=app.activeDocument.width/nPer;
    var deltaY=app.activeDocument.height/nPer;
    var tX=0;
    var tY=deltaY;

    app.preferences.typeUnits = TypeUnits.POINTS;
    for(cnt=1;cnt<=limit;cnt++){

       // Adds a new layer to the active document and stores it in a variable named “myTextLayer”.
       var myTextLayer = app.activeDocument.artLayers.add();

       // Changes myTextLayer from normal to a text layer.
       myTextLayer.kind = LayerKind.TEXT;

       // Gets a reference to the textItem property of myTextLayer.
       var myText = myTextLayer.textItem;

       // sets the font size of the text to 16.
       myText.size = 16;

       // Sets the contents of the textItem.
       myText.contents = cnt;

       // Position the label - could be improved :-)
       tX=n*deltaX;
       myText.position = new Array(tX, tY);
       n++;
       if(n==nPer){
           tY+=deltaY;
           n=0;
       }
    }

return;

}

///////////////////////////////////////////////////////////////////////////////
// isCorrectVersion - check for Adobe Photoshop CS2 (v9) or higher
///////////////////////////////////////////////////////////////////////////////
function isCorrectVersion() {
    if (parseInt(version, 10) >= 9) {
        return true;
    }
    else {
        alert('This script requires Adobe Photoshop CS2 or higher.', 'Wrong Version', false);
        return false;
    }
}



///////////////////////////////////////////////////////////////////////////////
// showError - display error message if something goes wrong
///////////////////////////////////////////////////////////////////////////////
function showError(err) {
    if (confirm('An unknown error has occurred.\n' +
        'Would you like to see more information?', true, 'Unknown Error')) {
            alert(err + ': on line ' + err.line, 'Script Error', true);
    }
}


// test initial conditions prior to running main function
if (isCorrectVersion()) {

    // Save current RulerUnits to restore when we have finished
    var savedRulerUnits = app.preferences.rulerUnits;

    // Set RulerUnits to PIXELS
    app.preferences.rulerUnits = Units.PIXELS;

    try {
        AddNumbers();
    }
    catch(e) {
        // don't report error on user cancel
        if (e.number != 8007) {
            showError(e);
        }
    }

    // Restore RulerUnits to whatever they were when we started
    app.preferences.rulerUnits = savedRulerUnits;
}


来源:https://stackoverflow.com/questions/32487476/photoshop-how-to-handle-numbering-a-large-amount-of-disorganized-items

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!