Copy link to clipboard
Copied
Hi folks,
I have a map of the world with countries on different layers. I need to end up with every country on it's own png file, and I need to keep the position of the object. (I'm importing the png's to Unity and I don't want to manually place each country). I've figured out how to export the layers as separate png's, but the result is an image cropped to just the country object.
Hopefully the images explain what I'm looking for.
Thank you!
Copy link to clipboard
Copied
make a no-fill, no-stroke border around the artboard, include it when you export your individual countries
Copy link to clipboard
Copied
Okay, I made a rectangle (no fill/no stroke) but how do I include it in the layers? Would I need a border like this for every sub-layer?
Copy link to clipboard
Copied
no, you can put it on a new layer on top of trace copy layer.
Copy link to clipboard
Copied
I'm not sure what you mean by "new layer on top of trace copy layer"? Do you mean add a layer on top of the stack? I'm having trouble figuring out where/how to add the border rectangle.
Copy link to clipboard
Copied
Hi, yes add a new layer on top of the stack then add the border rectangle in that new layer
Copy link to clipboard
Copied
Okay I've tried adding a layer with the rectangle border, but it's not being applied to the other layers. I'm using the Asset Export window, and it looks like this (pic1). Alternatively, I can drag and drop the rectangle onto each layer one at a time, and that works in the Asset Export (pic2). Doing it that way, even though it works, is prone to lots of little mistake as I drag and drop.
(I've also tried having the countries as objects and also as layers, made by: "Release to layers - sequence" but that doesn't help. It creates a layer, but doesn't grab the name which would be nice.)
Copy link to clipboard
Copied
clayr95172224​ I understand your query and I've no idea whether the above answers are helpful fro you or not. I just know a simple way I can do this.
1) Separating layers as of each country.
2) Hiding all layers except the one which has to be exported.
3) Press Ctrl+Shift+S or Ctrl+Shift+Alt+S and save.
4) Repeat this for all the layers (countries).
As the canvas is same for each layer. Each PNG will retain its position.
Copy link to clipboard
Copied
fahad_dexter, thanks that's probably the easiest thing to do. I was hoping to save the png's more automatically, but the most important thing was getting them to stay in position.
Thanks!
Copy link to clipboard
Copied
Hi so you're selecting and dragging all the countries to the assets panel in one go? And when you export your pngs you want to keep the names of the countries.
The only way I can think of is by grouping each country with a copy of the border rectangle, then naming the group as the country...but sounds tedious.
I could write a script to help you group and rename. Is this a one-time project or do you do this often?
Copy link to clipboard
Copied
CarlosCanto​ - Hey that's thoughtful of you. I eventually found a way to get the layers to save to Photoshop (where I'm more experienced). From there I used "Export layers to files" and made png's that worked. I will just rename them by hand.
I am interested in learning how to write scripts, if you could point me to some examples?
Thanks for your help
Copy link to clipboard
Copied
This script should do what you want, exporting main layers to images:
Scripting Illustrator: Export Layers as Images
Unfortunately on my machine it insists on opening CS6, but it creates a script in the directory that you target for the result, and that script works when used in CC
Copy link to clipboard
Copied
https://forums.adobe.com/people/Ton+Frederiks wrote
Unfortunately on my machine it insists on opening CS6
does it have "#target Illustrator" at top of the script?
if so, change that to
#target illustrator-23
if you're using CC2019
Copy link to clipboard
Copied
Thanks Carlos, that did it, I tried to change the targetting before, but found now that you need to change it in 2 places in the script.
Copy link to clipboard
Copied
no problem clayr, here's the script anyway. It works as I described above, make a no-fill, no-stroke rectangle, name it "border". The script will select everything, group a copy of each country along with the "border" and name each group to match the country.
If you have more objects other thank the countries, they will also get processed. So, lock or hide other art before running the script
var idoc = app.activeDocument;
app.executeMenuCommand('selectall');
var border = idoc.pageItems['border'];
border.selected = false;
var grp = idoc.groupItems.add()
border.move(grp, ElementPlacement.PLACEATEND);
var dup, country;
var sel = idoc.selection;
for (a=sel.length-1; a>=0; a--) {
country = sel;
dup = grp.duplicate(country, ElementPlacement.PLACEBEFORE);
country.move(dup, ElementPlacement.PLACEATBEGINNING)
dup.name = country.name;
}
idoc.selection = null;
grp.selected = true;
app.executeMenuCommand('ungroup');
let me know if you need help running scripts. And if you want to get into scripting, you can start with the official scripting guides, Adobe assumes you already know JavaScript, if you don't you need to learn that somewhere else, and if you get stuck or have questions, you're more than welcome to post your questions over the scripting forum.
Copy link to clipboard
Copied
CarlosCanto​ Thanks again, I appreciate your help!
Copy link to clipboard
Copied
No problem
Find more inspiration, events, and resources on the new Adobe Community
Explore Now