diff --git a/InitGui.py b/InitGui.py index eedbf9b8..530bab73 100644 --- a/InitGui.py +++ b/InitGui.py @@ -26,7 +26,7 @@ __title__ = 'A2plus assembly Workbench - InitGui file' __author__ = 'kbwbe' -A2P_VERSION = 'V0.4.20' +A2P_VERSION = 'V0.4.21' diff --git a/a2p_MuxAssembly.py b/a2p_MuxAssembly.py index a13617a2..1b403fbb 100644 --- a/a2p_MuxAssembly.py +++ b/a2p_MuxAssembly.py @@ -147,24 +147,23 @@ def muxAssemblyWithTopoNames(doc, desiredShapeLabel=None): faces.extend(tempShape.Faces) - shell = Part.makeShell(faces) + if len(faces) == 1: + shell = Part.makeShell([faces]) + else: + shell = Part.makeShell(faces) try: - # solid = Part.Solid(shell) - # solid = Part.makeCompound (shape_list) if a2plib.getUseSolidUnion(): if len(shape_list) > 1: shape_base=shape_list[0] shapes=shape_list[1:] solid = shape_base.fuse(shapes) - else: #one drill ONLY - solid = shape_list[0] + else: + solid = Part.Solid(shape_list[0]) else: - numShellFaces = len(shell.Faces) solid = Part.Solid(shell) # This does not work if shell includes spherical faces. FC-Bug ?? - numSolidFaces = len(solid.Faces) - # Check, whether all faces where processed... - if numShellFaces != numSolidFaces: - solid = shell # Some faces are missing, take shell as result as workaround.. + # Fall back to shell if some faces are missing.. + if len(shell.Faces) != len(solid.Faces): + solid = shell except: # keeping a shell if solid is failing solid = shell @@ -268,29 +267,23 @@ def createOrUpdateSimpleAssemblyShape(doc): for obj in visibleImportObjects: faces = faces + obj.Shape.Faces shape_list.append(obj.Shape) - shell = Part.makeShell(faces) + if len(faces) == 1: + shell = Part.makeShell([faces]) + else: + shell = Part.makeShell(faces) try: - # solid = Part.Solid(shell) - # solid = Part.makeCompound (shape_list) if a2plib.getUseSolidUnion(): if len(shape_list) > 1: shape_base=shape_list[0] shapes=shape_list[1:] solid = shape_base.fuse(shapes) - else: #one shape only - numShellFaces = len(shell.Faces) - solid = Part.Solid(shell) # This does not work if shell includes spherical faces. FC-Bug ?? - numSolidFaces = len(solid.Faces) - # Check, whether all faces where processed... - if numShellFaces != numSolidFaces: - solid = shell # Some faces are missing, take shell as result as workaround.. + else: + solid = Part.Solid(shape_list[0]) else: - numShellFaces = len(shell.Faces) solid = Part.Solid(shell) # This does not work if shell includes spherical faces. FC-Bug ?? - numSolidFaces = len(solid.Faces) - # Check, whether all faces where processed... - if numShellFaces != numSolidFaces: - solid = shell # Some faces are missing, take shell as result as workaround.. + # Fall back to shell if faces are misiing + if len(shell.Faces) != len(solid.Faces): + solid = shell except: # keeping a shell if solid is failing solid = shell diff --git a/a2p_importedPart_class.py b/a2p_importedPart_class.py index 32a88fd1..37e54f05 100644 --- a/a2p_importedPart_class.py +++ b/a2p_importedPart_class.py @@ -31,7 +31,7 @@ from FreeCAD import Base from PySide import QtGui import a2plib - +from a2p_versionmanagement import A2P_VERSION #============================================================================== class Proxy_importPart: ''' @@ -46,6 +46,7 @@ def setProperties(self,obj): propList = obj.PropertiesList if not "a2p_Version" in propList: obj.addProperty("App::PropertyString", "a2p_Version", "importPart") + obj.a2p_Version = A2P_VERSION if not "sourceFile" in propList: obj.addProperty("App::PropertyFile", "sourceFile", "importPart") if not "sourcePart" in propList: @@ -58,8 +59,10 @@ def setProperties(self,obj): obj.addProperty("App::PropertyBool","fixedPosition","importPart") if not "subassemblyImport" in propList: obj.addProperty("App::PropertyBool","subassemblyImport","importPart") + obj.subassemblyImport = False if not "updateColors" in propList: obj.addProperty("App::PropertyBool","updateColors","importPart") + obj.updateColors = True self.type = "a2p_importPart" diff --git a/a2p_importpart.py b/a2p_importpart.py index ae83d1c9..4f18c9ea 100644 --- a/a2p_importpart.py +++ b/a2p_importpart.py @@ -55,7 +55,7 @@ ) import a2p_lcs_support -from a2p_importedPart_class import Proxy_importPart +from a2p_importedPart_class import Proxy_importPart, ImportedPartViewProviderProxy PYVERSION = sys.version_info[0] @@ -580,6 +580,14 @@ def updateImportedParts(doc): for obj in doc.Objects: if hasattr(obj, 'sourceFile') and a2plib.to_str(obj.sourceFile) != a2plib.to_str('converted'): + + #repair data structures (perhaps an old Assembly2 import was found) + if hasattr(obj,"Content") and 'importPart' in obj.Content: # be sure to have an assembly object + if obj.Proxy is None: + #print (u"Repair Proxy of: {}, Proxy: {}".format(obj.Label, obj.Proxy)) + Proxy_importPart(obj) + ImportedPartViewProviderProxy(obj.ViewObject) + assemblyPath = os.path.normpath(os.path.split(doc.FileName)[0]) absPath = a2plib.findSourceFileInProject(obj.sourceFile, assemblyPath) diff --git a/a2p_topomapper.py b/a2p_topomapper.py index 3a8a6832..1a7d570a 100644 --- a/a2p_topomapper.py +++ b/a2p_topomapper.py @@ -535,29 +535,26 @@ def createTopoNames(self, desiredShapeLabel = None): faceColors.extend(diffuseCol) #let python libs extend faceColors, much faster faces.extend(tempShape.Faces) #let python libs extend faces, much faster - shell = Part.makeShell(faces) + if len(faces) == 1: + shell = Part.makeShell([faces]) + else: + shell = Part.makeShell(faces) try: if a2plib.getUseSolidUnion(): if len(shape_list) > 1: shape_base=shape_list[0] shapes=shape_list[1:] solid = shape_base.fuse(shapes) - #solid = ob.Shape else: #one shape only - solid = shape_list[0] + solid = Part.Solid(shape_list[0]) else: - solid = Part.Solid(shell) + solid = Part.Solid(shell) # fails with missing faces if shell contains spheres + if len(shell.Faces) != len(solid.Faces): + solid = shell # fall back to shell if faces are missing except: # keeping a shell if solid is failing solid = shell - # sometimes converting to solid deletes faces, especially spheres. - # check for this problem and apply a shell if problems are detected - numShellFaces = len(shell.Faces) - numSolidFaces = len(solid.Faces) - if numShellFaces != numSolidFaces: - solid = shell # fall back to shell on missing faces - #------------------------------------------- # if toponaming is used, assign toponames to # shells geometry