示例#1
0
def getNiceLengths(unitschema=None):
    if unitschema is None:
        unitschema = UnitSystem.getActiveSchema()
    if unitschema == UnitSystem.SI1 or unitschema == UnitSystem.SI2 or unitschema == UnitSystem.Centimeters or unitschema == UnitSystem.MmMin:
        nice_numbers = [1.0, 2.0, 5.0]
        nice_magnitudes = []
        for degree in range(-3, 6):
            order = 10.0**degree
            nice_magnitudes.extend([order * val for val in nice_numbers])
        return nice_magnitudes
    elif unitschema == UnitSystem.Imperial1 or unitschema == UnitSystem.ImperialBuilding or unitschema == UnitSystem.ImperialDecimal:
        inch = 25.4
        foot = 304.8
        yard = 914.4
        mile = 1609344.0
        #https://forum.freecadweb.org/viewtopic.php?f=8&t=32565#p271923
        #.005" .010", .025", .050", .100", .250", 1", 6", 1', 8', 50', 100', 500', 1000', 2500', 1 mile, 10 miles, 100 miles
        return [
            0.005 * inch, 0.010 * inch, 0.025 * inch, 0.050 * inch,
            0.10 * inch, 0.25 * inch, 0.50 * inch, 1 * inch, 2 * inch,
            6 * inch, 1 * foot, 2 * foot, 4 * foot, 8 * foot, 16 * foot,
            32 * foot, 50 * foot, 100 * foot, 250 * foot, 500 * foot,
            1000 * foot, 2500 * foot, 1 * mile, 2 * mile, 5 * mile, 10 * mile,
            25 * mile, 50 * mile, 100 * mile
        ]
    else:
        #unit unsupported? fall back to metric
        import FreeCAD as App
        App.PrintWarning(
            "Lattice Autosize: Unit schema {n} is not yet supported.\n".format(
                n=unitschema))
        return getNiceLengths(UnitSystem.SI1)
示例#2
0
 def testPrint(self):
     sLog = FreeCAD.GetStatus("MessageBox", "Log")
     sErr = FreeCAD.GetStatus("MessageBox", "Err")
     sWrn = FreeCAD.GetStatus("MessageBox", "Wrn")
     sMsg = FreeCAD.GetStatus("MessageBox", "Msg")
     FreeCAD.SetStatus("MessageBox", "Log", 0)
     FreeCAD.SetStatus("MessageBox", "Err", 0)
     FreeCAD.SetStatus("MessageBox", "Wrn", 0)
     FreeCAD.SetStatus("MessageBox", "Msg", 0)
     FreeCAD.PrintMessage("   Printing message\n")
     FreeCAD.PrintError("   Printing error\n")
     FreeCAD.PrintWarning("   Printing warning\n")
     FreeCAD.PrintLog("   Printing Log\n")
     FreeCAD.SetStatus("MessageBox", "Log", sLog)
     FreeCAD.SetStatus("MessageBox", "Err", sErr)
     FreeCAD.SetStatus("MessageBox", "Wrn", sWrn)
     FreeCAD.SetStatus("MessageBox", "Msg", sMsg)