Shared Parameters
Get Shared Parameter Name
$getSharedParamName := function($sharedParamId){
$$[type="Parameter" and id = $sharedParamId].name
};
Get Shared Parameter GUID
$getSharedParamGuid := function($sharedParamId){
$$[type="Parameter" and id = $sharedParamId].values.guid
};
Family Symbols and Instance
Deze regels verzameld alle Family Symbols en de eerste Instance van Families waarvan de naam begint met NLRS.
(
$getSharedParamName := function($sharedParamId){
$$[type="Parameter" and id = $sharedParamId].name
};
$getSharedParamGuid := function($sharedParamId){
$$[type="Parameter" and id = $sharedParamId].values.guid
};
$getFamilyName := function($ParentId){
$$[type="Family" and id = $ParentId].name
};
$getInstanceSP := function($parentId) {
$filter(
$[type = "FamilyInstance" and parent.id = $parentId][0].**[ref = "Parameter"],
function($p) {
$count($match($getSharedParamName($p.id), /^(eV|eE)/)) = 0
}
).{
"name": $getSharedParamName($.id),
"value": value,
"guid": $getSharedParamGuid($.id),
}
};
/*Only model family ids whose name start with NLRS */
$families := $[type = "Family" and values.isEditable = true and values.familyCategory.type = "Model" and $match(name, /^NLRS/)].id;
$allfamilysymbols := $[type = "FamilySymbol" and parent.id in $families].{
"id": id,
"type": type,
"name": name,
"familyname": $getFamilyName(parent.id),
"sp": $append($filter(**[ref = "Parameter"], function($p) {
$count($match($getSharedParamName($p.id), /^(eV|eE)/)) = 0
}).{
"name": $getSharedParamName($.id),
"value": value,
"guid": $getSharedParamGuid($.id),
},
$getInstanceSP(id))
}[$exists(sp)][];
)
Family Symbols and Instance except parameter with eV
(
$getSharedParamName := function($sharedParamId){
$$[type="Parameter" and id = $sharedParamId].name
};
$getSharedParamGuid := function($sharedParamId){
$$[type="Parameter" and id = $sharedParamId].values.guid
};
$getInstanceSP := function($parentId) {
$filter(
$[type = "FamilyInstance" and parent.id = $parentId][0].**[ref = "Parameter"],
function($p) {
$count($match($getSharedParamName($p.id), /^(eV|eE)/)) = 0
}
).{
"name": $getSharedParamName($.id),
"value": value,
"guid": $getSharedParamGuid($.id),
}
};
$allfamilysymbols := $[type = "FamilySymbol"].{
"id": id,
"type": type,
"name": name,
"sp": $append($filter(**[ref = "Parameter"], function($p) {
$count($match($getSharedParamName($p.id), /^(eV|eE)/)) = 0
}).{
"name": $getSharedParamName($.id),
"value": value,
"guid": $getSharedParamGuid($.id),
},
$getInstanceSP(id))
}[$exists(sp)][];
)
LookupGuid
(
$LookupGuid1 := "104c3657-6918-4b2b-a0b9-bf4b05c8621a";
$LookupGuid2 := "2bc41923-4e29-4bf8-9911-992c87f16d26";
/* Get the Parameter Info for the given guid) */
$getSharedParamInfo := function($guid){(
$sharedParemInfo := $$[type="Parameter" and values.guid = $guid];
{
"paramExist": $exists($sharedParamInfo),
"guid": $exists($sharedParemInfo) ? $sharedParemInfo.values.guid : null,
"name": $exists($sharedParemInfo) ? $sharedParemInfo.values.name : null,
"spec": $exists($sharedParemInfo) ? $sharedParemInfo.values.spec : null,
"ispp": $exists($sharedParemInfo) ? $sharedParemInfo.values.isProjectParameter : null,
}
)};
/* Get info for both parameters */
$paramInfo1 := $getSharedParamInfo($LookupGuid1);
$paramInfo2 := $getSharedParamInfo($LookupGuid2);
/* Get parameter value from object using GUID */
$getSharedParam := function($object, $guid, $meta){(
$sp := $lookup($object.values, "p_" & $guid);
$paramExist := $exists($sp);
{
"paramExist": $paramExist,
"value": $paramExist ? $sp.value : "Parameter niet aanwezig",
"guid": $meta.guid,
"name": $meta.name,
"spec": $meta.spec,
"isPP": $meta.isPP
}
)};
/* Main data filter */
$[type = "FamilyInstance"].{
"name": name,
"type": type,
"id": id,
"Objecttype_Number": $getSharedParam($, $LookupGuid1, $paramInfo1),
"Objecttype_Description": $getSharedParam($, $LookupGuid2, $paramInfo2)
};
)
LookupGuid2
```jsonata ( / All relevant GUIDs in one place / $paramGuids := { "schijnbaar_vermogen": "05f48ef2-d9e1-4f54-aa1b-9bafd25fadae", "vermogensclassificatie": "9f8db0d3-4762-4cc1-a673-372900370c54", "schijnbaar_vermogen_L1": "6a7cbf53-e5af-454b-bd4c-9cbe1b09f45b", "schijnbaar_vermogen_L2": "4e2fbace-1871-4533-970f-61de8d5878cb", "schijnbaar_vermogen_L3": "f275a71d-d48f-44c9-a019-d8005dbd4068", };
/ Build one lookup table with metadata per GUID (keys are strings!) / $paramMetaByGuid := $merge( $$[type = "Parameter" and values.guid in $paramGuids.*].{ $string(values.guid): { "paramExist": true, "guid": values.guid, "name": values.name } } );
$getSharedParam := function($object, $logicalName){(
$guid := $lookup($paramGuids, $logicalName);
$meta := $guid ? $lookup($paramMetaByGuid, $string($guid)) : undefined;
$sp := $guid ? $lookup($object.values, "p_" & $guid) : undefined;
$present := $exists($sp);
/* Extract the correct value */
$val :=
$present and $exists($sp.valueAsString) and $sp.valueAsString != ""
? $sp.valueAsString
: (
$present and $exists($sp.value)
? $sp.value
: "Parameter niet aanwezig"
);
{
"paramExist": $present,
"value": $val,
"guid": $meta ? $meta.guid : $guid,
"name": $meta ? $meta.name : $logicalName
}
)};
/* All Families*/
$famNLRS := $[type = "Family" and $match(name, /^NLRS/)].id;
/* make sure this always returns a boolean */
$matches := function($s, $re){
$boolean($s) and ($match($s, $re) != [])
};
/* All FamilySymbols*/
$symbols32 := $[type = "FamilySymbol" and $matches($string(values.assemblyCode), /^62\.(?:[1-9]\d?)$/) and parent.id in $famNLRS];
/* Index symbols by id (id cast to string for object key) */
$symIndex := $merge(
$symbols32.{
$string(id): $
}
);
/* Main query over FamilyInstances */
$[type = "FamilyInstance"].(
$sym := $lookup($symIndex, $string(parent.id));
$sym ?
{
"id": id,
"type": type,
"name": name,
"Category": $sym.values.category.label,
"assemblyCode": $sym.values.assemblyCode,
"vermogensclassificatie": $getSharedParam($sym, "vermogensclassificatie"),
"schijnbaar_vermogen":$getSharedParam($, "schijnbaar_vermogen"),
"schijnbaar_vermogen_L1":$getSharedParam($, "schijnbaar_vermogen_L1"),
"schijnbaar_vermogen_L2":$getSharedParam($, "schijnbaar_vermogen_L2"),
"schijnbaar_vermogen_L3":$getSharedParam($, "schijnbaar_vermogen_L3"),
}
: ()
)
) ````
Template
```jsonata ( / All relevant GUIDs in one place / $paramGuids := { "DGW_Element_Suitability": "06cbdf9a-eaf7-4b9d-a3b7-e5bd79e368ac", "Element_Suitability_Description": "7c6cf05f-a9d8-4fac-9db8-329162de8be6" };
/ Build one lookup table with metadata per GUID (keys are strings!) / $paramMetaByGuid := $merge( $$[type = "Parameter" and values.guid in $paramGuids.*].{ $string(values.guid): { "paramExist": true, "guid": values.guid, "name": values.name } } );
$getSharedParam := function($object, $logicalName){ ( $guid := $lookup($paramGuids, $logicalName); $meta := $guid ? $lookup($paramMetaByGuid, $string($guid)) : undefined; $sp := $guid and $exists($object.values) ? $lookup($object.values, "p_" & $guid) : undefined;
$present := $exists($sp);
$val :=
$present and $exists($sp.valueAsString) and $sp.valueAsString != ""
? $sp.valueAsString
: (
$present and $exists($sp.value)
? $sp.value
: "Parameter niet aanwezig"
);
{
"paramExist": $present,
"value": $val,
"guid": $meta ? $meta.guid : $guid,
"name": $meta ? $meta.name : $logicalName
}
)
};
/ Category Exclusion List OST names/ $CategoryExclusion = ["OST_DetailComponents"];
/ Category filters based upon FamilySymbols / $symbols := $[type = "FamilySymbol" and values.category.type = "Model" and $not(values.category.label in $CategoryExclusion)];
/ Index symbols by id / $symIndex := $merge($symbols.{$string(id): $});
/ Main query over FamilyInstances / $[type = "FamilyInstance" and $exists(parent)].( $sym := $lookup($symIndex, $string(parent.id)); $sym ? { "id": id, "type": type, "name": name, "Category": $sym.values.category.label, "assemblyCode": $sym.values.assemblyCode, "DGW_Element_Suitability": $getSharedParam($, "DGW_Element_Suitability"), "Element_Suitability_Description": $getSharedParam($, "Element_Suitability_Description") } : () ) ) ````
template with built in check
```jsonata ( / All relevant GUIDs in one place / $paramGuids := { "DGW_Element_Suitability": "06cbdf9a-eaf7-4b9d-a3b7-e5bd79e368ac", "Element_Suitability_Description": "7c6cf05f-a9d8-4fac-9db8-329162de8be6" };
/ value mappings between DGW_Element_Suitability and Element_Suitability_Description / $map := { "S000": "Bestaande situatie", "S100": "Conceptueel", "S200": "VO", "S300": "DO", "S400": "UO", "S500": "AB" };
/ Build one lookup table with metadata per GUID (keys are strings!) / $paramMetaByGuid := $merge( $$[type = "Parameter" and values.guid in $paramGuids.*].{ $string(values.guid): { "paramExist": true, "guid": values.guid, "name": values.name } } );
$getSharedParam := function($object, $logicalName){ ( $guid := $lookup($paramGuids, $logicalName); $meta := $guid ? $lookup($paramMetaByGuid, $string($guid)) : undefined; $sp := $guid and $exists($object.values) ? $lookup($object.values, "p_" & $guid) : undefined;
$present := $exists($sp);
$val :=
$present and $exists($sp.valueAsString) and $sp.valueAsString != ""
? $sp.valueAsString
: (
$present and $exists($sp.value)
? $sp.value
: "Parameter niet aanwezig"
);
{
"paramExist": $present,
"value": $val,
"guid": $meta ? $meta.guid : $guid,
"name": $meta ? $meta.name : $logicalName
}
)
};
/ Mapping check: returns status text / $checkSuitabilityMapping := function($codeParam, $descParam){ ( $codeOk := $codeParam.paramExist and $codeParam.value != "Parameter niet aanwezig"; $descOk := $descParam.paramExist and $descParam.value != "Parameter niet aanwezig";
($codeOk and $descOk) = false ? "n.v.t." :
(
$expected := $lookup($map, $string($codeParam.value));
$expected = undefined ? "UnknownCode" :
($string($descParam.value) = $string($expected) ? "OK" : "Mismatch")
)
)
};
/ Category Exclusion List OST names/ $CategoryExclusion = ["OST_DetailComponents"];
/ Category filters based upon FamilySymbols / $symbols := $[type = "FamilySymbol" and values.category.type = "Model" and $not(values.category.label in $CategoryExclusion)];
/ Index symbols by id / $symIndex := $merge($symbols.{$string(id): $});
/ Main query over FamilyInstances / $[type = "FamilyInstance" and $exists(parent)].( $sym := $lookup($symIndex, $string(parent.id)); $sym ? ( $suit := $getSharedParam($, "DGW_Element_Suitability"); $desc := $getSharedParam($, "Element_Suitability_Description");
{
"id": id,
"type": type,
"name": name,
"Category": $sym.values.category.label,
"assemblyCode": $sym.values.assemblyCode,
"DGW_Element_Suitability": $suit,
"Element_Suitability_Description": $desc,
"SuitabilityMappingCheck": $checkSuitabilityMapping($suit, $desc)
}
)
: ()
) ) ````