Ensure base geometry is valid so if it isn't one can still edit the op and fix the base geometry.

This commit is contained in:
Markus Lampert
2021-02-11 20:35:55 -08:00
parent 57fd294391
commit ec2328bfaa
2 changed files with 24 additions and 0 deletions

View File

@@ -300,6 +300,13 @@ class ObjectOp(object):
def onChanged(self, obj, prop):
'''onChanged(obj, prop) ... base implementation of the FC notification framework.
Do not overwrite, overwrite opOnChanged() instead.'''
# there's a bit of cycle going on here, if sanitizeBase causes the transaction to
# be cancelled we end right here again with the unsainitized Base - if that is the
# case, stop the cycle and return immediately
if prop == 'Base' and self.sanitizeBase(obj):
return
if 'Restore' not in obj.State and prop in ['Base', 'StartDepth', 'FinalDepth']:
self.updateDepths(obj, True)
@@ -463,6 +470,19 @@ class ObjectOp(object):
self.opUpdateDepths(obj)
def sanitizeBase(self, obj):
'''sanitizeBase(obj) ... check if Base is valid and clear on errors.'''
if hasattr(obj, 'Base'):
try:
for (o, sublist) in obj.Base:
for sub in sublist:
e = o.Shape.getElement(sub)
except Part.OCCError as e:
PathLog.error("{} - stale base geometry detected - clearing.".format(obj.Label))
obj.Base = []
return True
return False
@waiting_effects
def execute(self, obj):
'''execute(obj) ... base implementation - do not overwrite!
@@ -494,6 +514,9 @@ class ObjectOp(object):
if not self._setBaseAndStock(obj):
return
# make sure Base is stil valid or clear it
self.sanitizeBase(obj)
if FeatureCoolant & self.opFeatures(obj):
if not hasattr(obj, 'CoolantMode'):
PathLog.error(translate("Path", "No coolant property found. Please recreate operation."))

View File

@@ -1177,6 +1177,7 @@ class TaskPanel(object):
def panelSetFields(self):
'''panelSetFields() ... invoked to trigger a complete transfer of the model's properties to the UI.'''
PathLog.track()
self.obj.Proxy.sanitizeBase(self.obj)
for page in self.featurePages:
page.pageSetFields()