Skip to content

Fractional units can't be converted to Float in bounding dimensions #2

@sowings13

Description

@sowings13

I use fractional units (i.e. 1 1/2"), but if I try to generate a BOM that includes dimensions, I get the following error:

Failed:
Traceback (most recent call last):
  File "CSV-BOM.py", line 540, in notify
    csvStr = self.collectData(design, bom, prefs)
  File "CSV-BOM.py", line 211, in collectData
    dimX = float(design.fusionUnitsManager.formatInternalValue(item["boundingBox["x"], defaultUnit, False))
  ValueError: could not convert string to float: '27 7/8'

I'm not a python developer, but a quick google search shows this as a way to convert fractions to decimals Convert Fraction to Float, and if I manually added that on lines 211-213 and 276-278, I was able to successfully generate the cut list. Here's what one line looked like:

dimX = float(sum(Fraction(s) for s in design.fusionUnitsManager.formatInternalValue(item["boundingBox"]["x"], defaultUnit, False).split()))

One downside is that just converts everything to decimals, so I have to then mentally convert back to fractional later when using it; ideally you'd have a better solution that automatically handled fractional units.

Otherwise, I really like your extension, thanks for making it!

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