10
$\begingroup$

In Adobe Illustrator (and other such graphics programs), it is possible to place different objects on different layers. All objects on a layer can be edited together, their stacking changed, and other useful manipulations. My question is this: is it possible to create layers (or layer-like structures) in Mathematica, and to then export them to pdf (or other such file format) so that Illustrator will interpret them as different layers?

What I have tried. I couldn't find anything in the documentation about creating layers, so I tried investigating. I created a two-layer document in Illustrator, saved as a pdf, and then read this into Mathematica. It looks like this after import: enter image description here

The good news is that the circle and rectangle are still an editable vector objects, but they have been condensed onto one layer, as can be seen directly by exporting and then reading back into Illustrator -- everything is in one layer.

Here is the file with 2 layers: https://www.dropbox.com/s/2nf91att3t4l4x5/twoLayers.pdf?dl=0

I imported this with

img = Import[twoLayers.pdf]

and then exported using

Export[twoLayers2.pdf,img]
$\endgroup$
5
$\begingroup$
Import["twoLayers.pdf"]
  1. Double click on each graphics object separately and edit as you wish. While editing, order the objects by using the mouse right click, and Move to Front, Move to Back, etc. This will order them in the correct layer sequence.
  2. Double click on one graphics object first, hold the Shift key, and select the other graphics objects that you want to export. You can also use Control-A while in Graphics mode to select all the objects.
  3. While the graphics objects are still selected, go to File -> Save Selection As, and save as .pdf file.

Now when you import the file back to MMA you will see that the graphics objects are still click-able and in the correct "layer" order.

You can also export your MMA graphics image as follows:

g1= {any graphics image}
Export["twoLayersNew.pdf", g1, "PDF"]

enter image description here

$\endgroup$
  • $\begingroup$ Hi Vixillator -- thanks for looking at the question. This kind of independent graphics objects was what I meant when I wrote that "The good news is that the circle and rectangle are still an editable vector objects." But the issue still remains that the objects have been collapsed onto a single layer. The reason this matters is because my real problem has many objects on each layer, and the goal is to process all the same-layer-objects together. $\endgroup$ – bill s Jan 26 '19 at 5:10
  • $\begingroup$ You can do that by grouping the objects that you want to be together. After you select the same layer objects that you want to group, do a right-click and select Group. You can even export the grouped objects as one image file so you can import and process separately. Remember you can also do cut and paste while in Graphics mode to manage objects in different layers. Good luck. $\endgroup$ – Vixillator Jan 26 '19 at 5:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.