Thank you René, I will do as you wisely suggest and update the script above.
- Mark
Working on my script version, I tried to merge all of the best ideas. The script is now Windows and macOS compatible. I integerated René's first solution to locate the file if it doesn't exist.
#target illustrator
(function () {
try {
var symFilePath;
doc = app.activeDocument;
if ($.os.indexOf("Windows") != -1) {
symFilePath = new Folder(app.path + "/Presets/"+ app.locale +"/Symbols");
} else {
symFilePath = new Folder(app.path + "/Presets.localized/"+ app.locale +"/Symbols");
}
var symFile = new File(symFilePath + "/tiki.ai"); //Replace with symbol file name
if (!symFile.exists) {
alert("File not found. Click OK to locate.");
symFile = File.openDialog("Select ai file to open.","AI files:*.ai",false);
}
if (symFile != null) {
var symDoc = app.open(symFile);
var symbl = symDoc.symbols.getByName("Fish"); //Replace with symbol name
var symItem = symDoc.symbolItems.add(symbl);
symItem = symItem.duplicate(doc);
symItem.remove();
//Close reference document
symDoc.close(SaveOptions.DONOTSAVECHANGES);
}
} catch (error) {
return alert("Symbol "+symbolName+" Not Found");
}
})();
Thank you @renél80416020 and @m1b