Skip to main content
StrongBeaver
Legend
May 7, 2016
Resuelto

Selections to Artboards ?

  • May 7, 2016
  • 3 respuestas
  • 3573 visualizaciones

Is there any script that can take a selection or multiple selections and make artboards from those selections and so the artboards fit perfectly to the selection ?

Este tema ha sido cerrado para respuestas.
Mejor respuesta de CarlosCanto

try this

for (var a=0; a<selection.length; a++) app.activeDocument.artboards.add(selection.geometricBounds);

StrongBeaver
Legend
May 23, 2016

My Layers panel is as such;

Layer1

-> Group

--> Letter1

--> Letter2

--> Letter3

--> Letter4

--> etc

The code I used was posted by Carlos in post #2, could it be the code won't work because the individual expanded letters are in a group ?

I completely oversaw post #6 by Carlos That is the result I want.

pixxxelschubser
Community Expert
Community Expert
May 24, 2016

StrongBeaver schrieb:

My Layers panel is as such;

Layer1

-> Group

--> Letter1

--> Letter2

--> Letter3

--> Letter4

--> etc

The code I used was posted by Carlos in post #2, could it be the code won't work because the individual expanded letters are in a group ?

I completely oversaw post #6 by Carlos That is the result I want.

pixxxel schubser schrieb:

Furthermore:

alert (app.activeDocument.selection.length);

alert (app.activeDocument.selection[0].typename);

It seems you completely oversaw my posting too:

pixxxel schubser schrieb:

… Because of:

If the selection is a group (if the word wasn't ungrouped after outlining) only one artboard will be added (with the code of in his post #1)

Ungroup the group, select the letters and runs Carlos script again.

You will get:

  • the existing artboards remains
  • every part of selection.length will adds an new artboard (5 letters will adds 5 artboards, but a group with 5 letters will adds only one artboard !!! )
CarlosCanto
Community Expert
Community Expert
May 24, 2016

The point is, grouped or ungrouped, at least one artboard should be created, something should be happening

StrongBeaver
Legend
May 11, 2016

I selected my selection, executed the code; but my selection was no placed on it's own artboard along side the artboard for which I selected my selection ?

CarlosCanto
Community Expert
Community Expert
May 11, 2016

please show screenshots of the results you're getting and the results you need.

pixxxelschubser
Community Expert
Community Expert
July 13, 2018

Actually my addition to the code does not seem to be working perfectly.

I think this is happening because the index order of the artboards is getting changed when artboards get deleted and then they get skipped. Not sure how to solve this yet…


Here is a before and after.

Before

​After


Perhaps a bit more better

var idoc = app.activeDocument;

var abs = idoc.artboards;

for (var a=abs.length-1; a>=0; a--) {

    idoc.selection = null;

    thisBoard = abs;

    idoc.artboards.setActiveArtboardIndex (a); // activate each artboard

    idoc.selectObjectsOnActiveArtboard(); // select all in artboard

    if(!idoc.selection.length) {

        thisBoard.remove(); //Delete artboard if it is empty,

        } else {

        idoc.fitArtboardToSelectedArt(a); // fit artboard to selection

    }

}

idoc.selection = null;

idoc.rearrangeArtboards();

Have fun

CarlosCanto
Community Expert
CarlosCantoCommunity ExpertRespuesta
Community Expert
May 9, 2016

try this

for (var a=0; a<selection.length; a++) app.activeDocument.artboards.add(selection.geometricBounds);

Disposition_Dev
Legend
May 10, 2016

This works great Carlos, as long as there are no clipping masks. Unfortunately, Illustrator treats the contents of the clipping mask as "visible" even though any artwork outside the clipping mask is not visible...

Hopefully you don't have clipping masks in your files, StrongBeaver​.. If so, let us know and we'll try and help you out with that contingency.