Skip to content

Commit

Permalink
Merge pull request #658 from jdegenstein/units
Browse files Browse the repository at this point in the history
Fix MC units and reduce code duplication of UNITS_PER_METER
  • Loading branch information
jdegenstein authored Jul 11, 2024
2 parents 28b6689 + 209b772 commit f6a3501
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/build123d/build_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
#

# LENGTH CONSTANTS
MC = 0.0001
MC = 0.001
MM = 1
CM = 10 * MM
M = 1000 * MM
Expand Down
12 changes: 1 addition & 11 deletions src/build123d/exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
Vector,
VectorLike,
)
from build123d.build_common import UNITS_PER_METER

PathSegment = Union[PT.Line, PT.Arc, PT.QuadraticBezier, PT.CubicBezier]

Expand Down Expand Up @@ -249,17 +250,6 @@ def iso_pattern(*args):
return result


# Scale factor to convert various units to meters.
UNITS_PER_METER = {
Unit.IN: 100 / 2.54,
Unit.FT: 100 / (12 * 2.54),
Unit.MC: 1_000_000,
Unit.MM: 1000,
Unit.CM: 100,
Unit.M: 1,
}


def unit_conversion_scale(from_unit: Unit, to_unit: Unit) -> float:
"""Return the multiplicative conversion factor to go from from_unit to to_unit."""
result = UNITS_PER_METER[to_unit] / UNITS_PER_METER[from_unit]
Expand Down

0 comments on commit f6a3501

Please sign in to comment.