diff --git a/inkscape/objects_to_spine.py b/inkscape/objects_to_spine.py index e785936..e1edd4f 100644 --- a/inkscape/objects_to_spine.py +++ b/inkscape/objects_to_spine.py @@ -303,19 +303,23 @@ def delete_invisible_children(node: BaseElement): # @staticmethod def get_bounding_box(self, node: BaseElement) -> tuple[float, float, float, float] | None: - transform = None - parent = node.getparent() - if parent is not None: - transform = parent.composed_transform() - bounding_box = node.bounding_box(transform) - - if bounding_box is None: - return None - - x = round(self.svg.uutounit(bounding_box.x.minimum)) - y = round(self.svg.uutounit(bounding_box.y.minimum)) - width = round(self.svg.uutounit(bounding_box.width)) - height = round(self.svg.uutounit(bounding_box.height)) + node_id = node.get_id() + + def q(arg: str) -> float: + # Ask Inkscape for the bbox of this id in page coordinates (px) + out = inkscape( + self.options.input_file, + **{ + "query-id": node_id, + arg: None, + } + ) + return float(str(out).strip()) + + x = q("query-x") + y = q("query-y") + width = q("query-width") + height = q("query-height") return x, y, width, height @staticmethod