Copy link to clipboard
Copied
I am trying to write a Javascript that can do the following:
1) Select an object whose note has <Object Name> (so its layers is also selected)
2) Duplicate the layer of that object
3) Rename the new layer to <Layer Name>
4) Apply a swatch to the object on the new layer (the object is only single colour)
5) Apply a new note to the object (over-writing the original note).
I also want to write a separate script that can do the following:
1) Select an Object whose note has <Object Name> (so its layer is selected as well)
2) Hide all other layers
3) Save a copy of the document with a specific name
I can do this as an Illustrator action. However, I need several different copies of the scripts where the Object Name, Layer Name, Swatch and File Name changes.
Re-recording the action to change the names is cumbersome.
I have looked at the Illustrator scripting reference, but cannot see any commands for select objects by their notes.
I was wondering if someone could give me some pointers on how to proceed (Or possibly, if feeling very generous, could write the script for me
)
Copy link to clipboard
Copied
This will show you how to select based on object note… My example selects muppets… This is hard coded by script will let you input/change this from a dialog box where your action wouldn't…
#target illustrator
var doc = app.activeDocument;
var allMyArt = doc.pageItems;
var toSelect = Array();
for ( var i = 0; i < allMyArt.length; i++ ) {
if ( allMyArt.note == 'muppet' ) { toSelect.push( foo ) };
};
doc.selection = toSelect;
I may need screen grabs to get a better understanding of your problem ( a simplified example of layers expanded is best ) B4 and after…
Copy link to clipboard
Copied
Thank you for your help. When I run the script, it says FOO is undefined. Here is the before and after:


(I've removed some of the layers to make the screenshots more compact, but the ones left still have the attribute names)
Copy link to clipboard
Copied
That's my error changing variables before posting… I can't edit that post now but this should fix it… Plus give you a very basic UI to enter a value…
#target illustrator
var n = prompt( 'Please enter your \'Note\' string…', 'muppet', 'Note finder' );
findNote( n );
function findNote( n ) {
var doc = app.activeDocument;
var allMyArt = doc.pageItems;
var toSelect = Array();
for ( var i = 0; i < allMyArt.length; i++ ) {
if ( allMyArt.note == n ) { toSelect.push( allMyArt ) };
};
doc.selection = toSelect;
};
Oh I didn't mean b4 n after running a duff script… What you do with actions so I can see what objects are duplicated where then coloured… ![]()
Copy link to clipboard
Copied
Hi Thanks for your help. I have sent you a private message.
Copy link to clipboard
Copied
I have the PM and will take a look over it tomorrom… Getting late now UK time zone… ![]()
Copy link to clipboard
Copied
the line
if ( allMyArt.note == n ) { toSelect.push( allMyArt ) }; in order to work, it must be as follows
if ( allMyArt[i].note == n ) { toSelect.push( allMyArt ) };
Copy link to clipboard
Copied
I really like this script. I have been playing around with the note feature and I am finding that a lot can be done by applying notes to text as well as graphics.
What I would like to figure out how to do is have a script that will select a text line with a specific note and either have a simple drop down that enters text or allows me to type in a dialog that will place the text on the line for me. Something to save me a few steps of selecting a text box, selecting the text and then changing the text.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now