need to write a script to count objects/brush-objects on a layer
Copy link to clipboard
Copied
I've forgotten how to script AI and all my old scripts are not retrievable ATM.
in Pseudo code what I need is:
determine current active AI layer
reference all the objects in that layer as stuff
iterate stuff as item
if item is a brushed path then count++
return count
bonus points for returning info on all visible layers and totalling the layer counts
I'd settle for even just counting selected objects whatever they are. thx.
if I can find out the references for layers and layer objects and selected objects I could get started. User Guide to Illustrator CC 2015 Scripting is not great, I need a proper manual.
my script so far. I'm not referencing the objects on the target layer correctly to count them so I get undefined as the value.
var msg = "List of visbile layers\r"
// If a docuement is open
if ( app.documents.length > 0 ) {
sourceDoc = activeDocument;
if(sourceDoc.pageItems.length > 0 ) {
var layerCount = sourceDoc.layers.length;
for (var i = 0; i < layerCount; i++ ) {
targetLayer = sourceDoc.layers ;
if (targetLayer.visible ) {
msg += targetLayer.name + ' ';
}
msg += targetLayer.length + '\r';
}
alert (msg +"\r i =" + i, -1)
}
}
Message was edited by: Alastair Leith script so far. just need to do counting and do filtering for brushes
Explore related tutorials & articles
Copy link to clipboard
Copied
This info is available in the GUI, can a script access this info?
Copy link to clipboard
Copied
unfortunately no. Adobe is quite far behind on giving all of us scripters access to GUI components.. Here's a list of the available properties and methods for the pathItem object,


-
- 1
- 2