6

Is there a way to remove path/group transformations when exporting as SVG with Illustrator? My problem is similar to this one but the given solution is only for Inkscape.

5
  • When do you get a transform attribute when exporting from Illustrator? I've never seen that and can't reproduce it now (I'm using CS6 and I believe SVG is handled differently in CC so that may be relevant).
    – Cai
    May 1, 2016 at 20:40
  • @CAI, i'm on CC but try to reproduce it by transforming the shape first (rotate it), then go to save as > SVG > show SVG code, there should be a "transform" attribute
    – Elbasan
    May 1, 2016 at 20:47
  • I tried that. No transform attribute. CC must have changed that because AFAIK Illustrator always expands any transforms/effects when saving as SVG and I can't set it to do otherwise.
    – Cai
    May 1, 2016 at 20:53
  • Does expanding appearance help? I assume that would fix it.
    – Cai
    May 1, 2016 at 20:57
  • Problem is that if you draw a perfectish box for example then illsutrator will make it a box and since a box cant be slanted then it will add a transform. However if your shape is one that says polygon or path then you can try if selecting object with black arrow and choosing Object -> transform-> Reset Bounding Box helps. I dont have CC so mine does not behave this way (theres only 2 features i would be glad to take in CC but 8 problems i cant afford to take on, plus subscription).
    – joojaa
    Jul 7, 2016 at 19:13

6 Answers 6

4

Using Illustrator CC -- After trying several of these tips without success, I was able to finally convert/export to SVG:

1) Set Artboard's X and Y to 0: enter image description here

2) Use Export As... and select to Use Artboards. enter image description here

3) After clicking Export button, SVG Options window opens, and select following settings: enter image description here

No more Transform/Expand errors! Hope this works for others :-)

4
  • It seems to partly help, but I still have transforms on my text elements.
    – MSC
    Dec 15, 2019 at 9:40
  • Did you "Outline" your text? Doing so will transform text into shapes. After doing so, you will not be able to edit your text with the text editor but everything should now stay true to its shape.
    – MizMO
    Dec 16, 2019 at 12:22
  • No I didn't Outline my text.
    – MSC
    Dec 17, 2019 at 0:49
  • Object rotate transforms remain in the SVG code when using this method. It may work for some circumstances, but not all.
    – ndemarco
    May 19, 2022 at 19:11
2

I'm not sure there's a one-click fix, but I solved the issue when working with simple shapes and paths by using "Unite" button in the Pathfinder pallet. You should actually see the bounding box change rotation as you click it.

However, some primitive shapes (ellipse, rect) were exported by Illustrator with transforms even after applying Unite. I solved this in my project by altering the points of the shape just slightly using the direct select tool.

The key seemed to be getting illustrator to output the svg using a path or polygon tags rather than svg's native rect or ellipse.

Illustrator CC v. 19.2.1

1
  • I think it was the background <Rectangle> causing the issue (as you point out)? After I moved the corner point out let it go the <Rectangle> changed to path. I put the point back in the corner and saved as SVG. Thank you Sir!
    – Kerry7777
    Jul 15, 2022 at 4:23
1

To remove transforms and keep primitive SVG shapes ( rect, ellipse ):

  • Group shapes you want to export
  • Then press "Unite"
  • Ungroup and export / asset / etc.

If you have overlapping shapes - move them before grouping so they don't overlap, do the procedure, move them back...

If you have only one shape - draw anything next to it, group ... do the procedure ... ungroup and remove anything you don't need, then export.

Without grouping it doesn't work sometimes, but with grouping - works for any shape.

Illustrator CC 19+, haven't tried it in earlier versions.

0

Select the shape then go to Object > Expand > Select Fill & Stroke > OK

enter image description here

5
  • I'm assuming you would want to expand appearance, not the fill and stroke.
    – Cai
    May 1, 2016 at 20:54
  • Stroke and fill are lost when expanding, thats why you expand both
    – Elbasan
    May 1, 2016 at 21:53
  • Stroke and fill aren't lost when expanding? That would make expanding appearance pretty useless. Anything that isn't expanded isn't affected.
    – Cai
    May 1, 2016 at 23:34
  • And having intact strokes is very useful.. You don't want to be expanding stuff unnecessarily
    – Cai
    May 1, 2016 at 23:35
  • When I go to "Object > Expand", I don't see a menu for "Select Fill & Stroke". How do I open that menu? Are you going to "Object" from the top menu bar? May 2, 2016 at 0:29
0

As far as I can tell only rectangles and ellipses will have the 'transform' attribute applied to them...

Here is a simple square:

Square one

And here is its relevant bit of code:

<rect x="95" y="95" width="470" height="470" fill="none" stroke="#0f6fa3" stroke-miterlimit="10" stroke-width="24"/>

That's 116 characters.

Here, the same square rotated:

Square one rotated

And its code:

<rect x="95" y="95" width="470" height="470" transform="translate(-99.59 147.65) rotate(-22)" fill="none" stroke="#0f6fa3" stroke-miterlimit="10" stroke-width="24"/>

That's 165 characters... Now the same square with a single anchor point added:

Square one with an extra anchor point

Resulting code:

<polygon points="635.92 459.86 200.14 635.92 24.08 200.14 142.31 152.38 459.86 24.08 635.92 459.86" fill="none" stroke="#0f6fa3" stroke-miterlimit="10" stroke-width="24"/>

And this last example weighs in at 171 characters...

So it seems that leaving the transform attributes alone may actually be more efficient anyhow...

1
  • Thanks for the info, but this doesn't answer the OP's question.
    – ndemarco
    May 19, 2022 at 19:13
0

One trick that seems to work reliably for me: right click on the affected shape layer and choose "Make Compound Path".

Now all exports of that shape seem to be generated using raw path objects.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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