Skip to content

Commit

Permalink
Merge pull request #281 from kbwbe/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
kbwbe authored May 12, 2019
2 parents be459a4 + fade1a2 commit b2c53a4
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 39 deletions.
2 changes: 1 addition & 1 deletion InitGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
__title__ = 'A2plus assembly Workbench - InitGui file'
__author__ = 'kbwbe'

A2P_VERSION = 'V0.4.20'
A2P_VERSION = 'V0.4.21'



Expand Down
43 changes: 18 additions & 25 deletions a2p_MuxAssembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion a2p_importedPart_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from FreeCAD import Base
from PySide import QtGui
import a2plib

from a2p_versionmanagement import A2P_VERSION
#==============================================================================
class Proxy_importPart:
'''
Expand All @@ -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:
Expand All @@ -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"

Expand Down
10 changes: 9 additions & 1 deletion a2p_importpart.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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)

Expand Down
19 changes: 8 additions & 11 deletions a2p_topomapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b2c53a4

Please sign in to comment.