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

I'd like to preserve the position of objects when I export a layer

Community Beginner ,
Dec 26, 2018 Dec 26, 2018

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!

preserve position.pngcountry layers.png

5.1K
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 ,
Dec 26, 2018 Dec 26, 2018

make a no-fill, no-stroke border around the artboard, include it when you export your individual countries

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 Beginner ,
Dec 26, 2018 Dec 26, 2018

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?rectangle.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 ,
Dec 26, 2018 Dec 26, 2018

no, you can put it on a new layer on top of trace copy layer.

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 Beginner ,
Dec 27, 2018 Dec 27, 2018

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.

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 ,
Dec 27, 2018 Dec 27, 2018

Hi, yes add a new layer on top of the stack then add the border rectangle in that new layer

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 Beginner ,
Dec 27, 2018 Dec 27, 2018

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.)

pic1.png

pic2.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
Explorer ,
Dec 28, 2018 Dec 28, 2018

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.

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 Beginner ,
Dec 28, 2018 Dec 28, 2018

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!

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 ,
Dec 28, 2018 Dec 28, 2018

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?

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 Beginner ,
Dec 28, 2018 Dec 28, 2018

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

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 ,
Dec 28, 2018 Dec 28, 2018

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

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 ,
Dec 28, 2018 Dec 28, 2018

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

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 ,
Dec 29, 2018 Dec 29, 2018

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.

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 ,
Dec 28, 2018 Dec 28, 2018

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.

Illustrator Scripting | Adobe Developer Connection

Illustrator Scripting

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 Beginner ,
Dec 30, 2018 Dec 30, 2018
LATEST

CarlosCanto​ Thanks again, I appreciate your help!

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
Explorer ,
Dec 28, 2018 Dec 28, 2018

No problem

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