spakin / SimpInkScr

Simple Inkscape Scripting
https://inkscape.org/~pakin/%E2%98%85simple-inkscape-scripting
GNU General Public License v3.0
320 stars 31 forks source link

Ungrouping objects also undoes the group's transform #115

Closed odisseus closed 9 months ago

odisseus commented 10 months ago

I have a script which generates several objects, groups them and applies a transform to the whole group. When I ungroup these objects with the Inkscape UI, all the objects remain in place. However, if I call the group's ungroup() method within the script, the objects look like the group's transform has never been applied to them (e. g. shifted coordinate origin).

spakin commented 10 months ago

That's an interesting discrepancy between Inkscape and Simple Inkscape Scripting. When I get back from travel (toward the end of the month) I'll look into making ungroup first apply its transform to its immediate children. In the meantime, you can use code like the following to perform that step explicitly:

for o in gr:
    o.transform = gr.transform @ o.transform
gr.ungroup()
spakin commented 9 months ago

ungroup's behavior should now match that of Inkscape's. Post again if you find any cases I overlooked.

odisseus commented 9 months ago

It works for me, thanks!