def get_material_template(withSpaces=False): # material properties # see the following resources in the FreeCAD wiki for more # information about the material specific properties: # https://www.freecadweb.org/wiki/Material_data_model # https://www.freecadweb.org/wiki/Material import yaml template_data = yaml.safe_load( open( join(FreeCAD.ConfigGet('AppHomePath'), 'Mod/Material/Templatematerial.yml'))) if withSpaces: # on attributes, add a space before a capital letter # will be used for better display in the ui import re for group in template_data: gg = list(group.keys())[0] # group dict has only one key # iterating over a dict and changing it is not allowed # thus it is iterated over a list of the keys for proper in list(group[gg].keys()): new_proper = re.sub(r"(\w)([A-Z]+)", r"\1 \2", proper) group[gg][new_proper] = group[gg][proper] del group[gg][proper] return template_data
def write(filename, dictionary): "writes the given dictionary to the given file" # sort the data into sections contents = [] for key in FileStructure: contents.append({"keyname": key[0]}) if key[0] == "Meta": header = contents[-1] elif key[0] == "User defined": user = contents[-1] for p in key[1]: contents[-1][p] = "" for k, i in dictionary.iteritems(): found = False for group in contents: if not found: if k in group.keys(): group[k] = i found = True if not found: user[k] = i # write header rev = FreeCAD.ConfigGet("BuildVersionMajor") + "." + FreeCAD.ConfigGet( "BuildVersionMinor") + " " + FreeCAD.ConfigGet("BuildRevision") f = pythonopen(filename, "wb") f.write("; " + header["CardName"] + "\n") f.write("; " + header["AuthorAndLicense"] + "\n") f.write("; file produced by FreeCAD " + rev + "\n") f.write( "; information about the content of this card can be found here:\n") f.write("; http://www.freecadweb.org/wiki/index.php?title=Material\n") f.write("\n") if header["Source"]: f.write("; source of the data provided in this card:\n") f.write("; " + header["Source"] + "\n") f.write("\n") # write sections for s in contents: if s["keyname"] != "Meta": if len(s) > 1: # if the section has no contents, we don't write it f.write("[" + s["keyname"] + "]\n") for k, i in s.iteritems(): if k != "keyname": f.write(k + "=" + i.encode('utf-8') + "\n") f.write("\n") f.close()
def run(self): "installs or updates the selected addon" git = None try: import git except: self.info_label.emit("python-git not found.") FreeCAD.Console.PrintWarning(translate("AddonsInstaller","python-git not found. Using standard download instead.\n")) try: import zipfile except: self.info_label.emit("no zip support.") FreeCAD.Console.PrintError(translate("AddonsInstaller","Your version of python doesn't appear to support ZIP files. Unable to proceed.\n")) return try: import StringIO as io except ImportError: # StringIO is not available with python3 import io if self.idx < 0: return if not self.repos: return if NOGIT: git = None basedir = FreeCAD.ConfigGet("UserAppData") moddir = basedir + os.sep + "Mod" if not os.path.exists(moddir): os.makedirs(moddir) clonedir = moddir + os.sep + self.repos[self.idx][0] self.progressbar_show.emit(True) if os.path.exists(clonedir): self.info_label.emit("Updating module...") if git: repo = git.Git(clonedir) answer = repo.pull() else: answer = self.download(self.repos[self.idx][1],clonedir) else: self.info_label.emit("Checking module dependencies...") depsok,answer = self.checkDependencies(self.repos[self.idx][1]) if depsok: if git: self.info_label.emit("Cloning module...") repo = git.Repo.clone_from(self.repos[self.idx][1], clonedir, branch='master') else: self.info_label.emit("Downloading module...") self.download(self.repos[self.idx][1],clonedir) answer = translate("AddonsInstaller", "Workbench successfully installed. Please restart FreeCAD to apply the changes.") # symlink any macro contained in the module to the macros folder macrodir = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro").GetString("MacroPath") for f in os.listdir(clonedir): if f.lower().endswith(".fcmacro"): symlink(clonedir+os.sep+f,macrodir+os.sep+f) FreeCAD.ParamGet('User parameter:Plugins/'+self.repos[self.idx][0]).SetString("destination",clonedir) answer += translate("AddonsInstaller", "A macro has been installed and is available the Macros menu") + ": <b>" answer += f + "</b>" self.info_label.emit(answer) self.progressbar_show.emit(False) self.stop = True
def run(self): if NOGIT: self.stop = True return try: import git except: self.stop = True return self.progressbar_show.emit(True) basedir = FreeCAD.ConfigGet("UserAppData") moddir = basedir + os.sep + "Mod" self.info_label.emit( translate("AddonsInstaller", "Checking for new versions...")) upds = 0 gitpython_warning = False for repo in self.repos: if repo[2] == 1: #installed self.info_label.emit( translate("AddonsInstaller", "Checking repo") + " " + repo[0] + "...") clonedir = moddir + os.sep + repo[0] if os.path.exists(clonedir): if not os.path.exists(clonedir + os.sep + '.git'): # Repair addon installed with raw download bare_repo = git.Repo.clone_from(repo[1], clonedir + os.sep + '.git', bare=True) try: with bare_repo.config_writer() as cw: cw.set('core', 'bare', False) except AttributeError: if not gitpython_warning: FreeCAD.Console.PrintWarning( translate( "AddonsInstaller", "Outdated GitPython detected, consider upgrading with pip.\n" )) gitpython_warning = True cw = bare_repo.config_writer() cw.set('core', 'bare', False) del cw repo = git.Repo(clonedir) repo.head.reset('--hard') gitrepo = git.Git(clonedir) gitrepo.fetch() if "git pull" in gitrepo.status(): self.mark.emit(repo[0]) upds += 1 self.progressbar_show.emit(False) if upds: self.info_label.emit( str(upds) + " " + translate("AddonsInstaller", "update(s) available")) else: self.info_label.emit( translate("AddonsInstaller", "Everything is up to date")) self.stop = True
def collect_python_modules(femsubdir=None): if not femsubdir: pydir = join(FreeCAD.ConfigGet("AppHomePath"), 'Mod', 'Fem') else: pydir = join(FreeCAD.ConfigGet("AppHomePath"), 'Mod', 'Fem', femsubdir) collected_modules = [] fcc_print(pydir) for pyfile in sorted(os.listdir(pydir)): if pyfile.endswith(".py") and not pyfile.startswith('Init'): if not femsubdir: collected_modules.append( os.path.splitext(os.path.basename(pyfile))[0]) else: collected_modules.append( femsubdir.replace('/', '.') + '.' + os.path.splitext(os.path.basename(pyfile))[0]) return collected_modules
def chooseTemplateFileClicked(self): """This function is executed when Choose Template button is clicked in ui to execute QFileDialog to select template file.""" path = FreeCAD.ConfigGet("UserAppData") template_file, _filter = QtWidgets.QFileDialog.getOpenFileName( None, "Choose template for Drawing", path, "*.svg") if template_file: self.drawing_widget.template_file.setText(str(template_file))
def GetResources(self): IconPath = FreeCAD.ConfigGet( "AppHomePath") + "Mod/PartDesign/WizardShaft/WizardShaft.svg" MenuText = QtCore.QT_TRANSLATE_NOOP("WizardShaft", "Shaft design wizard...") ToolTip = QtCore.QT_TRANSLATE_NOOP("WizardShaft", "Start the shaft design wizard") return {'Pixmap': IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}
def getModulePath(): """returns the current Cfd module path.""" import os user_mod_path = os.path.join(FreeCAD.ConfigGet("UserAppData"), "Mod/Cfd") dev_mod_path = os.path.join(FreeCAD.ConfigGet("UserAppData"), "Mod/Cfd_dev") app_mod_path = os.path.join(FreeCAD.ConfigGet("AppHomePath"), "Mod/Cfd") if os.path.exists( user_mod_path ): # user's app data folder (the second overrides the first). return user_mod_path elif os.path.exists( dev_mod_path ): # dev module and module installed from addonManager may coexist return dev_mod_path else: return app_mod_path
def get_macro_dir(): """Return the directory where macros are located""" default_macro_dir = os.path.join(FreeCAD.ConfigGet('UserAppData'), 'Macro') path = FreeCAD.ParamGet('User parameter:BaseApp/Preferences/Macro').GetString('MacroPath', default_macro_dir) # For Py2 path is a utf-8 encoded unicode which we must decode again if sys.version_info.major < 3: path = path.decode("utf-8") return path
def __init__(self): rel_path = "Mod/Civil/images/civil-engineering.png" pref_visual_ui_rel_path = "Mod/Civil/ui/preferences-punch_visual.ui" self.pref_visual_ui_abs_path = FreeCAD.ConfigGet( "AppHomePath") + pref_visual_ui_rel_path import os if not os.path.exists(self.pref_visual_ui_abs_path): self.pref_visual_ui_abs_path = FreeCAD.ConfigGet( "UserAppData") + pref_visual_ui_rel_path icon_path = FreeCAD.ConfigGet("AppHomePath") + rel_path if not os.path.exists(icon_path): icon_path = FreeCAD.ConfigGet("UserAppData") + rel_path self.__class__.Icon = icon_path self.__class__.MenuText = "Civil" self.__class__.ToolTip = "Civil Workbench"
def choose_template_clicked(self): """This function is executed when Choose button clicked in ui to execute QFileDialog to select svg template file.""" path = FreeCAD.ConfigGet("UserAppData") template_file, Filter = QtWidgets.QFileDialog.getOpenFileName( None, "Choose template for Bill of Material", path, "*.svg") if template_file: self.form.templateFile.setText(str(template_file))
def create_mat_template_card(write_group_section=True): template_card = join(get_source_path(), 'src/Mod/Material/StandardMaterial/TEMPLATE.FCMat') if not os.path.isfile(template_card): FreeCAD.Console.PrintError( 'file not found: {}'.format(template_card) ) return rev = "{}.{}.{}".format( FreeCAD.ConfigGet("BuildVersionMajor"), FreeCAD.ConfigGet("BuildVersionMinor"), FreeCAD.ConfigGet("BuildRevision") ) template_data = get_material_template() f = open(template_card, "w") f.write('; TEMPLATE\n') f.write('; (c) 2013-2015 Juergen Riegel (CC-BY 3.0)\n') f.write('; information about the content of such cards can be found on the wiki:\n') f.write('; https://www.freecadweb.org/wiki/Material\n') f.write(': this template card was created by FreeCAD ' + rev + '\n\n') f.write('; localized Name, Description and KindOfMaterial uses 2 letter codes\n') f.write('; defined in ISO-639-1, see https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes\n') f.write('; find unit information in src/App/FreeCADInit.py') # write sections # write standard FCMat section if write group section parameter is set to False if write_group_section is False: f.write("\n[FCMat]\n") for group in template_data: gg = list(group.keys())[0] # group dict has only one key # do not write groups Meta and UserDefined if (gg != 'Meta') and (gg != 'UserDefined'): # only write group section if write group section parameter is set to True if write_group_section is True: f.write("\n\n[" + gg + "]") for prop_name in group[gg]: f.write('\n') description = group[gg][prop_name]['Description'] if not description.strip(): f.write('; Description to be updated\n') else: f.write('; ' + description + '\n') url = group[gg][prop_name]['URL'] if url.strip(): f.write('; ' + url + '\n') f.write(prop_name + ' =\n') f.close
def choose_svg_output_file_clicked(self): """This function is executed when Choose button clicked in ui to execute QFileDialog to select svg output file.""" path = FreeCAD.ConfigGet("UserAppData") output_file, file_filter = QtWidgets.QFileDialog.getSaveFileName( None, "Choose output file for Bar Bending Schedule", path, "*.svg") if output_file: self.form.svgOutputFile.setText( str(Path(output_file).with_suffix(".svg")))
def choose_svg_output_file_clicked(self): """This function is executed when Choose button clicked in ui to execute QFileDialog to select svg output file.""" path = FreeCAD.ConfigGet("UserAppData") output_file, Filter = QtWidgets.QFileDialog.getSaveFileName( None, "Choose output file for Rebar Shape Cut List", path, "*.svg") if output_file: self.form.svgOutputFile.setText( os.path.splitext(str(output_file))[0] + ".svg")
def run(mx, my, dx, dy): ys = my - dy yn = my + dy xw = mx - dx xe = mx + dx dats = [] say(xw, ys, xe, yn) for ix in range(int(math.floor(xw)), int(math.floor(xe)) + 1): for iy in range(int(math.floor(ys)), int(math.floor(yn)) + 1): dat = "Lat" + str(iy) + "Lon" + str(ix) + "Lat" + str( iy + 1) + "Lon" + str(ix + 1) say(dat) dats.append(dat) directory = FreeCAD.ConfigGet("UserAppData") + "geodat_SRTM/" if not os.path.isdir(directory): os.makedirs(directory) for dat in dats: getdata(directory, dat) fn = directory + "/" + dat + ".osm" pts = runfile(fn, xw, xe, ys, yn, mx, my) # Get or create "Point_Groups". try: PointGroups = FreeCAD.ActiveDocument.Point_Groups except Exception: PointGroups = FreeCAD.ActiveDocument.addObject( "App::DocumentObjectGroup", 'Point_Groups') PointGroups.Label = "Point Groups" # Get or create "Points". try: FreeCAD.ActiveDocument.Points except Exception: Points = FreeCAD.ActiveDocument.addObject('Points::Feature', "Points") PointGroups.addObject(Points) PointGroup = FreeCAD.ActiveDocument.addObject('Points::Feature', "Point_Group") PointGroup.Label = dat FreeCAD.ActiveDocument.Point_Groups.addObject(PointGroup) PointObject = PointGroup.Points.copy() PointObject.addPoints(pts) PointGroup.Points = PointObject FreeCAD.ActiveDocument.recompute() FreeCADGui.SendMsgToActiveView("ViewFit") return pts
def __init__(self, obj,icon=None): obj.Proxy = self self.Object = obj.Object self.ViewObject = obj self.icon=icon if icon==None: icon= 'freecad-nurbs/icons/BB.svg' if icon.startswith('/'): ic= self.icon else: ic= FreeCAD.ConfigGet("UserAppData") +'/Mod/' + icon obj.addProperty("App::PropertyString",'icon').icon=ic
def createDirectory(self): """ Create needed folder to write data and scripts. @return True if error happens. """ self.path = FreeCAD.ConfigGet("UserAppData") + "ShipOutput/" if not os.path.exists(self.path): os.makedirs(self.path) if not os.path.exists(self.path): msg = Translator.translate("Can't create '" + self.path + "' folder.\n") FreeCAD.Console.PrintError(msg) return False
def getSchema(): "retrieves the express schema" p = None p = os.path.join(FreeCAD.ConfigGet("UserAppData"), SCHEMA.split('/')[-1]) if os.path.exists(p): return p import ArchCommands p = ArchCommands.download(SCHEMA) if p: return p return None
def saveSketch(w=None): '''save Gui.Selection sketch into a file inside the sketch lib directory''' sel=Gui.Selection.getSelection()[0] fn=FreeCAD.ConfigGet("UserAppData") +'sketchlib/'+sel.Name+"_"+str(int(round(time.time())))+"_sk.fcstd" nd=App.newDocument("XYZ") App.ActiveDocument=nd copySketch(sel,"Sketch") print (sel.Label+" - speichere als " + fn) App.ActiveDocument.saveAs(fn) App.closeDocument("XYZ")
def drawUI(self): # Our main window will be a QDialog self.setWindowTitle('Help for FreeCAD and Assembly4') self.setWindowIcon( QtGui.QIcon(os.path.join(Asm4.iconPath, 'FreeCad.svg'))) self.setMinimumSize(600, 550) self.resize(600, 500) self.setModal(False) # make this dialog stay above the others, always visible self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) # Version info versionPath = os.path.join(Asm4.wbPath, 'VERSION') versionFile = open(versionPath, "r") Asm4version = versionFile.readlines()[1] FCmajor = App.ConfigGet('ExeVersion') FCminor = App.ConfigGet('BuildRevision') FCversion = FCmajor + '-' + FCminor self.versionFC = QtGui.QLabel(self) self.versionFC.setText("FreeCAD version : " + FCversion) self.versionFC.move(10, 20) self.versionAsm4 = QtGui.QLabel(self) self.versionAsm4.setText("Assembly4 version : " + Asm4version) self.versionAsm4.move(10, 50) # Help text self.helpSource = QtGui.QTextBrowser(self) self.helpSource.move(10, 90) self.helpSource.setMinimumSize(580, 400) self.helpSource.setSearchPaths( [os.path.join(Asm4.wbPath, 'Resources')]) self.helpSource.setSource('Asm4_Help.html') # OK button self.OKButton = QtGui.QPushButton('OK', self) self.OKButton.setAutoDefault(True) self.OKButton.move(510, 510) self.OKButton.setDefault(True) # Actions self.OKButton.clicked.connect(self.onOK)
def fillMaterialCombo(self): import glob,os matmap = self.obj.Material dirname = FreeCAD.ConfigGet("AppHomePath")+"data/Mod/Material/StandardMaterial" self.pathList = glob.glob(dirname + '/*.FCMat') self.formUi.comboBox_MaterialsInDir.clear() if(matmap.has_key('General_name')): self.formUi.comboBox_MaterialsInDir.addItem(matmap['General_name']) else: self.formUi.comboBox_MaterialsInDir.addItem('-> choose Material') for i in self.pathList: self.formUi.comboBox_MaterialsInDir.addItem(os.path.basename(i) )
def __init__(self, title_widget, objectname): QtGui.QDockWidget.__init__(self) self.title_widget = title_widget self.setWindowTitle(objectname) self.setObjectName(objectname) self.setTitleBarWidget(None) self.setMinimumSize(200, 185) self.centralWidget = QtGui.QWidget(self) self.setWidget(self.centralWidget) layout = QtGui.QVBoxLayout() self.layout = layout self.centralWidget.setLayout(layout) self.scroll = QtGui.QScrollArea() self.liste = QtGui.QWidget() self.lilayout = QtGui.QVBoxLayout() self.liste.setLayout(self.lilayout) mygroupbox = QtGui.QGroupBox() mygroupbox.setStyleSheet( "QWidget { background-color: lightblue;margin:0px;padding:0px;}" "QPushButton { margin-right:0px;margin-left:0px;margin:0 px;padding:0px;;" "background-color: lightblue;text-align:left;" "padding:6px;padding-left:4px;color:brown; }") self.mygroupbox = mygroupbox myform = QtGui.QFormLayout() self.myform = myform self.myform.setSpacing(0) mygroupbox.setLayout(myform) scroll = QtGui.QScrollArea() scroll.setWidget(mygroupbox) scroll.setWidgetResizable(True) self.lilayout.addWidget(scroll) # optionaler Top button self.pushButton01 = QtGui.QPushButton( QtGui.QIcon( FreeCAD.ConfigGet('UserAppData') + '/Mod/mylib/icons/mars.png'), "Mars") # self.pushButton01.clicked.connect(self.start) # layout.addWidget(self.liste) # layout.addWidget(self.pushButton01) self.createToplevelButtons()
def get_source_path(): # in the file 'Makefile' in build directory the cmake variable CMAKE_SOURCE_DIR has the dir source_dir = '' make_file = join(FreeCAD.ConfigGet('AppHomePath'), 'Makefile') f = open(make_file, 'r') lines = f.readlines() f.close() for line in lines: if line.startswith('CMAKE_SOURCE_DIR'): source_dir = line.lstrip('CMAKE_SOURCE_DIR = ') source_dir = source_dir.rstrip() # get rid on new line and white spaces etc. break # print(source_dir) return source_dir
def createDirectory(self): """ Create needed folder to write data and scripts. @return True if error happens. """ self.path = FreeCAD.ConfigGet("UserAppData") + "ShipOutput/" if not os.path.exists(self.path): os.makedirs(self.path) if not os.path.exists(self.path): msg = QtGui.QApplication.translate( "ship_console", "Failure creating the folder".format(self.path), None, QtGui.QApplication.UnicodeUTF8) FreeCAD.Console.PrintError(msg + ":\n\t'" + self.path + "'\n") return False
def pip_install(package): if not report_view_param(): report_view_param(True) QTimer.singleShot(2000, lambda:report_view_param(False)) postfix = '.exe' if platform.system() == 'Windows' else '' bin_path = os.path.dirname(sys.executable) exe_path = os.path.join(bin_path, 'FreeCADCmd' + postfix) if os.path.exists(exe_path): stdin = ''' import sys from pip._internal.cli.main import main if __name__ == '__main__': sys.argv = ['pip', 'install', '%s', '--user'] sys.exit(main()) ''' % package args = [exe_path] else: stdin = None exe_path = os.path.join(bin_path, 'python' + postfix) if not os.path.exists(exe_path): bin_path = FreeCAD.ConfigGet('BinPath') exe_path = os.path.join(bin_path, 'python' + postfix) if not os.path.exists(exe_path): exe_path = 'python3' + postfix args = [exe_path, '-m', 'pip', 'install', package, '--user'] print_msg(' '.join(args) + '\n') try: if stdin: proc = subp.Popen(args, stdin=subp.PIPE, stdout=subp.PIPE, stderr=subp.PIPE) out, err = proc.communicate(input=stdin.encode('utf8')) else: proc = subp.Popen(args, stdout=subp.PIPE, stderr=subp.PIPE) out, err = proc.communicate() print_msg(out.decode('utf8') + '\n') if err: print_func = print_err for msg in err.decode("utf8").split('\r\n'): m = msg.lower() if 'warning' in m: print_func = print_warn elif any(key in m for key in ('exception', 'error')): print_func = print_err print_func(msg + '\n') except Exception as e: msg = str(e) if not msg: msg = 'Failed' print_err(msg + '\n')
def get_osmdata(b, l, bk): dn = os.path.join(FreeCAD.ConfigGet("UserAppData"), "geodat_osm") if not os.path.isdir(dn): os.makedirs(dn) fn = os.path.join(dn, "{}-{}-{}".format(b, l, bk)) say("Local osm data file:") say("{}".format(fn)) # TODO: do much less in try/except # use os for file existence etc. tree = None try: say("Try to read data from a former existing osm data file ... ") f = open(fn, "r") content = f.read() # try to read it False if content else True # get pylint and LGTM silent # really read fn before skipping new internet upload # because fn might be empty or does have wrong encoding tree = my_xmlparser.getData(fn) except Exception: say( "No former existing osm data file, " "connecting to openstreetmap.org ..." ) lk = bk b1 = b - bk / 1113 * 10 l1 = l - lk / 713 * 10 b2 = b + bk / 1113 * 10 l2 = l + lk / 713 * 10 koord_str = "{},{},{},{}".format(l1, b1, l2, b2) source = "http://api.openstreetmap.org/api/0.6/map?bbox=" + koord_str say(source) response = urllib.request.urlopen(source) # the file we write into needs uft8 encoding f = open(fn, "w", encoding="utf-8") # decode makes a string out of the bytesstring f.write(response.read().decode("utf8")) f.close() # writing the file is only for later usage # thus may be first parse the data and afterwards write it ... ? tree = my_xmlparser.getData(fn) if tree is not None: return tree else: return None
def __init__(self): print("Fetching GitHub Workbenches") # For storing instances of Plugin() class. self.instances = {} self.gitPlugins = [] self.plugin_type = "Workbench" # Specify the directory where the Workbenches are to be installed. self.workbench_path = os.path.join(FreeCAD.ConfigGet("UserAppData"), "Mod") # If any of the paths do not exist, then create one. if not os.path.exists(self.workbench_path): os.makedirs(self.workbench_path)
def import_emir( filename, textdat=None, directText=False, ): #lines=data.splitlines() if filename.startswith('UserAppData'): filename = filename.replace('UserAppData', FreeCAD.ConfigGet("UserAppData")) f = open(filename, 'rb') lines = f.readlines() parsedata(lines)
def fillMaterialCombo(self): "fills the combo with the existing FCMat cards" # look for cards in both resources dir and user folder. # User cards with same name will override system cards paths = [FreeCAD.getResourceDir() + os.sep + "Mod" + os.sep + "Material" + os.sep + "StandardMaterial"] paths.append(FreeCAD.ConfigGet("UserAppData")) self.cards = {} for p in paths: for f in os.listdir(p): b,e = os.path.splitext(f) if e.upper() == ".FCMAT": self.cards[b] = p + os.sep + f if self.cards: for k in sorted(self.cards.keys()): self.form.comboBox_MaterialsInDir.addItem(k)
def remove(self): if self.tabWidget.currentIndex() == 0: idx = self.listWorkbenches.currentRow() basedir = FreeCAD.ConfigGet("UserAppData") moddir = basedir + os.sep + "Mod" clonedir = basedir + os.sep + "Mod" + os.sep + self.repos[idx][0] if os.path.exists(clonedir): shutil.rmtree(clonedir) self.labelDescription.setText( QtGui.QApplication.translate( "AddonsInstaller", "Addon successfully removed. Please restart FreeCAD", None, QtGui.QApplication.UnicodeUTF8)) else: self.labelDescription.setText( QtGui.QApplication.translate( "AddonsInstaller", "Unable to remove this addon", None, QtGui.QApplication.UnicodeUTF8)) elif self.tabWidget.currentIndex() == 1: macropath = FreeCAD.ParamGet( 'User parameter:BaseApp/Preferences/Macro').GetString( "MacroPath", os.path.join(FreeCAD.ConfigGet("UserAppData"), "Macro")) macro = self.macros[self.listMacros.currentRow()] if macro[1] != 1: return macroname = "Macro_" + macro[0] + ".FCMacro" macroname = macroname.replace(" ", "_") macrofilename = os.path.join(macropath, macroname) if os.path.exists(macrofilename): os.remove(macrofilename) self.labelDescription.setText( QtGui.QApplication.translate( "AddonsInstaller", "Macro successfully removed.", None, QtGui.QApplication.UnicodeUTF8)) self.update_status()