Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Apologies if this has been answered, I've just spent 2 hours trying to figure this out and I can't explain it.
I'm pulling parameters using Python script and when I display the parameter value for an expression of 1/8" it shows me 0.3175. Seeing this in several parameter values I've spot checked.
Code Snippet:
design = adsk.fusion.Design.cast(app.activeProduct)
for parm in design.allParameters:
if parm.name == "d700":
app.log(f'debug value: parm.name: {parm.name} value: {parm.value}, str: {str(parm.value)}')
fracVal = 1/8
app.log(f'fracVal = 1/8: {fracVal}')
floatVal = float(1/8)
app.log(f'floatVal = float(1/8): {floatVal}')
d = 1.0/8.0
app.log(f'd = 1.0/8.0: {d}')
Result:
debug value: parm.name: d700 value: 0.3175, str: 0.3175
fracVal = 1/8: 0.125
floatVal = float(1/8): 0.125
d = 1.0/8.0: 0.125
A lot of noise online about floating point precision, which is why I tested the 3 methods to generate a float value.
I have another UserParameter with an expression of 5 1/4", but the value prints as 13.335.
What am I missing?
Thanks in advance!
Solved! Go to Solution.