Skip navigation
Currently Being Moderated

Name and Number selected paths?

Jan 10, 2011 6:02 AM

I am working on a very large .ai file of a baseball stadium render. It contains many small sections and box seats that need named and numbered in this format: section::100, section::101, ... and so on. Right now, I'm having to go through and rename each path individually. Is there a script that will save me TONS of time by automating this for me?

 

I found this one on here, which is a good start for what I need, but it doesn't let me only number selected paths, nor does it let me start the numbering where I want (say at 100 and go up from there).

 

#target illustrator

 

var docRef = app.activeDocument;
var newName = prompt ("What's the base of the new name","base");
var myNB = docRef.pathItems.length;
for ( i = 1 ; i < myNB; i++)
{
var finalName = newName + i;
docRef.pathItems[i].name = finalName
}

 

 

Thanks in advance!!

 
Replies
  • Currently Being Moderated
    Jan 10, 2011 6:36 AM   in reply to Andymc7

    Im not convinced that a script is going to work for what you want to do… You can work with selected objects and check that they are 'text frames' you can also prompt for a start number and check it's a number before using it. Where you 'may' fall into difficulty is with the stacking order of the objects within the drawing. Your sample script will number in this order as is…

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 10, 2011 7:38 AM   in reply to Andymc7

    I have taken a quick guess at what you want but Im supposed to be busy at work…

     

    #target illustrator
     
    var docRef = app.activeDocument;
     
    var newName = prompt ("What's the base of the new name","base");
    var stNumb = prompt ("What's the start number","1");
     
    var myNB = docRef.selection.length;
     
    for (var i = 0 ; i < myNB; i++) {
         var finalName = newName + stNumb;
         if (docRef.selection[i].typename == 'PathItem') {
              docRef.selection[i].name = finalName;
              stNumb++;
         }
    }
    

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 10, 2011 8:09 AM   in reply to Andymc7

    My boss has no idea as to what I can/can't script… So I can make it work for me… Glad it works… I did think you were putting in the labels…

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 10, 2011 8:42 AM   in reply to Andymc7

    Click inside the 'circle' of your layer 'sections' in the layers pallete? Should select all sub items…

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 10, 2011 12:12 PM   in reply to Muppet Mark-QAl63s

    .. Im supposed to be busy at work…

     

    hahahaha...good one

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points