Пример #1
0
 def _handleConstants(self):
     self.constsdef = {
         "Gravity": constants.gravity(),
         "StefanBoltzmann": constants.stefan_boltzmann(),
         "PermittivityOfVacuum": constants.vacuum_permittivity(),
         "BoltzmannConstant": constants.boltzmann_constant(),
     }
Пример #2
0
 def __init__(self, obj):
     super(ConstantVacuumPermittivity, self).__init__(obj)
     obj.addProperty("App::PropertyVacuumPermittivity",
                     "VacuumPermittivity", "Constants",
                     "Set the permittivity of vacuum")
     obj.VacuumPermittivity = Units.Quantity(
         constants.vacuum_permittivity())
Пример #3
0
 def __init__(self, obj):
     super(ConstantVacuumPermittivity, self).__init__(obj)
     obj.addProperty(
         "App::PropertyVacuumPermittivity",
         "VacuumPermittivity",
         "Constants",
         "Overwrites default permittivity of vacuum"
     )
     # we must set an expression so that the small value can actually be entered
     permittivity = Units.Quantity(constants.vacuum_permittivity()).getValueAs("F/m")
     obj.setExpression("VacuumPermittivity", str(permittivity))
Пример #4
0
    Console.PrintMessage("The unit schema mm/kg/s is used. So export and "
                         "import is done in standard FreeCAD units.\n")
    UNITS = {
        "L": "mm",
        "M": "kg",
        "T": "s",
        "I": "A",
        "O": "K",
        "N": "mol",
        "J": "cd",
    }

CONSTS_DEF = {
    "Gravity": constants.gravity(),
    "StefanBoltzmann": constants.stefan_boltzmann(),
    "PermittivityOfVacuum": constants.vacuum_permittivity(),
    "BoltzmannConstant": constants.boltzmann_constant(),
}


def getFromUi(value, unit, outputDim):
    quantity = Units.Quantity(str(value) + str(unit))
    return convert(quantity, outputDim)


def convert(quantityStr, unit):
    quantity = Units.Quantity(quantityStr)
    for key, setting in UNITS.items():
        unit = unit.replace(key, setting)
    return float(quantity.getValueAs(unit))