Skip to content

Incorrect Dimensions with Non-Pixel User Unit #6

@jphilbert

Description

@jphilbert

Just installed this extension on 0.92.3 and was getting some incorrect labels. I often make documents using inches with a scale of 1:1. With a test document w/ display units in inches and scale of 1, I made a reference 4in line. This yielded dimension of 0.0416666682292. Oddly this equals 4in/96px so I gathered the extension thought the document was still using pixel units.

I traced it down to this line of code I think:

value = self.userUnit2unit(value, unit)

I also noticed that if the document scale is changed it will scale the labeled dimension. For example changing the scale from 1 to 2, a 4in line becomes 0.083.

FYI, this seems to fix things for me:

try:
    elem = self.getElemFromXpath('/svg:svg/sodipodi:namedview')
    doc_scale = self.getElemAtrib(elem, 'scale-x')
    doc_scale = float(doc_scale)
except:
   doc_scale = 1

value = self.unit2unit(value, self.documentUnit, unit) / doc_scale

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions