Skip to content

Commit

Permalink
Provide an option to discard the parent transform on ungroup
Browse files Browse the repository at this point in the history
Perhaps someone will want the old behavior.
  • Loading branch information
spakin committed Dec 3, 2023
1 parent 9a9c393 commit 423f000
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions simpinkscr/simple_inkscape_scripting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,7 @@ def _append_or_extend(self, objs):
else:
self.append(objs)

def ungroup(self, objs=None):
def ungroup(self, objs=None, preserve_transform=True):
'''Remove one or more objects from the group and add it to the
top level. Return the list of objects that were ungrouped.'''
# Add each object to the top level.
Expand All @@ -1347,13 +1347,14 @@ def ungroup(self, objs=None):

# Apply the SimpleGroup's transform (if any) to each of the
# objects to be removed from it.
for o in objs:
try:
# Inkscape 1.2+
o.transform = self.transform @ o.transform
except TypeError:
# Inkscape 1.1
o.transform = o.transform * self.transform
if preserve_transform:
for o in objs:
try:
# Inkscape 1.2+
o.transform = self.transform @ o.transform
except TypeError:
# Inkscape 1.1
o.transform = o.transform * self.transform

# Remove each object from the SimpleGroup. It has already been
# removed from the SVG group as a side effect of the call to
Expand Down

0 comments on commit 423f000

Please sign in to comment.