Skip to main content
prema56615405
Inspiring
January 16, 2019
Answered

Remove selected items on active artboard

  • January 16, 2019
  • 3 replies
  • 2387 views

I have written the below javascript for the below actions. Remove command is not working.

1) select the objects on active artboard

2) remove the selected objects

var doc = app.activeDocument;

doc.selectObjectsOnActiveArtboard()

removeAll();

This topic has been closed for replies.
Correct answer prema56615405

The correct answer is as below

var doc = app.activeDocument;

doc.selectObjectsOnActiveArtboard()

app.executeMenuCommand("clear");

3 replies

prema56615405
prema56615405AuthorCorrect answer
Inspiring
January 22, 2019

The correct answer is as below

var doc = app.activeDocument;

doc.selectObjectsOnActiveArtboard()

app.executeMenuCommand("clear");

pixxxelschubser
Community Expert
Community Expert
January 22, 2019

The result is the same as with my answer, right?

Disposition_Dev
Legend
February 18, 2019

Hi rcraighead

You are right.

But: Does the result change?


the result inside the illustrator file wouldn't change. but someone could be relying on something that's already on the clipboard. in that case, this would overwrite the contents of the clipboard. that's the only difference i can see. (i'm not advocating that it's a good idea to rely on the clipboard in this way)

Ton Frederiks
Community Expert
Community Expert
January 16, 2019

It would be better to ask this in the scripting forum;

Illustrator Scripting

But if that's all you want to do, recording it as an action would be easy.

Srishti Bali
Legend
January 21, 2019

Discussion moved to Illustrator Scripting

pixxxelschubser
Community Expert
Community Expert
January 21, 2019

The fastest way?

Replace your last line

removeAll();

with

app.executeMenuCommand ('cut');

Have fun

Silkrooster
Legend
January 16, 2019

Not positive but I think the second line requires a ; at the end like the other two lines.