Skip to content

Commit

Permalink
fix(model): Include room names in model adjacency checks where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey committed Jul 30, 2024
1 parent e8e4d70 commit f3fef22
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
8 changes: 8 additions & 0 deletions honeybee/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,14 @@ def _validation_message(
error_dict['parents'] = [parents]
return [error_dict]

def _top_parent(self):
"""Get the highest parent object that this object is a part of."""
if getattr(self, '_parent', None) is not None:
rel_obj = self
while getattr(rel_obj, '_parent', None) is not None:
rel_obj = getattr(rel_obj, '_parent')
return rel_obj

@staticmethod
def _validation_message_child(
message, child_obj, detailed=False, code='000000', extension='Core',
Expand Down
20 changes: 14 additions & 6 deletions honeybee/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3282,8 +3282,10 @@ def _self_adj_check(self, obj_type, hb_obj, bc_ids, room_ids, bc_set, detailed):
msgs = []
# first ensure that the object is not referencing itself
if hb_obj.identifier == bc_obj:
msg = '{} "{}" cannot reference itself in its Surface boundary ' \
'condition.'.format(obj_type, hb_obj.full_id)
parent_msg = 'with parent "{}" '.format(hb_obj._top_parent().full_id) \
if hb_obj.has_parent else ''
msg = '{} "{}" {}cannot reference itself in its Surface boundary ' \
'condition.'.format(obj_type, hb_obj.full_id, parent_msg)
msg = self._validation_message_child(
msg, hb_obj, detailed, '000201',
error_type='Self-Referential Adjacency')
Expand All @@ -3299,8 +3301,12 @@ def _self_adj_check(self, obj_type, hb_obj, bc_ids, room_ids, bc_set, detailed):
msgs.append(msg)
# lastly make sure the adjacent object doesn't already have an adjacency
if bc_obj in bc_set:
msg = '{} "{}" is adjacent to object "{}", which has another adjacent ' \
'object in the Model.'.format(obj_type, hb_obj.full_id, bc_obj)
parent_msg1 = 'with parent "{}" '.format(hb_obj._top_parent().full_id) \
if hb_obj.has_parent else ''
parent_msg2 = ' with parent "{}" '.format(bc_room) if len(bc_objs) > 1 else ''
msg = '{} "{}" {}is adjacent to object "{}"{}, which has another adjacent ' \
'object in the Model.'.format(
obj_type, hb_obj.full_id, parent_msg1, bc_obj, parent_msg2)
msg = self._validation_message_child(
msg, hb_obj, detailed, '000203',
error_type='Object with Multiple Adjacencies')
Expand All @@ -3311,8 +3317,10 @@ def _self_adj_check(self, obj_type, hb_obj, bc_ids, room_ids, bc_set, detailed):

def _missing_adj_msg(self, messages, hb_obj, bc_obj,
obj_type='Face', bc_obj_type='Face', detailed=False):
msg = '{} "{}" has an adjacent {} that is missing from the model: ' \
'{}'.format(obj_type, hb_obj.full_id, bc_obj_type, bc_obj)
parent_msg = 'with parent "{}" '.format(hb_obj._top_parent().full_id) \
if hb_obj.has_parent else ''
msg = '{} "{}" {}has an adjacent {} that is missing from the model: ' \
'{}'.format(obj_type, hb_obj.full_id, parent_msg, bc_obj_type, bc_obj)
msg = self._validation_message_child(
msg, hb_obj, detailed, '000204', error_type='Missing Adjacency')
if detailed:
Expand Down

0 comments on commit f3fef22

Please sign in to comment.