Skip to main content
Participating Frequently
May 22, 2023
Answered

Create a searchable icon library?

  • May 22, 2023
  • 6 replies
  • 1390 views

I have a document with 300+ artboards, each with an icon on it, and all artboards are named with what the icon depicts. How can I quickly search for the icon I need? (right now I'm just scrolling around looking for a specific visual). Is there a better way to set this up? (ie, a symbol library? I tried to search those though, and couldn't find a search feature). Thank you.

This topic has been closed for replies.
Correct answer jduncan

Since you already have them set up as artboards, @Sergey Osokin has a great script for easily searching artboards. You can find it here.

6 replies

Participant
July 10, 2024

I have a similar question but specific to searching within the symbol library. Is there a way to search for a specific symbol in the library instead of scrolling down each time? 

 

I looked in the github link posted by jduncan and did not find a script for searching in a symbol library.

 

Thank you.

 

jduncan
Community Expert
Community Expert
July 10, 2024

The script I linked was for searching artboards (better fit for the OP's needs)....

 

If you need to search for the symbols in your documents Symbols palette, you can try the script below. It uses a searchable list box from the book ScriptUI for dummies by Peter Kahrel and the Symbols collection from the API (learn more). Whatever symbol you select in the dialog will be available in the script as the variable `symbol` (learn more).

 

Note: this does not search the actual symbols placed on the document artboard(s), just the base symbols in the palette...

 

Finally, I'm not sure what you plan to do with the selected symbol after selecting so let us know and we can help you with the next step(s) if you need it. Cheers!

 

// get the current document
var doc = app.activeDocument;

// get symbols from current document
var symbols = [];
for (var i = 0; i < doc.symbols.length; i++) {
  symbols.push(doc.symbols[i].name);
}

// show symbol picker
picked = picker(symbols);

// select symbol for later use
var symbol = doc.symbols.getByName(picked);

// alert choice for debugging
alert("You picked symbol...\n" + picked + "\n" + symbol);

// "type-ahead" listbox found in ScriptUI for dummies by Peter Kahrel (pgs. 37-38)
// https://creativepro.com/files/kahrel/indesign/scriptui.html
// NOTE: If you document has lots of symbols you may want to read the "Processing long lists" section (pgs. 39-40)
function picker(arr) {
  var w = new Window('dialog {text: "Document Symbols", alignChildren: "fill"}');
  var entry = w.add("edittext {active: true}");
  var list = w.add("listbox", [0, 0, 250, 250], arr);
  list.selection = 0;
  entry.onChanging = function () {
    var temp = this.text;
    list.removeAll();
    for (var i = 0; i < arr.length; i++) {
      if (arr[i].toLowerCase().indexOf(temp) == 0) {
        list.add("item", arr[i]);
      }
    }
    if (list.items.length > 0) {
      list.selection = 0;
    }
  };
  // We need the button to catch the Return/Enter key (CC and later)
  w.add("button", undefined, "Ok", { name: "ok" });
  if (w.show() != 2) {
    return list.selection.text;
  }
  w.close();
}

 

Inspiring
May 22, 2023
Participating Frequently
May 24, 2023

@jodmcc49  Thank you for the link. Unless something has changed, I don't see a way to search a library like, as an example for the "magnifying glass" icon. Seems you just scroll until you see it? 

jduncan
Community Expert
jduncanCommunity ExpertCorrect answer
Community Expert
May 22, 2023

Since you already have them set up as artboards, @Sergey Osokin has a great script for easily searching artboards. You can find it here.

Participating Frequently
June 12, 2023

@jduncan Thank you, this is exactly what I was looking for (no pun intended)!