Skip to content

Commit

Permalink
Fix exception after reload of file
Browse files Browse the repository at this point in the history
When a boolean operation was applied to a mesh, it could not be
recomputed because the boolean operations execute was not called, and
so the mesh was empty. Fixed it by calling execute when needed.

optimizes #33
  • Loading branch information
furti committed Apr 24, 2019
1 parent 4eb66ca commit 8eb6222
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions boolean_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ def execute(self, obj):
else:
self.mesh = MeshPart.meshFromShape(base.copy(False))

def getMesh(self):
if not self.mesh:
self.execute(self.Object)

return self.mesh

def applyOperationToMesh(self, mesh):
if not self.Object.Enabled:
return mesh
Expand All @@ -69,10 +75,12 @@ def applyOperationToMesh(self, mesh):

openscadOperation = MODE_MAPPING[self.Object.Mode]

return OpenSCADUtils.meshoptempfile(openscadOperation, (mesh, self.mesh))
return OpenSCADUtils.meshoptempfile(openscadOperation, (mesh, self.getMesh()))

def setProperties(self, obj):
self.Object = obj
self.mesh = None

pl = obj.PropertiesList

if not 'Base' in pl:
Expand Down Expand Up @@ -199,7 +207,6 @@ def execute(self, obj):
obj.Result.Mesh = resultMesh

def executeOpenSCAD(self, basemesh, obj):
print('scad')
if len(obj.Features) == 0:
return basemesh

Expand All @@ -211,15 +218,14 @@ def executeOpenSCAD(self, basemesh, obj):
return mesh

def executeBlender(self, basemesh, obj):
print('blender')
if len(obj.Features) == 0:
return basemesh

from blender import blender_processor

operations = [(feature.Proxy.mesh, feature.Mode, feature.Name)
operations = [(feature.Proxy.getMesh(), feature.Mode, feature.Name)
for feature in obj.Features if feature.Enabled]

# no operations enabled
if len(operations) == 0:
return basemesh
Expand Down

0 comments on commit 8eb6222

Please sign in to comment.