Skip to content

Commit

Permalink
fix(core): Property Facet in IDS throwing error when NominalValue is …
Browse files Browse the repository at this point in the history
…null
  • Loading branch information
HoyosJuan committed Nov 5, 2024
1 parent a5d806a commit d8d2cdc
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions packages/core/src/openbim/IDSSpecifications/src/facets/Property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,10 @@ export class IDSProperty extends IDSFacet {
// IFCPROPERTYTABLEVALUE are not supported yet
// Work must to be done to convert numerical value units to IDS-nominated standard units https://github.com/buildingSMART/IDS/blob/development/Documentation/UserManual/units.md
private evalValue(attrs: Record<string, any>, checks?: IDSCheck[]) {
const valueKey = this.getValueKey(attrs);
const valueKey = this.getValueKey(attrs) as any;
const valueAttr = attrs[valueKey];
if (this.value) {
if (!valueKey) {
if (!valueAttr) {
checks?.push({
parameter: "Value",
currentValue: null,
Expand All @@ -380,7 +381,6 @@ export class IDSProperty extends IDSFacet {
return false;
}

const valueAttr = attrs[valueKey];
const facetValue = structuredClone(this.value);
if (valueAttr.name === "IFCLABEL" && facetValue.type === "simple") {
facetValue.parameter = String(facetValue.parameter);
Expand Down Expand Up @@ -415,10 +415,9 @@ export class IDSProperty extends IDSFacet {
}

if (!valueKey) return true;
const value = attrs[valueKey];

// IDSDocs: Values with a logical unknown always fail
if (value.type === 3 && value.value === 2) {
if (valueAttr.type === 3 && valueAttr.value === 2) {
checks?.push({
parameter: "Value",
currentValue: null,
Expand All @@ -429,7 +428,7 @@ export class IDSProperty extends IDSFacet {
}

// IDSDocs: An empty string is considered false
if (value.type === 1 && value.value.trim() === "") {
if (valueAttr.type === 1 && valueAttr.value.trim() === "") {
checks?.push({
parameter: "Value",
currentValue: "",
Expand All @@ -444,8 +443,18 @@ export class IDSProperty extends IDSFacet {

private evalDataType(attrs: Record<string, any>, checks?: IDSCheck[]) {
if (!this.dataType) return true;
const valueKey = this.getValueKey(attrs);
const valueAttr = attrs[valueKey as any];
const valueKey = this.getValueKey(attrs) as any;
const valueAttr = attrs[valueKey];

if (!valueAttr) {
checks?.push({
parameter: "DataType",
currentValue: null,
pass: false,
requiredValue: this.dataType,
});
return false;
}

if (
(attrs.type === WEBIFC.IFCPROPERTYLISTVALUE ||
Expand Down

0 comments on commit d8d2cdc

Please sign in to comment.