old_contents: # ##### BEGIN GPL LICENSE BLOCK #####
  #
  #  JewelCraft jewelry design toolkit for Blender.
  #  Copyright (C) 2015-2019  Mikhail Rachinskiy
  #
  #  This program is free software: you can redistribute it and/or modify
  #  it under the terms of the GNU General Public License as published by
  #  the Free Software Foundation, either version 3 of the License, or
  #  (at your option) any later version.
  #
  #  This program is distributed in the hope that it will be useful,
  #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  #  GNU General Public License for more details.
  #
  #  You should have received a copy of the GNU General Public License
  #  along with this program.  If not, see <https://www.gnu.org/licenses/>.
  #
  # ##### END GPL LICENSE BLOCK #####
  
  
  def convert_cm3_mm3(x):
      return x / 1000
  
  
  def convert_g_ct(x):
      return x * 5
  
  
  class Scale:
      __slots__ = ("scale", "use_conversion")
  
      def __init__(self, context):
          unit = context.scene.unit_settings
          self.scale = round(unit.scale_length, 4)
          self.use_conversion = unit.system == "METRIC" and self.scale != 0.001
  
      def from_scene(self, x, volume=False, batch=False):
          if self.use_conversion:
  
              if volume:
                  return x * 1000 ** 3 * self.scale ** 3
              if batch:
                  return tuple(v * 1000 * self.scale for v in x)
  
              return x * 1000 * self.scale
  
          return x
  
      def to_scene(self, x, volume=False, batch=False):
          if self.use_conversion:
  
              if volume:
                  return x / 1000 ** 3 / self.scale ** 3
              if batch:
                  return tuple(v / 1000 / self.scale for v in x)
  
              return x / 1000 / self.scale
  
          return x
  
new_contents: # ##### BEGIN GPL LICENSE BLOCK #####
  #
  #  JewelCraft jewelry design toolkit for Blender.
  #  Copyright (C) 2015-2019  Mikhail Rachinskiy
  #
  #  This program is free software: you can redistribute it and/or modify
  #  it under the terms of the GNU General Public License as published by
  #  the Free Software Foundation, either version 3 of the License, or
  #  (at your option) any later version.
  #
  #  This program is distributed in the hope that it will be useful,
  #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  #  GNU General Public License for more details.
  #
  #  You should have received a copy of the GNU General Public License
  #  along with this program.  If not, see <https://www.gnu.org/licenses/>.
  #
  # ##### END GPL LICENSE BLOCK #####
  
  
  def convert_cm3_mm3(x):
      return x / 1000
  
  
  def convert_g_ct(x):
      return x * 5
  
  
  class Scale:
      __slots__ = ("scale", "from_scene", "to_scene")
  
      def __init__(self, context):
          unit = context.scene.unit_settings
          self.scale = round(unit.scale_length, 4)
  
          if unit.system == "METRIC" and self.scale != 0.001:
              self.from_scene = self._from_scene
              self.to_scene = self._to_scene
          else:
              self.from_scene = self._blank
              self.to_scene = self._blank
  
      def _from_scene(self, x, volume=False, batch=False):
          if volume:
              return x * 1000 ** 3 * self.scale ** 3
          if batch:
              return tuple(v * 1000 * self.scale for v in x)
  
          return x * 1000 * self.scale
  
      def _to_scene(self, x, volume=False, batch=False):
          if volume:
              return x / 1000 ** 3 / self.scale ** 3
          if batch:
              return tuple(v / 1000 / self.scale for v in x)
  
          return x / 1000 / self.scale
  
      def _blank(self, x, volume=False, batch=False):
          return x
  
subject: Scale object remap methods