Hey,
Due to a bug in another piece of software I'm using, when I export my designs as PDF or EPS files, I don't want to store any transforms for any objects.
For my objects that are predominantly paths, this seems to be easy enough - I ungroup everything and it removes the transforms from the group object when it removes it, and the children's paths have their x/y positions set in-place. But it leaves circles (and presumably other arcs/curves) with a transform.
For circles, they've got a 90 degree rotation applied to them (because their parent was rotated when my extension ran a bin packing algorithm over everything), which is pretty easy to get rid of, but I'd like it to be automated, and it won't be that easy for the capsules I've made by combining 2 paths and 2 arcs.
Is there a command that can remove all the transforms whilst leaving everything where it is (I gather some other software has a 'Re-Orient' paths function)?
Remove all transforms whilst keeping in-place
-
- Posts: 9
- Joined: Wed May 25, 2016 1:01 pm
Re: Remove all transforms whilst keeping in-place
You could turn them to paths, maybe? Path -> Convert to Path would be quick.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
Re: Remove all transforms whilst keeping in-place
I thought moving everything to a new layer would remove the transforms. I could be wrong.
Basics - Help menu > Tutorials
Manual - Inkscape: Guide to a Vector Drawing Program
Inkscape Community - Inkscape FAQ - Gallery
Inkscape for Cutting Design
Manual - Inkscape: Guide to a Vector Drawing Program
Inkscape Community - Inkscape FAQ - Gallery
Inkscape for Cutting Design
-
- Posts: 9
- Joined: Wed May 25, 2016 1:01 pm
Re: Remove all transforms whilst keeping in-place
Moving to a new layer didn't seem to help.
I wrote a batch file to do the conversion for me:
It's slow (there might be 20-30 objects, each made up of many paths, sometimes dozens) and clunky, and assumes that the svg has a circle node with the id 'circle1', but it works. I also had to change my extension to write out circles as 2 arcs, because 'simplify' seemed to distort my circles, whereas it leaves 2 perfect half-circles alone (apart from removing the transform).
I got a response from the developers of the other piece of software, they said there was something strange about how Inkscape was exporting transforms for pdf and eps formats, that was causing the problem in their program.
But, seeing as they see it as a bug in Inkscape, they won't be writing a workaround. They did say, however, that they're working on importing svg files directly, and so hopefully once they do I won't need to do any of this shenanigans and exporting, and it will just work.
But, being in software development myself, I'm not holding my breath waiting for the next release.
I wrote a batch file to do the conversion for me:
Code: Select all
"C:\Program Files\Inkscape\inkscape" %1 --verb EditSelectAllInAllLayers --verb SelectionUnGroup --verb EditDeselect --select "circle1" --verb EditSelectSameObjectType --verb SelectionSimplify --verb FileSave --verb FileQuit
"C:\Program Files\Inkscape\inkscape" %1 --export-eps=%1.eps --export-text-to-path
It's slow (there might be 20-30 objects, each made up of many paths, sometimes dozens) and clunky, and assumes that the svg has a circle node with the id 'circle1', but it works. I also had to change my extension to write out circles as 2 arcs, because 'simplify' seemed to distort my circles, whereas it leaves 2 perfect half-circles alone (apart from removing the transform).
I got a response from the developers of the other piece of software, they said there was something strange about how Inkscape was exporting transforms for pdf and eps formats, that was causing the problem in their program.
But, seeing as they see it as a bug in Inkscape, they won't be writing a workaround. They did say, however, that they're working on importing svg files directly, and so hopefully once they do I won't need to do any of this shenanigans and exporting, and it will just work.
But, being in software development myself, I'm not holding my breath waiting for the next release.
Re: Remove all transforms whilst keeping in-place
Antony.Marshall wrote:Moving to a new layer didn't seem to help.
I wrote a batch file to do the conversion for me:Code: Select all
"C:\Program Files\Inkscape\inkscape" %1 --verb EditSelectAllInAllLayers --verb SelectionUnGroup --verb EditDeselect --select "circle1" --verb EditSelectSameObjectType --verb SelectionSimplify --verb FileSave --verb FileQuit
"C:\Program Files\Inkscape\inkscape" %1 --export-eps=%1.eps --export-text-to-path
It's slow (there might be 20-30 objects, each made up of many paths, sometimes dozens) and clunky, and assumes that the svg has a circle node with the id 'circle1', but it works. I also had to change my extension to write out circles as 2 arcs, because 'simplify' seemed to distort my circles, whereas it leaves 2 perfect half-circles alone (apart from removing the transform).
I got a response from the developers of the other piece of software, they said there was something strange about how Inkscape was exporting transforms for pdf and eps formats, that was causing the problem in their program.
But, seeing as they see it as a bug in Inkscape, they won't be writing a workaround. They did say, however, that they're working on importing svg files directly, and so hopefully once they do I won't need to do any of this shenanigans and exporting, and it will just work.
But, being in software development myself, I'm not holding my breath waiting for the next release.
Hello
Inkscape provides a library for python extensions that take in account transformations:
http://wiki.inkscape.org/wiki/index.php ... ansform.py
http://wiki.inkscape.org/wiki/index.php ... plepath.py
But I think that it doesn't provide much more info for circles, text or other shapes, unless you convert all of them to paths.
However, if you say that the bug appears between the exporting from svg to pdf, ... I can't help there. What I know, is that Inkscape uses external libraries to convert from svg to pdf.
By the way, Why don't you say the name of that other software you mention?.
If you have problems:
1.- Post a sample (or samples) of your file please.
2.- Please check here:
http://tavmjong.free.fr/INKSCAPE/MANUAL/html/index.html
3.- If you manage to solve your problem, please post here your solution.
1.- Post a sample (or samples) of your file please.
2.- Please check here:
http://tavmjong.free.fr/INKSCAPE/MANUAL/html/index.html
3.- If you manage to solve your problem, please post here your solution.
-
- Posts: 9
- Joined: Wed May 25, 2016 1:01 pm
Re: Remove all transforms whilst keeping in-place
Hi,
Yes, my extension uses simplepath and simpletransform, as I built it from examples online that used these.
No reason not to mention the other software, it's Vectric Software's "Cut2D", it's for my laser cutter.
Another thing I'm going to try is downloading a command-line converter, see if converting from svg/eps/pdf to eps or pdf gives a different, useable output.
Yes, my extension uses simplepath and simpletransform, as I built it from examples online that used these.
No reason not to mention the other software, it's Vectric Software's "Cut2D", it's for my laser cutter.
Another thing I'm going to try is downloading a command-line converter, see if converting from svg/eps/pdf to eps or pdf gives a different, useable output.
Re: Remove all transforms whilst keeping in-place
If there aren't any groups in your file (or any other objects that really *require* a transform attribute), but only paths, then you could also just change your Inkscape preferences (if you haven't already).
Edit -> Preferences -> Behavior -> Transforms: Optimized
Then just move everything once (up and down, or left and right) and all transforms will be gone. Oh, and if you've ever resized the document, create a new layer first, and move everything to that layer.
Edit -> Preferences -> Behavior -> Transforms: Optimized
Then just move everything once (up and down, or left and right) and all transforms will be gone. Oh, and if you've ever resized the document, create a new layer first, and move everything to that layer.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
-
- Posts: 9
- Joined: Wed May 25, 2016 1:01 pm
Re: Remove all transforms whilst keeping in-place
I tried that, it was already set to optimized. After ungrouping everything, moving objects doesn't appear to remove the transforms from any arcs or curves, and the straight line paths already had their transforms removed when the ungrouping occurred.
But the objects in my scene are grouped by default, my extension creates a series of objects (groups) for laser cutting. It's helpful to keep them as groups so I can rearrange them with my bin packing algorithm, to place them in such a way as to minimize wasted material.
It's the ungroup everything operation that's really slow, it can take a couple of minutes to complete as there are so many internal parts to my designs.
For example one of my parts contains a measuring tool, so there are dozens and dozens of lines, like you'd find on the edge of a ruler. They wouldn't be possible as a single path, without doubling back over themselves, which I don't want the laser to do.
But the objects in my scene are grouped by default, my extension creates a series of objects (groups) for laser cutting. It's helpful to keep them as groups so I can rearrange them with my bin packing algorithm, to place them in such a way as to minimize wasted material.
It's the ungroup everything operation that's really slow, it can take a couple of minutes to complete as there are so many internal parts to my designs.
For example one of my parts contains a measuring tool, so there are dozens and dozens of lines, like you'd find on the edge of a ruler. They wouldn't be possible as a single path, without doubling back over themselves, which I don't want the laser to do.
Re: Remove all transforms whilst keeping in-place
mmmh. Then I'm at a loss. You could upload one of your creations to get someone to try a few things.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
Re: Remove all transforms whilst keeping in-place
I'm quite sure I remember someone asking this same question, not more than a month or 2 ago. I didn't understand why they needed it, but the successful solution for them, was to move everything to a new layer. But it must only remove certain kind of transforms.
Because in the past, when there were some issues with the transform attribute (I mean certain bugs) the successful workaround is to move everything to a new layer. Specifically, that was with my custom default doc, where I have the orientation switched from portrait to landscape. And moving to a new layer absolutely removes that transform attribute, and the bug doesn't happen.
Yet when I tested just now, I found that moving my drawing to a new layer, not only did not remove the transforms, it added a new ones! So it's all very confusing. For a test, see attached. Oh wait, I don't think we can attach in this board.... Here: http://inkscapecommunity.com/jd/ss/rt.svg
When I select the red diamond shape, and look in XML Editor, there's an attribute "inkscape:transform-center-y". Create a new layer, and move the red diamond into it. Now in XML Editor, in addition to that one, there's a NEW transform attribute ("transform" with value "translate....")
But since there seems to be different kinds of transforms in the XML/SVG code, maybe it would help to know specifically about your file?
Because in the past, when there were some issues with the transform attribute (I mean certain bugs) the successful workaround is to move everything to a new layer. Specifically, that was with my custom default doc, where I have the orientation switched from portrait to landscape. And moving to a new layer absolutely removes that transform attribute, and the bug doesn't happen.
Yet when I tested just now, I found that moving my drawing to a new layer, not only did not remove the transforms, it added a new ones! So it's all very confusing. For a test, see attached. Oh wait, I don't think we can attach in this board.... Here: http://inkscapecommunity.com/jd/ss/rt.svg
When I select the red diamond shape, and look in XML Editor, there's an attribute "inkscape:transform-center-y". Create a new layer, and move the red diamond into it. Now in XML Editor, in addition to that one, there's a NEW transform attribute ("transform" with value "translate....")
But since there seems to be different kinds of transforms in the XML/SVG code, maybe it would help to know specifically about your file?
Basics - Help menu > Tutorials
Manual - Inkscape: Guide to a Vector Drawing Program
Inkscape Community - Inkscape FAQ - Gallery
Inkscape for Cutting Design
Manual - Inkscape: Guide to a Vector Drawing Program
Inkscape Community - Inkscape FAQ - Gallery
Inkscape for Cutting Design
-
- Posts: 9
- Joined: Wed May 25, 2016 1:01 pm
Re: Remove all transforms whilst keeping in-place
Here's a link to one of my sheets, that's been drawn and packed using the python extension I'm writing.
https://www.dropbox.com/s/awe32p3c8xdfbs8/LaserBed.svg?dl=0
I tried selecting everthing in that file with Edit->Select All in All Layers, then Layer->Move Selection To Layer, and selecting a different layer for everything... but the XML tells me that each object still has a transform: matrix(...) member.
However, if I go Edit->Select All in All Layers, then Object->Ungroup (which takes *ages* for this many objects), I find each path no longer has a transform, except for the circles. If this was one of my sheets where I've got capsule-shaped paths, then the straight edges would be fine, but the arcs that form the 'caps' would still have a transform on them.
https://www.dropbox.com/s/awe32p3c8xdfbs8/LaserBed.svg?dl=0
I tried selecting everthing in that file with Edit->Select All in All Layers, then Layer->Move Selection To Layer, and selecting a different layer for everything... but the XML tells me that each object still has a transform: matrix(...) member.
However, if I go Edit->Select All in All Layers, then Object->Ungroup (which takes *ages* for this many objects), I find each path no longer has a transform, except for the circles. If this was one of my sheets where I've got capsule-shaped paths, then the straight edges would be fine, but the arcs that form the 'caps' would still have a transform on them.
Re: Remove all transforms whilst keeping in-place
Brynn has collected a set of extensions here:
http://wiki.inkscape.org/wiki/index.php ... Extensions
Yesterday I discovered one of them claims to remove all transforms. Didn't test it yet.
For the next version, there's also a 'Deep ungroup' extension
http://wiki.inkscape.org/wiki/index.php ... Extensions
Yesterday I discovered one of them claims to remove all transforms. Didn't test it yet.
For the next version, there's also a 'Deep ungroup' extension
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
-
- Posts: 9
- Joined: Wed May 25, 2016 1:01 pm
Re: Remove all transforms whilst keeping in-place
apply-transforms?
Fantastic, that appears to work!
Although it does move all my text, I guess the algorithm doesn't account for text. Gotta find an extension that will convert my text to paths first (like exporting to eps does), then I can apply this extension.
Much, much, much faster than running a batch file that opens inkscape, selects everything, ungroups everything, selects all my arcs (due to my code naming the first arc in a certain way), and simplifies them. That takes 20-30 seconds. This, I can build into my own extension.
Thank you so much!
Fantastic, that appears to work!
Although it does move all my text, I guess the algorithm doesn't account for text. Gotta find an extension that will convert my text to paths first (like exporting to eps does), then I can apply this extension.
Much, much, much faster than running a batch file that opens inkscape, selects everything, ungroups everything, selects all my arcs (due to my code naming the first arc in a certain way), and simplifies them. That takes 20-30 seconds. This, I can build into my own extension.
Thank you so much!