Skip to main content
Known Participant
September 18, 2009
Answered

(CS3; JavaScript) how to efficiently "select all"/running an action

  • September 18, 2009
  • 1 reply
  • 1232 views

Hi all,

while I found some code to run actions from applescript I need to be able to do it from JavaScript. The documentation does not mention actions at all.

It would save me a lot of work if I could simply run an action that changes the document color to CMYK instead of having to duplicate all objects into a new doc. (I already created the action and it works)

That brings me to my other question: Is there really no "select all"? It takes almost 2 seconds (at least if the profiler is right) just to select a mere 300 objects in my test file. I need to batch process something like 30 files that might be more complex and I dont like the idea of telling my colleagues that they have to wait that long...

Isn't there a better way than looping through pageItems and setting .selected=true?

I could imagine running an action that does select all objects (how do you copy actions to other machines btw.?) or to execute the shortcut (Ctrl+a)

Many thanks

Mike

This topic has been closed for replies.
Correct answer Patrice Brel

Good evening,

Sub test_ai()

Set myAi = CreateObject("illustrator.application.CS4")
Set myDocAi = myAi.ActiveDocument

'- - An idea is to show at first the layers on which you want to select all objects.


myDocAi.Layers("myLayerWithObjects").Visible = True
myDocAi.ActiveLayer.Locked = False


myDocAi.Layers("mySecondLayerWithObjects").Visible = True
myDocAi.ActiveLayer.Locked = False

' - - -  In a second time you select all

For Each myLayers In myDocAi.Layers
If myLayers.Visible = True Then myLayers.HasSelectedArtwork = True
Next

' - - and finally you define a variable with your selection

myselexion = myAi.Selection

End Sub

After that you will probably have to identify each object of your selection.

Best regards

Patrice

1 reply

Patrice Brel
Patrice BrelCorrect answer
Inspiring
October 3, 2009

Good evening,

Sub test_ai()

Set myAi = CreateObject("illustrator.application.CS4")
Set myDocAi = myAi.ActiveDocument

'- - An idea is to show at first the layers on which you want to select all objects.


myDocAi.Layers("myLayerWithObjects").Visible = True
myDocAi.ActiveLayer.Locked = False


myDocAi.Layers("mySecondLayerWithObjects").Visible = True
myDocAi.ActiveLayer.Locked = False

' - - -  In a second time you select all

For Each myLayers In myDocAi.Layers
If myLayers.Visible = True Then myLayers.HasSelectedArtwork = True
Next

' - - and finally you define a variable with your selection

myselexion = myAi.Selection

End Sub

After that you will probably have to identify each object of your selection.

Best regards

Patrice

Mike.EdelAuthor
Known Participant
October 8, 2009

Hi Patrice,

nice one - I wasn't aware that setting the "HasSelectedArtwork" property to true would select all objects on the layer.

So far I always had to loop through the objects and set their selected property to true.

Thanks,

Mike