First off, thanks to the Inkscape team for making such a great product.
I'm trying to write a script that resizes the data from a group of .svg files and places them all together into 1 finished file. Using <g transform=""> is doing the trick when I fiddle with it by hand, but I need the transformation numbers to be based on the collective width and height of a group of SVG elements - each of my .svg files' collective objects are a different size. Does Inkscape provide a mechanism in Python for calculating the width and height of the objects inside a <g> container? I've looked through the SVG spec several times and I can't seem to find a way to do this easily.
Thank you for any ideas that you have.
Calculating the width and height of a group of elements
Re: Calculating the width and height of a group of elements
Not sure about from within python, but I know that it can from the command line. (I beleve several extentions call inkscape a second time as a process to get the command line data).
from the command line, you can use the query commands:
relevent section of Man page
from the command line, you can use the query commands:
relevent section of Man page
-I, --query-id
Set the ID of the object whose dimensions are queried. If not set, query options will return the dimensions of the drawing (i.e. all document objects), not the page or viewbox
-X, --query-x
Query the X coordinate of the drawing or, if specified, of the object with --query-id. The returned value is in px (SVG user units).
-Y, --query-y
Query the Y coordinate of the drawing or, if specified, of the object with --query-id. The returned value is in px (SVG user units).
-W, --query-width
Query the width of the drawing or, if specified, of the object with --query-id. The returned value is in px (SVG user units).
-H, --query-height
Query the height of the drawing or, if specified, of the object with --query-id. The returned value is in px (SVG user units).
-S, --query-all
Prints a comma delimited listing of all objects in the SVG document with IDs defined, along with their x, y, width, and height values.