Inkscape.org
Creating New Extensions finding height and width of an object in extension script
  1. #1
    zwmm zwmm @zwmm

    The inkscape GUI shows an object's X, Y, W and H across the top. You can also get these from the command line by querying all objects in the SVG file.

    I cannot see anything in the inkex module which will provide this information.

  2. #2
    inklinea inklinea @inklinea⛰️
    *

    https://inkscape.gitlab.io/extensions/documentation/source/inkex.elements._base.html?highlight=bounding%20box#inkex.elements._base.ShapeElement.bounding_box

    selection_list = self.svg.selected

    for item in selection_list:

         item_id = item.get_id()

         bbox = item.bounding_box()

         inkex.errormsg(f'item id {item_id} x1 {bbox.left} y1 {bbox.top} width {bbox.width} height {bbox.height}')

    The bounding box of text cannot be obtained this way.

     

     

     

     

     

  3. #3
    FrankI4466 FrankI4466 @FrankI4466

    Hi,

     I want to know with and height of a text object. But nothing above is working. When I print bbox I obtain this:

    BoundingBox((-56.0, -56.0),(-187.13548107485641, -187.13548107485641))

    Is anyone can help me.

    Thank's

  4. #4
    inklinea inklinea @inklinea⛰️

    https://inkscape.org/forums/extensions/issuess-with-bounding-boxes/

    2nd post down on this thread.

  5. #5
    FrankI4466 FrankI4466 @FrankI4466

    Thank's

  6. #6
    FrankI4466 FrankI4466 @FrankI4466

    Thank's

Inkscape Inkscape.org Inkscape Forum Creating New Extensions finding height and width of an object in extension script