Converting Groups to Layers in Illustrator

Top  Previous  Next

 

An issue you'll encounter when importing any SVG file into Illustrator is that you'll end up with a hierarchy of groups, not actual Illustrator layers and sublayers. Furthermore, any layer or sublayer will be exported from Illustrator as an ordinary SVG group, the distinction between groups and layers being lost. Since the roundtripping process requires that you place artwork into specially named SVG groups, you might  think it necessary to modify the way you draw. For example, you can use the direct selection tool (white arrow cursor) to target objects inside groups.

 

My preference, however, is to transform the particular groups I need to work with into true layers so that they can be targeted in the usual way. This is only needed when a raw SVG export from Walls is first opened in Illustrator, or when a Walls-updated SVG is being brought back in. At other times we would be maintaining an AI file while doing our drafting and occasionally spinning off SVG files for use by other software.

 

Caution: Unfortunately, not only is this aspect of the layer structure discarded when Illustrator exports to pure SVG format. When the file is read back in, some art objects, notably brush strokes, will have been "expanded" and will not be as easily editable. Illustrator artwork should never be saved as an SVG file until it's necessary, say for adjustment by Walls.

 

Using a Script to Convert Groups to Layers.

An Illustrator script that can perform this conversion is now installed alongside Walls in its application folder. To make it especially easy to invoke, you'll need to copy file w2dGroupsToLayers.jsx to Illustrator's script folder when Illustrator is not running. (Windows may prompt for permission to do this.) On my computer this folder is

 

C:\Program Files\Adobe\Adobe Illustrator CS6 (64 Bit)\Presets\en_US\Scripts\.

 

After that, whenever you open an SVG freshly exported from Walls, select File | Scripts from Illustrator's main menu. The name w2dGroupsToLayers should appear in the list of readily-available scripts. Just clicking on the name will execute the script, which begins with a request for confirmation -- a total of 3 mouse clicks.

 

The groups that are converted, if they are found, are w2d Legend, w2d Walls, w2d Walls sym, w2d Walls shp, w2d Detail, w2d Detail sym, w2d Detail shp, and w2d Mask. The other w2d groups are placed in an initial locked state. The script makes no changes if the top layer is either empty or it already contains true sublayers. Other layers can exist below the top layer, in which case they shouldn't be affected.

 

Manually Converting Groups to Layers

Here are instructions for converting the key SVG groups into layers using Illustrator's Layer panel functions. They could be performed as described here, after Illustrator opens an SVG file generated by Walls. But even if you've used the above script for that task, you might need to use the manual method on a specific named group you've created earlier as a sublayer, say one now existing as a subgroup of w2d Walls shp.

 

Double-click on the artwork square next to the name of a high-level w2d group in the Layers panel, for example, w2d Legend. (The parent must already be a layer.) This opens a small "Options" dialog showing the group name. Right-click on the name and select Copy to save the name to the clipboard, then cancel the dialog.

 

While the group is still highlighted in the Layers panel, open the Layers pop-up context menu by clicking on the tiny down-arrow near the top of the panel. From the list of commands, select Collect in New Layer. This will create a new layer with a unique name, say Layer 2, containing the group w2d Legend that you want to convert. Layer 2 also takes up the slot originally held by w2d Legend.

 

Double-click on the artwork square next to the name of Layer 2 and paste the original name, w2d Legend, back in. You will now see an arrow next to this layer indicating that it has child objects under it. Expand the layer and you will see beneath it the original group, w2d Legend, with its name unchanged.

 

If Walls exported the SVG file in a merge operation, this lower w2d Legend group will likely contain artwork. If that 's the case, select the group's contents by clicking on the circle to the right of the name, then select Object | Ungroup from Illustrator's main menu. That removes the duplicate name and extra level in the hierarchy. If this is your first SVG export from Walls, one without Illustrator artwork, then the lower w2d Legend group will be empty, in which case you can delete it by clicking the panel's trash can icon. In either case, you'll notice that the remaining w2d Legend panel item is displayed with a darker background color, distinguishing it as a true Illustrator layer, not a group.

 

Next, convert the w2d Walls group to a layer in the same fashion. This group, however, contains two sublayers (groups for now), with the names w2d Walls sym and w2d Walls shp. As in the case above, the w2d Walls group will become a child of the new w2d Walls layer that's created. You don’t need to do anything to that, it will disappear on its own when the child groups are converted to layers.

 

Perform the same conversion on the w2d Detail group and its two subgroups. Pay attention when pasting the layer names back in when doing these conversions on a file that already contains artwork. After you select Collect in New Layer, a different layer may become highlighted, and if you are not careful you may be pasting the original name into the wrong place.

 

This amounts to just a few mouse clicks per layer, and with practice the conversion of groups to layers can be done in about 3 minutes.