From 4e105f9ee496d60abbbcacd40f6c05b0dcb20554 Mon Sep 17 00:00:00 2001 From: kbwbe Date: Sat, 8 Jun 2019 11:03:16 +0200 Subject: [PATCH 1/2] remove obsolete code --- a2p_convertPart.py | 2 +- a2p_importpart.py | 5 +- a2p_versionmanagement.py | 121 +-------------------------------------- 3 files changed, 3 insertions(+), 125 deletions(-) diff --git a/a2p_convertPart.py b/a2p_convertPart.py index 167d5064..9f9b3d8f 100644 --- a/a2p_convertPart.py +++ b/a2p_convertPart.py @@ -28,7 +28,7 @@ import a2plib from a2p_MuxAssembly import createTopoInfo from a2p_viewProviderProxies import * -from a2p_versionmanagement import SubAssemblyWalk, A2P_VERSION +from a2p_versionmanagement import A2P_VERSION import a2p_solversystem from a2plib import ( appVersionStr, diff --git a/a2p_importpart.py b/a2p_importpart.py index 9d2fcbf1..149110ab 100644 --- a/a2p_importpart.py +++ b/a2p_importpart.py @@ -32,10 +32,7 @@ muxAssemblyWithTopoNames ) from a2p_viewProviderProxies import * -from a2p_versionmanagement import ( - SubAssemblyWalk, - A2P_VERSION - ) +from a2p_versionmanagement import A2P_VERSION import a2p_solversystem from a2plib import ( appVersionStr, diff --git a/a2p_versionmanagement.py b/a2p_versionmanagement.py index 19d477dd..8123f186 100644 --- a/a2p_versionmanagement.py +++ b/a2p_versionmanagement.py @@ -1,6 +1,6 @@ #*************************************************************************** #* * -#* Copyright (c) 2018 kbwbe * +#* Copyright (c) 2018,2019 kbwbe * #* * #* This program is free software; you can redistribute it and/or modify * #* it under the terms of the GNU Lesser General Public License (LGPL) * @@ -20,124 +20,5 @@ #* * #*************************************************************************** -import FreeCAD, FreeCADGui, Part, Draft, math, MeshPart, Mesh, Drawing, time -import Spreadsheet, os -#from PyQt4 import QtGui,QtCore -from PySide import QtCore, QtGui -from FreeCAD import Base -from a2plib import * -App=FreeCAD -Gui=FreeCADGui - A2P_VERSION = 'V0.1' #to be aligned with InitGui A2P Version - -class SubAssemblyWalk(): - ''' - Class for walking through subassemblies, - creating missing properties, - checking for necessary update of importparts... - - start it with method executeWalk(self) - ''' - - def __init__(self,startFile): - self.startFile = startFile - self.docsToBeClosed = [] - - def checkForSubAssembly(self,subFileName): - filename = findSourceFileInProject(subFileName) # path within subfile will be ignored.. - if filename == None: - FreeCAD.Console.PrintMessage( - "SubassemblyCheck failed for {} ".format( subFileName ) - ) - return False - - doc_already_open = filename in [ d.FileName for d in FreeCAD.listDocuments().values() ] - if doc_already_open: - doc = [ d for d in FreeCAD.listDocuments().values() if d.FileName == filename][0] - else: - doc = FreeCAD.openDocument(filename) - - for obj in doc.Objects: - if hasattr(obj, 'sourceFile'): - if not doc_already_open: - FreeCAD.closeDocument(doc.Name) - return True - - if not doc_already_open: - FreeCAD.closeDocument(doc.Name) - return False - - def openSubAssembly(self,subFile): #recursive func!! This can consumpt the total memory of your computer - filename = findSourceFileInProject(subFile) # path within subfile will be ignored.. - if filename == None: - FreeCAD.Console.PrintMessage( "Missing file {} ignored".format(subFile) ) - return False - - doc_already_open = filename in [ d.FileName for d in FreeCAD.listDocuments().values() ] - if doc_already_open: - doc = [ d for d in FreeCAD.listDocuments().values() if d.FileName == filename][0] - else: - doc = FreeCAD.openDocument(filename) - - needUpdate = False - - for obj in doc.Objects: - if hasattr(obj, 'sourceFile'): - - # This Section: Add missing but necessary properties of this Version - if not hasattr( obj, 'a2p_Version'): - obj.addProperty("App::PropertyString", "a2p_Version","importPart").a2p_Version = 'V0.0' - obj.setEditorMode("a2p_Version",1) - needUpdate = True - - if not hasattr( obj, 'muxInfo'): - obj.addProperty("App::PropertyStringList", "muxInfo","importPart").muxInfo = [] - needUpdate = True - - if not hasattr(obj, 'subassemblyImport'): - obj.addProperty("App::PropertyBool","subassemblyImport","importPart").subassemblyImport = False - obj.setEditorMode("subassemblyImport",1) - obj.subassemblyImport = self.checkForSubAssembly(obj.sourceFile) - needUpdate = True - - if obj.subassemblyImport == True: - # This Section: Open subassemblies which this assembly depends on... - replacement = findSourceFileInProject(obj.sourceFile) # work in any case with files within projectFolder! - if replacement == None: - QtGui.QMessageBox.critical( QtGui.QApplication.activeWindow(), - "Source file not found", - "update of %s aborted!\nUnable to find %s" % ( - obj.Name, - obj.sourceFile - ) - ) - else: - if obj.sourceFile != replacement: - obj.sourceFile = replacement # update Filepath, perhaps location changed due to new projectFile! - result = self.openSubAssembly(obj.sourceFile) - if result == True: - needUpdate = True - - if obj.a2p_Version != A2P_VERSION: - needUpdate = True - - if os.path.getmtime( obj.sourceFile ) > obj.timeLastImport: - needUpdate = True - - if not needUpdate: - if doc not in self.docsToBeClosed: - self.docsToBeClosed.append(doc) - - return needUpdate - - - - - def executeWalk(self): - self.docsToBeClosed = [] - self.openSubAssembly(self.startFile) - for doc in self.docsToBeClosed: - if doc.FileName != self.startFile: - FreeCAD.closeDocument(doc.Name) From 82e9f7aa819a3385e4122838ca7bf281000f0fc8 Mon Sep 17 00:00:00 2001 From: kbwbe Date: Sat, 8 Jun 2019 11:07:40 +0200 Subject: [PATCH 2/2] aligned version --- InitGui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InitGui.py b/InitGui.py index 6952e09c..d882abc9 100644 --- a/InitGui.py +++ b/InitGui.py @@ -26,7 +26,7 @@ __title__ = 'A2plus assembly Workbench - InitGui file' __author__ = 'kbwbe' -A2P_VERSION = 'V0.4.23' +A2P_VERSION = 'V0.4.24'