From ac2263bca3fdbb66c1e23051368a4060f9c1582f Mon Sep 17 00:00:00 2001 From: kbwbe Date: Thu, 14 Feb 2019 22:56:54 +0100 Subject: [PATCH 01/10] fix issue #195 (naming of centerOfMass constraint) --- a2p_constraints.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/a2p_constraints.py b/a2p_constraints.py index 34b1f67e..4e73efcb 100644 --- a/a2p_constraints.py +++ b/a2p_constraints.py @@ -638,7 +638,7 @@ class CenterOfMassConstraint(BasicConstraint): def __init__(self,selection): BasicConstraint.__init__(self, selection) self.typeInfo = 'CenterOfMass' - self.constraintBaseName = 'CenterOfMass' + self.constraintBaseName = 'centerOfMass' self.iconPath = path_a2p + '/icons/a2p_CenterOfMassConstraint.svg' self.create(selection) @@ -669,7 +669,7 @@ def calcInitialValues(self): def getToolTip(): return \ ''' -Creates a Center of Mass constraint. +Creates a centerOfMass constraint. (Join centerOfMass of \'face1\' or \'closed edge1\' to centerOfMass of \'face2\' or \'closed edge2\') From 06965d524a04da9d6e9a3290ef2bc68192f9ad5c Mon Sep 17 00:00:00 2001 From: donovaly Date: Fri, 15 Feb 2019 02:16:02 +0100 Subject: [PATCH 02/10] update wordings - the English name is "parts list" - refer to the actual spreadsheet name - avoid camel case names - shorten the tooltip text a bit --- a2p_bom.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/a2p_bom.py b/a2p_bom.py index 0625019c..016738f0 100644 --- a/a2p_bom.py +++ b/a2p_bom.py @@ -129,20 +129,18 @@ def createPartList( toolTip = \ ''' Create a spreadsheet with a -partlist of this file. +parts list of this file. This function will read out -the partInfo spreadSheet of +the #PARTINFO# spreadsheet of all involved parts of the assembly and create a new -spreadSheet, containing the -partlist. (see tree view) +spreadsheet containing the +parts list. -After hitting this button -a dialog will pop up: - -Question: -- iterate recursively over +This button will open a dialog +with the Question: +- Iterate recursively over all subassenblies? Answer Yes: @@ -254,7 +252,7 @@ def Activated(self): def GetResources(self): return { 'Pixmap' : ':/icons/a2p_PartsList.svg', - 'MenuText': 'Create a spreadsheet with a partlist of this file', + 'MenuText': 'Create a spreadsheet with a parts list of this file', 'ToolTip': toolTip } From 95bc666459fd8daaf24ba1e45d09e5b7d3df004d Mon Sep 17 00:00:00 2001 From: donovaly Date: Fri, 15 Feb 2019 02:20:51 +0100 Subject: [PATCH 03/10] update wording - fix typos - avoid CamelCase names --- a2p_partinformation.py | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/a2p_partinformation.py b/a2p_partinformation.py index e5dd8e6d..7bb11eca 100644 --- a/a2p_partinformation.py +++ b/a2p_partinformation.py @@ -37,15 +37,15 @@ #------------------------------------------------------------------------------ toolTip = \ ''' -Create a spreadSheet for ordering or +Create a spreadsheet for ordering or logistics information. -The created spreadSheet can be found -within the treeview. +The created spreadsheet can be found +within the tree view. Please fill in your information. -This spreadSheet will be read out -by the partlist function of A2plus. +This spreadsheet will be read out +by the parts list function of A2plus. ''' class a2p_CreatePartInformationSheet_Command: @@ -55,7 +55,7 @@ def Activated(self): if doc == None: QtGui.QMessageBox.information( QtGui.QApplication.activeWindow(), "No active document found!", - "You have to open an fcstd file first." + "You have to open a FCstd file first." ) return @@ -82,31 +82,9 @@ def Activated(self): def GetResources(self): return { 'Pixmap' : ':/icons/a2p_PartsInfo.svg', - 'MenuText': 'Create a spreadSheet for ordering or logistics information', + 'MenuText': 'Create a spreadsheet for ordering or logistics information', 'ToolTip': toolTip } FreeCADGui.addCommand('a2p_CreatePartInformationSheet_Command', a2p_CreatePartInformationSheet_Command()) #------------------------------------------------------------------------------ - - - - - - - - - - - - - - - - - - - - - - From c005648ad1733afa55c5d62f260c5fcde6b6f181 Mon Sep 17 00:00:00 2001 From: donovaly Date: Fri, 15 Feb 2019 02:22:10 +0100 Subject: [PATCH 04/10] fix a typo --- a2p_partinformation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/a2p_partinformation.py b/a2p_partinformation.py index 7bb11eca..caaed298 100644 --- a/a2p_partinformation.py +++ b/a2p_partinformation.py @@ -55,7 +55,7 @@ def Activated(self): if doc == None: QtGui.QMessageBox.information( QtGui.QApplication.activeWindow(), "No active document found!", - "You have to open a FCstd file first." + "You have to open a FCStd file first." ) return From c5f1d32d8168773e290bf684f3f5fdf504632f1b Mon Sep 17 00:00:00 2001 From: donovaly Date: Fri, 15 Feb 2019 02:27:03 +0100 Subject: [PATCH 05/10] more improvements - more consistent naming - whitespace --- a2p_bom.py | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/a2p_bom.py b/a2p_bom.py index 016738f0..f0fee5c6 100644 --- a/a2p_bom.py +++ b/a2p_bom.py @@ -169,18 +169,18 @@ def Activated(self): if doc == None: QtGui.QMessageBox.information( QtGui.QApplication.activeWindow(), u"No active document found!", - u"You have to open an fcstd file first." + u"You have to open a FCStd file first." ) return completeFilePath = doc.FileName p,f = os.path.split(completeFilePath) flags = QtGui.QMessageBox.StandardButton.Yes | QtGui.QMessageBox.StandardButton.No - msg = u"Please save before generating a partlist!\nSave now ?" + msg = u"Please save before generating a parts list!\nSave now ?" response = QtGui.QMessageBox.information(QtGui.QApplication.activeWindow(), u"Save document?", msg, flags ) if response == QtGui.QMessageBox.No: QtGui.QMessageBox.information( QtGui.QApplication.activeWindow(), - u"Partlist generation aborted!", + u"Parts list generation aborted!", u"You have to save the assembly file first." ) return @@ -188,8 +188,8 @@ def Activated(self): doc.save() flags = QtGui.QMessageBox.StandardButton.Yes | QtGui.QMessageBox.StandardButton.No - msg = u"Partslist/BOM: Do recursively over all included subassemblies ?" - response = QtGui.QMessageBox.information(QtGui.QApplication.activeWindow(), u"PARTSLIST/BOM mode?", msg, flags ) + msg = u"Do you want to iterate recursively over all included subassemblies?" + response = QtGui.QMessageBox.information(QtGui.QApplication.activeWindow(), u"PARTSLIST", msg, flags ) if response == QtGui.QMessageBox.Yes: subAssyRecursion = True else: @@ -246,7 +246,7 @@ def Activated(self): # recompute to finish.. doc.recompute() - print("partslist/BOM spreadsheet has been created!") + print("#PARTsLIST' spreadsheet has been created") def GetResources(self): @@ -258,20 +258,3 @@ def GetResources(self): FreeCADGui.addCommand('a2p_CreatePartlist', a2p_CreatePartlist()) #------------------------------------------------------------------------------ - - - - - - - - - - - - - - - - - From d33a82f886da4d23b5d1f3790dfbd834b1a06cd7 Mon Sep 17 00:00:00 2001 From: donovaly Date: Fri, 15 Feb 2019 02:42:40 +0100 Subject: [PATCH 06/10] fix for issue #202 Fixes issue #202 --- GuiA2p/Resources/ui/a2p_prefs.ui | 43 +++++++++++++++----------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/GuiA2p/Resources/ui/a2p_prefs.ui b/GuiA2p/Resources/ui/a2p_prefs.ui index 3e3196a2..ebdf1353 100644 --- a/GuiA2p/Resources/ui/a2p_prefs.ui +++ b/GuiA2p/Resources/ui/a2p_prefs.ui @@ -11,7 +11,7 @@ - A2plus Settings + A2plus settings @@ -38,7 +38,7 @@ - show constraints on toolbar + Show constraints on toolbar true @@ -77,7 +77,7 @@ - behavior when updating imported parts + Behavior when updating imported parts @@ -92,7 +92,7 @@ - recalculate imported parts before updating them (experimental) + Recalculate imported parts before updating them (experimental) recalculateImportedParts @@ -105,7 +105,7 @@ - enable recursive update of imported parts (process all subassemblies) + Enable recursive update of imported parts (process all subassemblies) enableRecursiveUpdate @@ -118,7 +118,7 @@ - use experimental topological naming + Use experimental topological naming useTopoNaming @@ -131,7 +131,7 @@ - inherit per face transparency from parts and sub-assemblies (experimental) + Inherit per face transparency from parts and sub-assemblies (experimental) usePerFaceTransparency @@ -144,7 +144,7 @@ - do not import invisible shapes (use with caution, can break assemblies) + Do not import invisible shapes (use with caution, can break assemblies) doNotImportInvisibleShapes @@ -157,7 +157,7 @@ - use solid union for importing parts and subassemblies (experimental) + Use solid union for importing parts and subassemblies (experimental) useSolidUnion @@ -195,7 +195,7 @@ - default solving method + Default solving method @@ -210,7 +210,7 @@ - use solving of partial systems (recommended for static assemblies) + Use solving of partial systems (recommended for static assemblies) true @@ -226,7 +226,7 @@ - use "magnetic" solver, solving all parts at once (for dynamical assemblies) + Use "magnetic" solver, solving all parts at once (for dynamical assemblies) useMagneticSolver @@ -239,7 +239,7 @@ - force FixedPosition to all Imports + Force fixed position to all imports forceFixedPosition @@ -277,7 +277,7 @@ - storage of files + Storage of files @@ -292,7 +292,7 @@ - use relative paths for imported parts + Use relative paths for imported parts true @@ -308,7 +308,7 @@ - use absolute paths for imported parts + Use absolute paths for imported parts useAbsolutePathes @@ -321,7 +321,7 @@ - use project-folder, all files are below this + Use project-folder, all files are below this useProjectFolder @@ -332,7 +332,7 @@ - + 250 @@ -345,9 +345,6 @@ 16777215 - - Gui::FileChooser::Directory - @@ -376,7 +373,7 @@ - default solver behavior + Default solver behavior @@ -391,7 +388,7 @@ - solve automatically if a constraints property is changed + Solve automatically if a constraints property is changed true From 0589c4f1f8396e7a25653aa3798f2534e90fd430 Mon Sep 17 00:00:00 2001 From: donovaly Date: Fri, 15 Feb 2019 02:50:57 +0100 Subject: [PATCH 07/10] fix issue #199 completely - fix #199 completely - improve and simplify wording - whitespace --- a2p_constraintDialog.py | 38 +++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/a2p_constraintDialog.py b/a2p_constraintDialog.py index ce4daf69..f012d7ba 100644 --- a/a2p_constraintDialog.py +++ b/a2p_constraintDialog.py @@ -251,7 +251,7 @@ def solve(self): QtGui.QMessageBox.information( QtGui.QApplication.activeWindow(), "Constraint does not exist anymore", - "Constraint has been already deleted" + "Constraint has already been deleted" ) a2plib.setConstraintEditorRef(None) self.Deleted.emit() @@ -326,10 +326,10 @@ def delete(self): return flags = QtGui.QMessageBox.StandardButton.Yes | QtGui.QMessageBox.StandardButton.No - response = QtGui.QMessageBox.critical( + response = QtGui.QMessageBox.information( QtGui.QApplication.activeWindow(), "Confirmation required", - "Really delete this constraint ?", + "Really delete this constraint?", flags ) if response == QtGui.QMessageBox.Yes: @@ -352,7 +352,7 @@ def accept(self): QtGui.QMessageBox.information( QtGui.QApplication.activeWindow(), "Constraint does not exist anymore", - "Constraint has been already deleted" + "Constraint has already been deleted" ) a2plib.setConstraintEditorRef(None) self.Deleted.emit() @@ -367,7 +367,7 @@ def cancelOperation(self): QtGui.QMessageBox.information( QtGui.QApplication.activeWindow(), "Constraint does not exist anymore", - "Constraint has been already deleted" + "Constraint has already been deleted" ) a2plib.setConstraintEditorRef(None) self.Deleted.emit() @@ -375,10 +375,10 @@ def cancelOperation(self): if self.mode == 'createConstraint': flags = QtGui.QMessageBox.StandardButton.Yes | QtGui.QMessageBox.StandardButton.No - response = QtGui.QMessageBox.critical( + response = QtGui.QMessageBox.information( QtGui.QApplication.activeWindow(), "Confirmation required", - "Exit and delete new constraint ?", + "Exit and delete new constraint?", flags ) if response == QtGui.QMessageBox.Yes: @@ -389,7 +389,7 @@ def cancelOperation(self): else: if self.isWindowModified() or self.winModified: flags = QtGui.QMessageBox.StandardButton.Yes | QtGui.QMessageBox.StandardButton.No - response = QtGui.QMessageBox.critical( + response = QtGui.QMessageBox.information( QtGui.QApplication.activeWindow(), "Information", "Values changed! Accept Constraint?", @@ -895,12 +895,8 @@ def closeEvent(self,event): #============================================================================== toolTipText = \ ''' -Open a dialog to +Opens a dialog to define constraints - -Find all constraints -within the opening -dialog ! ''' class a2p_ConstraintDialogCommand: @@ -974,19 +970,3 @@ def GetResources(self): FreeCADGui.addCommand('a2p_EditConstraintCommand', a2p_EditConstraintCommand()) #============================================================================== - - - - - - - - - - - - - - - - From 3d643976a7cb76d926de4adfdfde5fada7f2e589 Mon Sep 17 00:00:00 2001 From: kbwbe Date: Fri, 15 Feb 2019 08:40:11 +0100 Subject: [PATCH 08/10] prefsPage: set mode of filechooser to directory --- GuiA2p/Resources/ui/a2p_prefs.ui | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/GuiA2p/Resources/ui/a2p_prefs.ui b/GuiA2p/Resources/ui/a2p_prefs.ui index ebdf1353..089ea1e8 100644 --- a/GuiA2p/Resources/ui/a2p_prefs.ui +++ b/GuiA2p/Resources/ui/a2p_prefs.ui @@ -85,7 +85,7 @@ 20 30 621 - 181 + 200 @@ -332,7 +332,7 @@ - + 250 @@ -345,6 +345,9 @@ 16777215 + + Gui::FileChooser::Directory + From 356d10cff5c1ab5b2901957ec27eab66b1723d12 Mon Sep 17 00:00:00 2001 From: donovaly Date: Fri, 15 Feb 2019 11:38:04 +0100 Subject: [PATCH 09/10] fix typo in a2p_bom.py - fix typo I introduced today --- a2p_bom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/a2p_bom.py b/a2p_bom.py index f0fee5c6..d3ab7871 100644 --- a/a2p_bom.py +++ b/a2p_bom.py @@ -246,7 +246,7 @@ def Activated(self): # recompute to finish.. doc.recompute() - print("#PARTsLIST' spreadsheet has been created") + print("#PARTSLIST# spreadsheet has been created") def GetResources(self): From f80636968a73c2af4a3e68e91ca36484143f5854 Mon Sep 17 00:00:00 2001 From: kbwbe Date: Fri, 15 Feb 2019 13:02:19 +0100 Subject: [PATCH 10/10] bugfix: partslist got struggled with step files --- InitGui.py | 2 +- a2p_bom.py | 1 + a2p_simpleXMLreader.py | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/InitGui.py b/InitGui.py index 544b4636..9d995c23 100644 --- a/InitGui.py +++ b/InitGui.py @@ -26,7 +26,7 @@ __title__ = 'A2plus assembly Workbench - InitGui file' __author__ = 'kbwbe' -A2P_VERSION = 'V0.3.7' +A2P_VERSION = 'V0.3.8' import sys PyVersion = sys.version_info[0] diff --git a/a2p_bom.py b/a2p_bom.py index d3ab7871..010ba471 100644 --- a/a2p_bom.py +++ b/a2p_bom.py @@ -60,6 +60,7 @@ def createPartList( parentAssemblyDir ) workingDir,basicFileName = os.path.split(fileNameInProject) + docReader1 = FCdocumentReader() docReader1.openDocument(fileNameInProject) diff --git a/a2p_simpleXMLreader.py b/a2p_simpleXMLreader.py index f74c8ba7..6ea2c057 100644 --- a/a2p_simpleXMLreader.py +++ b/a2p_simpleXMLreader.py @@ -203,10 +203,12 @@ class for extracting the XML-Documentdata from a fcstd-file given by def __init__(self): self.xmlLines = [] self.objects = [] + self.successfulOpened = False def clear(self): self.xmlLines = [] self.objects = [] + self.successfulOpened = False def openDocument(self,_fileName): fileName = _fileName @@ -215,14 +217,24 @@ def openDocument(self,_fileName): fileName = a2plib.to_str(fileName) self.clear() + # check whether file exists or not... if not os.path.exists( fileName ): print (u"fcDocumentReader: file {} does not exist!".format(fileName)) + successfulOpened = False + return + + # check for fcstd file + if not fileName.lower().endswith(a2plib.to_str('.fcstd')): + print (u"fcDocumentReader: file {} is no FCStd file!".format(fileName)) + successfulOpened = False return + # decompress the file f = zipfile.ZipFile(fileName,'r') xml = f.read('Document.xml') f.close() + self.successfulOpened = True # #self.xmlLines = xml.split("\r\n") #Windows self.xmlLines = xml.split(b'\r\n') #Windows @@ -253,6 +265,7 @@ def openDocument(self,_fileName): self.objects = tmp def getA2pObjects(self): + if not self.successfulOpened: return [] out = [] for ob in self.objects: if ob.propertyDict.get(b'a2p_Version',None) != None: @@ -261,6 +274,7 @@ def getA2pObjects(self): return out def getSpreadsheetObjects(self): + if not self.successfulOpened: return [] out = [] for ob in self.objects: if ob.propertyDict.get(b'cells',None) != None: @@ -268,6 +282,7 @@ def getSpreadsheetObjects(self): return out def getObjectByName(self,name): + if not self.successfulOpened: return None for ob in self.objects: if ob.name == name: return ob