Skip to content

Commit b255eb6

Browse files
committed
Handle missing IfcRelationship
eg. if all sofas are deleted the IfcRelDefinesByType is deleted too, but we reincarnate as an empty list so it can be merged.
1 parent 9f63603 commit b255eb6

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

ifcmerge

+26-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,19 @@ for my $id ($local->deleted_ids)
7373
{
7474
if (defined $remote->{modified}->{$id})
7575
{
76-
push @errors, "$ARGV[1] deleted entity #$id modified in $ARGV[2]!";
76+
my ($remote_class) = $remote->class_attributes($id);
77+
if ($remote_class =~ /^IfcRel/i)
78+
{
79+
# IfcRelationship may be deleted overzealously, reinsert empty
80+
$local->{file}->{$id} = $remote->{file}->{$id};
81+
$local->{file}->{$id} =~ s/\([0-9#,]+\)/\(\)/;
82+
delete $local->{deleted}->{$id};
83+
$local->{modified}->{$id} = 1;
84+
}
85+
else
86+
{
87+
push @errors, "$ARGV[1] deleted entity #$id modified in $ARGV[2]!";
88+
}
7789
}
7890
else
7991
{
@@ -84,7 +96,19 @@ for my $id ($remote->deleted_ids)
8496
{
8597
if (defined $local->{modified}->{$id})
8698
{
87-
push @errors, "$ARGV[2] deleted entity #$id modified in $ARGV[1]!";
99+
my ($local_class) = $local->class_attributes($id);
100+
if ($local_class =~ /^IfcRel/i)
101+
{
102+
# IfcRelationship may be deleted overzealously, reinsert empty
103+
$remote->{file}->{$id} = $local->{file}->{$id};
104+
$remote->{file}->{$id} =~ s/\([0-9#,]+\)/\(\)/;
105+
delete $remote->{deleted}->{$id};
106+
$remote->{modified}->{$id} = 1;
107+
}
108+
else
109+
{
110+
push @errors, "$ARGV[2] deleted entity #$id modified in $ARGV[1]!";
111+
}
88112
}
89113
else
90114
{

0 commit comments

Comments
 (0)