Macro findConfigFiles: Difference between revisions

From FreeCAD Documentation
(Created page with "==Macro findConfigFiles== Use this macro to find your user setting configuration files. These files: system.cfg and user.cfg can be renamed in order to reset FreeCAD's sett...")
 
Line 9: Line 9:
import subprocess, os
import subprocess, os
from PySide import QtCore,QtGui
from PySide import QtCore,QtGui
import platform
import platform <nowiki>
__title__ = "findConfigFiles"
__title__ = "findConfigFiles"
__author__ = "TheMarkster"
__author__ = "TheMarkster"
Line 15: Line 15:
__Wiki__ = "http://www.freecadweb.org/wiki/index.php?title=Macro_findConfigFiles"
__Wiki__ = "http://www.freecadweb.org/wiki/index.php?title=Macro_findConfigFiles"
__date__ = "2018.07.22"
__date__ = "2018.07.22"
__version__ = __date__
__version__ = __date__</nowiki>
#OS: Windows 10
#OS: Windows 10
#Word size of OS: 64-bit
#Word size of OS: 64-bit

Revision as of 18:39, 22 July 2018

Macro findConfigFiles

Use this macro to find your user setting configuration files. These files: system.cfg and user.cfg can be renamed in order to reset FreeCAD's settings back to their original defaults. This can sometimes fix problems you are having with FreeCAD.


# -*- coding: utf-8 -*-
import FreeCAD
import subprocess, os 
from PySide import QtCore,QtGui
import platform 
 __title__ = "findConfigFiles"
 __author__ = "TheMarkster"
 __url__ = "https://www.freecadweb.org/wiki/Macro_findConfigFiles"
 __Wiki__ = "http://www.freecadweb.org/wiki/index.php?title=Macro_findConfigFiles"
 __date__ = "2018.07.22" 
 __version__ = __date__
#OS: Windows 10
#Word size of OS: 64-bit
#Word size of FreeCAD: 64-bit
#Version: 0.18.14061 (Git)
#Build type: Release
#Branch: master
#Hash: c4fc02cbcfff975712e977dc08f859fba71ba0ad
#Python version: 2.7.14
#Qt version: 4.8.7
#Coin version: 4.0.0a
#OCC version: 7.2.0
#Locale: English/UnitedStates (en_US)

"""A macro to help with user configuration files --<TheMarkster>"""

clipboard = QtGui.QApplication.clipboard()
sys = platform.system()
userFolder = App.getUserAppDataDir()
clipboard.setText(userFolder)
msgBox = QtGui.QMessageBox()
msgBox.setWindowTitle('findConfigFiles macro')
msgBox.setTextFormat(QtCore.Qt.RichText)

#HTML tags are part of the source -- do not edit

msg = """
 These files are located here on your system:<br/>
 <br/>
 <b><font color = 'blue'>"""+userFolder+"""</font></b><br/>
 <br/>
 (Has been already copied to your clipboard.)<br/>
 <br/>
 This macro is to aid you in renaming your user app configuration <br/>
 files.  This can *sometimes* correct some issues you are having <br/>
 using FreeCAD.  If it doesn't work you can always go back and <br/>
 rename them back to their original names.<br/>
 <br/>
 To reset your configuration settings, exit FreeCAD and rename these 2 files:<br/>
 <br/>
 <b><font color='blue'>system.cfg</font></b> (rename to system.cfg.backup or something similar)<br/>
 <b><font color = 'blue'>user.cfg</font></b>   (rename to user.cfg.backup or something similar)<br/>
 <br/>
 When you press OK we will attempt to open the folder location for you, but <br/>
 you might need to open it manually if this doesn't work. <br/>
 <br/>
 Renaming these files will reset *all* of your FreeCAD settings back to default.<br/>
 <br/>
 (This macro does *not* make any changes to these files or to your user settings.)<br/>
 """

msgBox.setText(msg)
msgBox.exec_()

if 'Windows' in sys:
    subprocess.Popen('start explorer.exe '+userFolder, shell=True)
elif 'Linux' in sys:
    os.system("xdg-open '%s'" % userFolder)
elif 'Darwin' in sys:
    subprocess.Popen(["open", userFolder])
else:
    msgBox = QtGui.QMessageBox()
    msg = "We were unable to determine your platform, and thus cannot open your '+userFolder+' for you, but you can still do it manually.\n"
    msgBox.exec_()