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

need to write a script to count objects/brush-objects on a layer

Enthusiast ,
Nov 29, 2015 Nov 29, 2015

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.

            Screenshot 2015-11-30 10.43.25.png

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

TOPICS
Scripting
4.9K
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
Adobe
Community Expert ,
Nov 30, 2015 Nov 30, 2015

This info is available in the GUI, can a script access this info?

brushed-items.png

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 ,
Nov 30, 2015 Nov 30, 2015

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,

Screen Shot 2015-11-30 at 2.52.09 PM.jpg

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