在 SVG 中创建 Illustrator 顶层

发布于 2024-11-24 14:09:56 字数 124 浏览 0 评论 0原文

当我将分层 SVG 文件加载到 Illustrator 中时,所有图层都按其应有的方式工作,但它们始终位于新图层下;我没有指定“第 1 层”。

如何创建 SVG,使我的顶层最终也成为 Illustrator 中的顶层?

When I load my layered SVG files into Illustrator all the layers works just as they should but they are always positioned under a new layer; "Layer 1" that I did not specify.

How do I create a SVG where my top layers end up as the top layer in Illustrator as well?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

太阳男子 2024-12-01 14:09:56
  1. 在 Illustrator 中创建一个具有所需组织结构的文件。
  2. 将 Illustrator 中的 SVG 保存为“a.svg”。
  3. 在 Illustrator 中重新打开 SVG 文件。
    嘿,我的所有图层都在第 1 层下重新组合!
  4. 修复组织。
  5. 从 Illustrator 保存 SVG,并将“保留 Illustrator 编辑功能”选项选中为“b.svg”。
  6. 在 Illustrator 中重新打开 SVG 文件。
    是的,图层被保留了!
  7. 比较 a.svgb.svg 以查看 Illustrator 保存了哪些额外元数据。
  8. 在您自己的文件中模仿此数据。
    当您意识到该解决方案是一个巨大的专有 blob( 元素)时,您会哭。
  9. 放弃并决定这并不那么重要。
  1. Create a file in Illustrator that has an organization like you want.
  2. Save the SVG from Illustrator as "a.svg".
  3. Re-open the SVG file in Illustrator.
    Hey, all my layers got regrouped under Layer 1!
  4. Fix the organization.
  5. Save the SVG from Illustrator with the "Preserve Illustrator Editing Capabilities" option checked as "b.svg".
  6. Re-open the SVG file in Illustrator.
    Yay, the Layers were preserved!
  7. Diff a.svg and b.svg to see what extra metadata Illustrator is saving.
  8. Mimic this data in your own file.
    Cry when you realize that the solution is an enormous proprietary blob (the <i:pgf> element).
  9. Give up and decide it doesn't really matter all that much.
梦与时光遇 2024-12-01 14:09:56

这确实对我来说很重要,所以我停止哭泣,花了几个小时编写了这个解决方案的脚本:

  • 下载脚本:https://github.com/JcBernack/IllustratorScripts/archive/master.zip
  • 将“Fix SVG Layers”文件夹放置在标准 Illustrator 脚本文件夹中。它的位置取决于您的安装和语言,我的位于:
    C:\Program Files\Adobe\Adobe Illustrator CS6(64 位)\Presets\de_DE\Skripten
  • 启动 Illustrator 并加载 SVG,其中所有实际图层现在都分组在新的“图层 1”中。
  • 转到文件 -> 脚本 -> 修复 SVG 图层 -> FixSvgLayers
  • 耶!所有组现在都是实际的层,“第 1 层”永远消失了。

更多信息:

  • “FixSvgLayers”将“Layer 1”中的所有组转换回图层,将它们移动到文档根目录并删除现在空的“Layer 1”。
  • “GroupsToLayers”将当前活动图层中的所有组转换为图层,而不移动或删除任何内容。
  • 两个脚本都提示输入“递归深度”,该深度指定应将多少级别的组-组-组转换为子子子层。
  • 第三个脚本 (ConvertGroupsIntoLayers) 是另外两个脚本所需要的,从菜单调用它会打开一个提示,但不会执行任何操作。

打开 SVG 时,所有实际图层都分组在新的“图层 1”中。这些可以毫不含糊地转换回来。不过,子层是有问题的,因为没有信息可以区分实际的组和应该是子层的组(如果有,请告诉我!)。作为解决方法,我的脚本提示输入递归深度并将所有组转换为该深度内的(子)层。

就我而言,我有三层,其中一层只是更多子层的容器。为了恢复原始图层结构,我执行了深度为 0 的 FixSvgLayers,然后选择容器层并执行深度为 0 的“GroupsToLayers”。

如果所有三个层都是“容器”层,则执行深度为 1 的 FixSvgLayers 将已经足以恢复正确的结构。

如果您不需要任何组并且每个组都应转换为(子)层,只需输入足够高的数字作为递归深度。

It indeed does really matter to me so I stopped crying, spent a few hours and scripted this solution:

  • Download the scripts: https://github.com/JcBernack/IllustratorScripts/archive/master.zip
  • Place the "Fix SVG Layers" folder in the standard Illustrator scripts folder. Where that is depends on your installation and language, mine is at:
    C:\Program Files\Adobe\Adobe Illustrator CS6 (64 Bit)\Presets\de_DE\Skripten
  • Start Illustrator and load the SVG where all the actual layers are now groups within a new "Layer 1".
  • Go to File->Scripts->Fix SVG Layers->FixSvgLayers
  • Yay! All the groups are now actual layers and "Layer 1" is gone for good.

A bit more information:

  • "FixSvgLayers" converts all groups within the "Layer 1" back to layers, moves them to the document root and deletes the now empty "Layer 1".
  • "GroupsToLayers" converts all groups within the currently active layer to layers, without moving or deleting anything.
  • Both scripts prompt for a "recursion depth" which specifies how many levels of groups-groups-groups should by converted to sub-sub-sub-layers.
  • The third script (ConvertGroupsIntoLayers) is just needed by the other two, calling it from the menu opens a prompt but doesn't do anything.

When opening the SVG all the actual layers are groups within a new "Layer 1". These can be converted back without ambiguity. Sub-layers are problematic though, because there is no information to distinguish actual groups from groups which should be sub-layers (if there is please let me know!). As a workaround my script prompts for a recursion depth and converts all groups to (sub-)layers within that depth.

In my case I had three layers, where one of them was just a container for more sub-layers. To get back the original layer-structure I executed FixSvgLayers with a depth of 0, then selected the container layer and executed "GroupsToLayers" with depth of 0.

If all three layers were "container"-layers executing FixSvgLayers with a depth of 1 would have been enough to get back the correct structure.

If you don't want any groups and every group should be converted to a (sub-)layer just enter a high enough number as the recursion depth.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文