Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sowings13 opened this issue Sep 19, 2018 · 1 comment · May be fixed by #7
Open

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

sowings13 opened this issue Sep 19, 2018 · 1 comment · May be fixed by #7

Comments

@sowings13
Copy link

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!

@loganhnry
Copy link

loganhnry commented Nov 5, 2019

I am having the same issue. If I switch my units to decimal (mm) it will export, but with really strange dimensions in the csv. I tried to modify the code but must not have done it correctly. I'm assuming it's a Fusion 360 update that caused the issue, since the installation tutorial is no longer accurate (menu location, as well as I had to select the entire folder and not simply the .py file).

newellista pushed a commit to newellista/CSV-BOM that referenced this issue Apr 22, 2021
to a float, by parsing the string, converting the pieces and converting
the pieces to a float.

Shout out to @sowings13 and @loganhnry for the diagnosis and reporting
it in macmanpb#2

This will resolve macmanpb#2
@newellista newellista linked a pull request Apr 22, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants