Skip to content

Instantly share code, notes, and snippets.

@Eneroth3
Last active December 3, 2020 12:57
Show Gist options
  • Save Eneroth3/7173bbf6247c344c5719c08d00d4c0ac to your computer and use it in GitHub Desktop.
Save Eneroth3/7173bbf6247c344c5719c08d00d4c0ac to your computer and use it in GitHub Desktop.
Test if SketchUp uses metric units
def metric?(model = Sketchup.active_model)
unit_options = model.options["UnitsOptions"]
return false unless unit_options["LengthFormat"] == Length::Decimal
[
Length::Millimeter,
Length::Centimeter,
Length::Meter
].include?(unit_options["LengthUnit"])
end
# Example usage
default = metric? ? 100.mm : 4.inch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment