connorferster / forallpeople

Python SI units library: your 'daily driver' for calculations.
Apache License 2.0
307 stars 40 forks source link

Convert 'm' to 'mm' in Structural env #69

Open cslotboom opened 1 year ago

cslotboom commented 1 year ago

Hey! I'm trying to convert meters to mm in the structural environment and struggling. 'mm' doesn't seem to be in the defined or derived units - is this expected?

import forallpeople as si
si.environment('structural')
print(si.m)
print(si.mm)
out = si.m.to('mm')

image

DonCammne commented 9 months ago

Ehi, I guess that you can use .to only to change the current unit to a different one (like m to inch) but not the prefix. See the code below that prints the possible options for .to:

import forallpeople
forallpeople.environment('structural', top_level=True)
measure = 1 *m
print(measure.to())

The output:

Available units: 
ft
inch
None

To do that you need .prefix

import forallpeople
forallpeople.environment('structural', top_level=True)
measure = 1 *m
print(measure.prefix('c'))

The output:

100.000 cm

I hope this helped :)