Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Is there a way to select all text objects containing specified character?

New Here ,
Sep 23, 2014 Sep 23, 2014

Is there a way to select all text objects containing specified character?

For instance,

My artwork consists of dots and numbers.

Dots are on separated text frames, so are numbers.

I would like to select all dots, so I can group them.

Or numbers, and group them.

Screen Shot 2014-09-23 at 14.48.52.png

TOPICS
Scripting
2.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 23, 2014 Sep 23, 2014

yes,

- loop thru all text items

- get each contents

- compare to "."

- if matching, save a reference to that text frame

- when done with all frames

- loop thru all saved references and move to a group

Translate
Adobe
Community Expert ,
Sep 23, 2014 Sep 23, 2014

yes,

- loop thru all text items

- get each contents

- compare to "."

- if matching, save a reference to that text frame

- when done with all frames

- loop thru all saved references and move to a group

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 23, 2014 Sep 23, 2014

Thanks, probably you are right, but

in fact I never started scripting in Illustrator and I am not able to write it myself..

So the question should be posted as: Do anyone has a script...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 23, 2014 Sep 23, 2014

I see, it is unlikely there is a ready made script for such particular need...One would need to be written. If time permits, some of us contributors might give it a try.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 24, 2014 Sep 24, 2014
LATEST

I'm still quite new with this whole scripting, but I wrote simple script for this. Just copy&paste it from here or download it from here Dropbox - TextSearchSelection.jsx

Hope it helps!

// Text Search Selection

//

// JavaScript Script for Adobe Illustrator CC 2014

// Tested with Adobe Illustrator CC 2014, Windows 7 64-bit.

// This script provided "as is" without warranty of any kind.

// Free to use and distribute.

//

// Copyright(c) 2014 Sakari Niittymaa

// http://www.niittymaa.com

//

// 2014-09-24

#target illustrator

if (app.documents.length > 0) {

   

var script_name = "Text Search Selection"

var doc = app.activeDocument;

var find_char;

// Loop all items

function getTextItems (item) {

    for (var i=0; i < item.length; i++) {

       

        if (item.groupItems) {

           

            getTextItems (item.groupItems);

            getTextItems (item.textFrames);

           

        } else if (item.typename == "TextFrame") {

           

            // Set selection

            item.selected = findCharacter (item.contents);           

        }

    }

}

// Parse selected text item

function findCharacter( item ) {

   

    var char_found = false;

   

    // Parse selected string characters

    for (var i=0; i < item.length; i++) {

       

        // Mark character found if there is same character in text item

        if ( item.toLowerCase() == find_char.toLowerCase() ) {

            char_found = true;

        }

    }

   

    // If character found return true value for selection

    if (char_found) {

        return true;

    } else { return false }

}

// GUI

startGUI();

function startGUI() {

   

    // Create Main Window

    var win = new Window( "dialog", script_name, undefined );

   

    // Style for Main Window

    win.orientation = "column";

    win.alignChildren = ["fill", "fill"];

   

    // Style for Search group

    var searchGrp = win.add("panel", undefined, "Find Character");

    searchGrp.orientation = "column";

    searchGrp.alignChildren = ["fill", "fill"];

   

    var titleMsg = searchGrp.add ("statictext", undefined, "Select all text items with this character:");

    var singleChar = searchGrp.add("edittext { characters: 1, justify: 'center', active: true }");

    singleChar.helpTip = "Enter single character";

   

    // Listener for the find button

    singleChar.onChanging = function() {

        if (singleChar.text.length > 1) { singleChar.text = ""; };

        app.executeMenuCommand ('selectall');

        find_char = singleChar.text;

        getTextItems ( doc.selection  );

        app.redraw();

    }

    // Style for Extra

    var extraGrp = win.add("panel", undefined, "Extra");

    extraGrp.orientation = "column";

    extraGrp.alignChildren = ["fill", "fill"];

    // Button: Edges

    var btnEdges = extraGrp.add('button', undefined, "Edges");

    btnEdges.helpTip = "Show/Hide Edges";

    btnEdges.onClick = function () {

        app.executeMenuCommand ('edge'); app.redraw();

    };

   

    // Button: Bounding Box

    var btnBoundingBox = extraGrp.add('button', undefined, "Bounding Box");

    btnBoundingBox.helpTip = "Show/Hide Bounding Box";

    btnBoundingBox.onClick = function () {

        app.executeMenuCommand ('AI Bounding Box Toggle'); app.redraw();

    };

    // Close button

    var quitBtn = win.add("button", undefined, "Close");

    quitBtn.helpTip = "Press Esc to Close";

    // Event listener for the quit button

    quitBtn.onClick = function() {  

        win.close();  

    } 

    // Centering & Show Window

    win.center();

    win.show();

}

} else {

    alert("You do not have any document opened!");

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines