Example #1
0
 def loadData(self, chopper):
     colorType = chopper.getUnsignedShort(
     )  # SubChunkId represents Color type.
     l = chopper.getInt()  # skip length.
     a = 1.0
     if (colorType == Rgb1Chunk.BYTE_COLOR):
         r = chopper.getUnsignedByte() / 255.0
         g = chopper.getUnsignedByte() / 255.0
         b = chopper.getUnsignedByte() / 255.0
     elif (colorType == Rgb1Chunk.BYTE_COLOR_GAMMA):
         r = chopper.getUnsignedByte() / 255.0
         g = chopper.getUnsignedByte() / 255.0
         b = chopper.getUnsignedByte() / 255.0
         a = chopper.getUnsignedByte() / 255.0
     elif (colorType == Rgb1Chunk.FLOAT_COLOR):
         r = chopper.getFloat()
         g = chopper.getFloat()
         b = chopper.getFloat()
     elif (colorType == Rgb1Chunk.FLOAT_COLOR_GAMMA):
         r = chopper.getFloat()
         g = chopper.getFloat()
         b = chopper.getFloat()
         a = chopper.getFloat()
     else:
         FreeCAD.PrintError(
             "Only RGB colors are enabled! Color type = %X, len = %d" %
             (colorType, self.len))
         r = l / 32767.0
         g = chopper.getInt() / 32767.0
         b = chopper.getUnsignedShort() / 32767.0
     self.data = (r, g, b, a)
Example #2
0
 def loadData(self, chopper):
     colorType = chopper.getUnsignedShort(
     )  # SubChunkId represents Color type.
     l = chopper.getInt()  # skip length.
     a = 1.0
     if (colorType == 0x10):  # rgb as float values 0.0 ... 1.0
         r = chopper.getFloat()
         g = chopper.getFloat()
         b = chopper.getFloat()
     elif (colorType == 0x11):  # rgb as float values 0 .. 255
         r = chopper.getUnsignedByte() / 255.0
         g = chopper.getUnsignedByte() / 255.0
         b = chopper.getUnsignedByte() / 255.0
     elif (colorType == 0x12
           ):  # rgb as float values 0 .. 255 (incl. gamma correction)
         r = chopper.getUnsignedByte() / 255.0
         g = chopper.getUnsignedByte() / 255.0
         b = chopper.getUnsignedByte() / 255.0
     elif (colorType == 0x13
           ):  # rgb as float values 0.0 ... 1.0 (incl. gamma correction)
         r = chopper.getFloat()
         g = chopper.getFloat()
         b = chopper.getFloat()
         a = chopper.getFloat()
     else:
         b = chopper.getChunkBytes()
         FreeCAD.PrintError(
             "Only RGB colors are enabled! Color type = %X: %s" %
             (colorType, " ".join(["%02X" % (c) for c in b])))
         r = 0.5
         g = 0.5
         b = 0.5
     self.data = (r, g, b, a)
Example #3
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)
Example #4
0
def InitApplications():
    try:
        import sys, os
    except:
        FreeCAD.PrintError(
            "\n\nSeems the python standard libs are not installed, bailing out!\n\n"
        )
        raise
    # Checking on FreeCAD module path ++++++++++++++++++++++++++++++++++++++++++
    ModDir = FreeCAD.getHomePath() + 'Mod'
    ModDir = os.path.realpath(ModDir)
    BinDir = FreeCAD.getHomePath() + 'bin'
    BinDir = os.path.realpath(BinDir)
    LibDir = FreeCAD.getHomePath() + 'lib'
    LibDir = os.path.realpath(LibDir)
    AddPath = FreeCAD.ConfigGet("AdditionalModulePaths").split(";")
    HomeMod = FreeCAD.ConfigGet("UserAppData") + "Mod"
    HomeMod = os.path.realpath(HomeMod)
    MacroDir = FreeCAD.ParamGet(
        "User parameter:BaseApp/Preferences/Macro").GetString("MacroPath")
    MacroMod = os.path.realpath(MacroDir + "/Mod")
    ModPar = FreeCAD.ParamGet("System parameter:Modules")

    #print FreeCAD.getHomePath()
    if os.path.isdir(FreeCAD.getHomePath() + 'src\\Tools'):
        sys.path.append(FreeCAD.getHomePath() + 'src\\Tools')
    # Searching for module dirs +++++++++++++++++++++++++++++++++++++++++++++++++++
    # Use dict to handle duplicated module names
    ModDict = {}
    if os.path.isdir(ModDir):
        ModDirs = os.listdir(ModDir)
        for i in ModDirs:
            ModDict[i.lower()] = os.path.join(ModDir, i)
    else:
        Wrn("No modules found in " + ModDir + "\n")
    # Search for additional modules in the home directory
    if os.path.isdir(HomeMod):
        HomeMods = os.listdir(HomeMod)
        for i in HomeMods:
            ModDict[i.lower()] = os.path.join(HomeMod, i)
    # Search for additional modules in the macro directory
    if os.path.isdir(MacroMod):
        MacroMods = os.listdir(MacroMod)
        for i in MacroMods:
            key = i.lower()
            if key not in ModDict: ModDict[key] = os.path.join(MacroMod, i)
    # Search for additional modules in command line
    for i in AddPath:
        if os.path.isdir(i): ModDict[i] = i
    #AddModPaths = App.ParamGet("System parameter:AdditionalModulePaths")
    #Err( AddModPaths)
    # add also this path so that all modules search for libraries
    # they depend on first here
    PathExtension = BinDir + os.pathsep
    # prepend all module paths to Python search path
    Log('Init:   Searching for modules...\n')
    FreeCAD.__path__ = ModDict.values()
    for Dir in ModDict.values():
        if ((Dir != '') & (Dir != 'CVS') & (Dir != '__init__.py')):
            ModGrp = ModPar.GetGroup(Dir)
            sys.path.insert(0, Dir)
            PathExtension += Dir + os.pathsep
            InstallFile = os.path.join(Dir, "Init.py")
            if (os.path.exists(InstallFile)):
                try:
                    execfile(InstallFile)
                except Exception, inst:
                    Log('Init:      Initializing ' + Dir + '... failed\n')
                    Err('During initialization the error ' + str(inst) +
                        ' occurred in ' + InstallFile + '\n')
                else:
                    Log('Init:      Initializing ' + Dir + '... done\n')
            else:
                Log('Init:      Initializing ' + Dir +
                    '(Init.py not found)... ignore\n')
Example #5
0
#*   You should have received a copy of the GNU Library General Public     *
#*   License along with FreeCAD; if not, write to the Free Software        *
#*   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
#*   USA                                                                   *
#*                                                                         *
#*   Juergen Riegel 2002                                                   *
#***************************************************************************/

# imports the one and only
import FreeCAD

try:
    import sys, os, dircache
except:
    FreeCAD.PrintError(
        "\n\nSeems the python standard libs are not installed, bailing out!\n\n"
    )
    raise


def InitDocumentation():
    # Checking on FreeCAD documentation path ++++++++++++++++++++++++++++++++++++++++++
    if os.path.isdir(FreeCAD.ConfigGet("HomePath") + 'Doc'):
        if os.path.isdir(
                FreeCAD.ConfigGet("HomePath") +
                'Doc\\free-cad.sourceforge.net'):
            FreeCAD.ConfigSet(
                "DocPath",
                FreeCAD.ConfigGet("HomePath") +
                'Doc\\free-cad.sourceforge.net')