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

Fix MC units and reduce code duplication of UNITS_PER_METER #658

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading