Macro findConfigFiles: Difference between revisions
TheMarkster (talk | contribs) |
TheMarkster (talk | contribs) (0.2022.03.15) |
||
(23 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
<languages/> |
|||
==Macro findConfigFiles== |
|||
<translate> |
|||
<!--T:1--> |
|||
==Description== |
|||
{{Macro |
|||
{{Macro|Icon=Text-x-python|Name=findConfigFiles|Description=Locate folder containing config files|Author=TheMarkster|Version=2018.07.22|Date=2018-07-22}} |
|||
|Name=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. |
|||
|Icon=Macro_findConfigFiles.png |
|||
|Description=Use this macro to find your user setting configuration files, that is,<br/>'''system.cfg'''<br/>'''user.cfg'''<br/>These files 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.<br/>You should exit FreeCAD before renaming the files, and then open FreeCAD again afterwards. If renaming the files did not solve the issue you were having you can delete the new files FreeCAD created and rename the original files back to their original names in order to restore your previous settings. You can also safely delete the renamed files once you are certain you no longer need or want them, but it is recommended to rename them instead of deleting until you are certain they are no longer needed.<br/>Note: The macro does not rename the files or make any changes to your settings. It merely finds the location of these files, copies that location to the clipboard, and (attempts to) open the folder containing these files on your computer using the default file browser. |
|||
|Author=TheMarkster |
|||
|Version=2022.03.15 |
|||
|Date=2022-03-15 |
|||
|FCVersion=All |
|||
|Download=[https://www.freecadweb.org/wiki/images/b/b5/Macro_findConfigFiles.png ToolBar Icon] |
|||
}} |
|||
==Description== <!--T:2--> |
|||
==Script== |
|||
<!--T:11--> |
|||
# -*- coding: utf-8 -*- |
|||
Use this macro to find your user setting configuration files, that is, |
|||
import FreeCAD |
|||
* {{incode|system.cfg}} |
|||
import subprocess, os |
|||
* {{incode|user.cfg}} |
|||
from PySide import QtCore,QtGui |
|||
import platform |
|||
<!--T:5--> |
|||
__title__ = "findConfigFiles" |
|||
These files 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. |
|||
__author__ = "TheMarkster" |
|||
__url__ = <nowiki>"https://www.freecadweb.org/wiki/Macro_findConfigFiles"</nowiki> |
|||
<!--T:6--> |
|||
__Wiki__ = <nowiki>"http://www.freecadweb.org/wiki/index.php?title=Macro_findConfigFiles"</nowiki> |
|||
You should exit FreeCAD before renaming the files, and then open FreeCAD again afterwards. If renaming the files did not solve the issue you were having you can delete the new files FreeCAD created and rename the original files back to their original names in order to restore your previous settings. You can also safely delete the renamed files once you are certain you no longer need or want them, but it is recommended to rename them instead of deleting until you are certain they are no longer needed. |
|||
__date__ = "2018.07.22" |
|||
__version__ = __date__ |
|||
<!--T:7--> |
|||
#OS: Windows 10 |
|||
Note: The macro does not rename the files or make any changes to your settings. It merely finds the location of these files, copies that location to the clipboard, and (attempts to) open the folder containing these files on your computer using the default file browser. |
|||
#Word size of OS: 64-bit |
|||
#Word size of FreeCAD: 64-bit |
|||
==Script== <!--T:8--> |
|||
#Version: 0.18.14061 (Git) |
|||
#Build type: Release |
|||
<!--T:12--> |
|||
#Branch: master |
|||
ToolBar icon [[Image:Macro_findConfigFiles.png]] |
|||
#Hash: c4fc02cbcfff975712e977dc08f859fba71ba0ad |
|||
#Python version: 2.7.14 |
|||
</translate> |
|||
#Qt version: 4.8.7 |
|||
'''Macro_findConfigFiles.FCMacro''' |
|||
#Coin version: 4.0.0a |
|||
#OCC version: 7.2.0 |
|||
{{MacroCode|code= |
|||
#Locale: English/UnitedStates (en_US) |
|||
# -*- coding: utf-8 -*- |
|||
import FreeCAD |
|||
"""A macro to help with user configuration files --<TheMarkster>""" |
|||
import subprocess, os |
|||
from PySide import QtCore,QtGui |
|||
clipboard = QtGui.QApplication.clipboard() |
|||
import platform |
|||
__title__ = "findConfigFiles" |
|||
userFolder = App.getUserAppDataDir() |
|||
__author__ = "TheMarkster" |
|||
clipboard.setText(userFolder) |
|||
__url__ = "https://www.freecadweb.org/wiki/Macro_findConfigFiles" |
|||
msgBox = QtGui.QMessageBox() |
|||
__Wiki__ = "http://www.freecadweb.org/wiki/index.php?title=Macro_findConfigFiles" |
|||
msgBox.setWindowTitle('findConfigFiles macro') |
|||
__date__ = "2022.03.15" |
|||
msgBox.setTextFormat(QtCore.Qt.RichText) |
|||
__version__ = __date__ |
|||
#HTML tags are part of the source -- do not edit |
|||
"""A macro to help with user configuration files --<TheMarkster>""" |
|||
msg = """<nowiki> |
|||
These files are located here on your system:<br/> |
|||
clipboard = QtGui.QApplication.clipboard() |
|||
<br/> |
|||
sys = platform.system() |
|||
<b><font color = 'blue'>"""+userFolder+"""</font></b><br/> |
|||
userFolder = App.getUserConfigDir() if hasattr(App,"getUserConfigDir") else App.getUserAppDataDir() |
|||
<br/> |
|||
(Has been already copied to your clipboard.)<br/> |
|||
msgBox = QtGui.QMessageBox() |
|||
<br/> |
|||
msgBox.setWindowTitle('findConfigFiles macro') |
|||
This macro is to aid you in renaming your user app configuration <br/> |
|||
msgBox.setTextFormat(QtCore.Qt.RichText) |
|||
files. This can *sometimes* correct some issues you are having <br/> |
|||
#msgBox.setStandardButtons(QtGui.QMessageBox.Ok.__or__(QtGui.QMessageBox.Cancel)) |
|||
using FreeCAD. If it doesn't work you can always go back and <br/> |
|||
#__or__() is deprecated in python 3.8 and the pipe symbol interferes with addon manager, so add buttons separately |
|||
rename them back to their original names.<br/> |
|||
msgBox.addButton(QtGui.QMessageBox.Ok) |
|||
<br/> |
|||
msgBox.addButton(QtGui.QMessageBox.Cancel) |
|||
To reset your configuration settings, exit FreeCAD and rename these 2 files:<br/> |
|||
msgBox.addButton("Copy to Clipboard and Open",QtGui.QMessageBox.ApplyRole) |
|||
<br/> |
|||
<b><font color='blue'>system.cfg</font></b> (rename to system.cfg.backup or something similar)<br/> |
|||
#HTML tags are part of the source -- do not edit |
|||
<b><font color = 'blue'>user.cfg</font></b> (rename to user.cfg.backup or something similar)<br/> |
|||
#thanks to user C4e for help with the paragraph formatting |
|||
<br/> |
|||
msg = """ |
|||
When you press OK we will attempt to open the folder location for you, but <br/> |
|||
These files are located here on your system: |
|||
you might need to open it manually if this doesn't work. <br/> |
|||
< |
<p> |
||
<b><font color = 'blue'>""" + userFolder + """</font></b> |
|||
Renaming these files will reset *all* of your FreeCAD settings back to default.<br/> |
|||
< |
</p> |
||
<p> |
|||
(This macro does *not* make any changes to these files or to your user settings.)<br/> |
|||
This macro was created to support you in renaming the configuration files of your user application. |
|||
"""</nowiki> |
|||
This can <i>sometimes</i> correct some issues you are having using FreeCAD. |
|||
If it doesn't work you can always go back and rename them back to their original names. |
|||
msgBox.setText(msg) |
|||
</p> |
|||
msgBox.exec_() |
|||
<p> |
|||
To reset your configuration settings, exit FreeCAD and rename these 2 files: |
|||
if 'Windows' in sys: |
|||
<ul> |
|||
subprocess.Popen('start explorer.exe '+userFolder, shell=True) |
|||
<li><b><font color='blue'>system.cfg</font></b> |
|||
elif 'Linux' in sys: |
|||
<li><b><font color = 'blue'>user.cfg</font></b> |
|||
os.system("xdg-open '%s'" % userFolder) |
|||
</ul> |
|||
elif 'Darwin' in sys: |
|||
Rename them e.g. to user/system.cfg.backup or something similar. |
|||
subprocess.Popen(["open", userFolder]) |
|||
</p> |
|||
else: |
|||
<p> |
|||
msgBox = QtGui.QMessageBox() |
|||
When you press OK the macro will attempt to open the folder location for you, but |
|||
msg = "We were unable to determine your platform, and thus cannot open your '+userFolder+' for you, but you can still do it manually.\n" |
|||
you might need to open it manually if this doesn't work. |
|||
msgBox.exec_() |
|||
</p> |
|||
<p> |
|||
Renaming these files will reset <i>all</i> of your FreeCAD settings back to default. |
|||
</p> |
|||
<p> |
|||
(This macro does <i>not</i> make any changes to these files or to your user settings.)</p> |
|||
""" |
|||
msgBox.setText(msg) |
|||
ok = msgBox.exec_() |
|||
if ok==0: |
|||
clipboard.setText(userFolder) |
|||
if ok == QtGui.QMessageBox.Ok or ok==0: |
|||
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_()}} |
|||
<translate> |
|||
==Link== <!--T:9--> |
|||
<!--T:10--> |
|||
[https://forum.freecadweb.org/viewtopic.php?f=22&t=29888 findConfigFiles macro] |
|||
</translate> |
Latest revision as of 21:31, 15 March 2022
Description |
---|
Use this macro to find your user setting configuration files, that is, system.cfg user.cfg These files 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. You should exit FreeCAD before renaming the files, and then open FreeCAD again afterwards. If renaming the files did not solve the issue you were having you can delete the new files FreeCAD created and rename the original files back to their original names in order to restore your previous settings. You can also safely delete the renamed files once you are certain you no longer need or want them, but it is recommended to rename them instead of deleting until you are certain they are no longer needed. Note: The macro does not rename the files or make any changes to your settings. It merely finds the location of these files, copies that location to the clipboard, and (attempts to) open the folder containing these files on your computer using the default file browser. Macro version: 2022.03.15 Last modified: 2022-03-15 FreeCAD version: All Download: ToolBar Icon Author: TheMarkster |
Author |
TheMarkster |
Download |
ToolBar Icon |
Links |
Macros recipes How to install macros How to customize toolbars |
Macro Version |
2022.03.15 |
Date last modified |
2022-03-15 |
FreeCAD Version(s) |
All |
Default shortcut |
None |
See also |
None |
Description
Use this macro to find your user setting configuration files, that is,
system.cfg
user.cfg
These files 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.
You should exit FreeCAD before renaming the files, and then open FreeCAD again afterwards. If renaming the files did not solve the issue you were having you can delete the new files FreeCAD created and rename the original files back to their original names in order to restore your previous settings. You can also safely delete the renamed files once you are certain you no longer need or want them, but it is recommended to rename them instead of deleting until you are certain they are no longer needed.
Note: The macro does not rename the files or make any changes to your settings. It merely finds the location of these files, copies that location to the clipboard, and (attempts to) open the folder containing these files on your computer using the default file browser.
Script
Macro_findConfigFiles.FCMacro
# -*- 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__ = "2022.03.15" __version__ = __date__ """A macro to help with user configuration files --<TheMarkster>""" clipboard = QtGui.QApplication.clipboard() sys = platform.system() userFolder = App.getUserConfigDir() if hasattr(App,"getUserConfigDir") else App.getUserAppDataDir() msgBox = QtGui.QMessageBox() msgBox.setWindowTitle('findConfigFiles macro') msgBox.setTextFormat(QtCore.Qt.RichText) #msgBox.setStandardButtons(QtGui.QMessageBox.Ok.__or__(QtGui.QMessageBox.Cancel)) #__or__() is deprecated in python 3.8 and the pipe symbol interferes with addon manager, so add buttons separately msgBox.addButton(QtGui.QMessageBox.Ok) msgBox.addButton(QtGui.QMessageBox.Cancel) msgBox.addButton("Copy to Clipboard and Open",QtGui.QMessageBox.ApplyRole) #HTML tags are part of the source -- do not edit #thanks to user C4e for help with the paragraph formatting msg = """ These files are located here on your system: <p> <b><font color = 'blue'>""" + userFolder + """</font></b> </p> <p> This macro was created to support you in renaming the configuration files of your user application. This can <i>sometimes</i> correct some issues you are having using FreeCAD. If it doesn't work you can always go back and rename them back to their original names. </p> <p> To reset your configuration settings, exit FreeCAD and rename these 2 files: <ul> <li><b><font color='blue'>system.cfg</font></b> <li><b><font color = 'blue'>user.cfg</font></b> </ul> Rename them e.g. to user/system.cfg.backup or something similar. </p> <p> When you press OK the macro will attempt to open the folder location for you, but you might need to open it manually if this doesn't work. </p> <p> Renaming these files will reset <i>all</i> of your FreeCAD settings back to default. </p> <p> (This macro does <i>not</i> make any changes to these files or to your user settings.)</p> """ msgBox.setText(msg) ok = msgBox.exec_() if ok==0: clipboard.setText(userFolder) if ok == QtGui.QMessageBox.Ok or ok==0: 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_()