Get Information of the family
getFamilyNameAndId
(
/* Resolve an element by id (first match) */
$byId := function($id){ $$[id = $id][0] };
/* Family name from any element (id or object) */
$getFamilyName := function($x){
(
$id := ($type($x) = "number" or $type($x) = "string") ? $x : $x.id;
$e := $byId($id);
$e.type = "Family" ? $e.name :
$e.type = "FamilySymbol" ? $byId($e.parent.id).name :
$e.type = "FamilyInstance" ? $byId($byId($e.parent.id).parent.id).name :
""
)
};
/* Family id from any element (id or object) */
$getFamilyId := function($x){
(
$id := ($type($x) = "number" or $type($x) = "string") ? $x : $x.id;
$e := $byId($id);
$e.type = "Family" ? $e.id :
$e.type = "FamilySymbol" ? $e.parent.id :
$e.type = "FamilyInstance" ? $byId($e.parent.id).parent.id :
null
)
};
/* Flattens an array of arrays */
$flatten := function($array) {
$reduce($array, function($acc, $arr) { $append($acc, $arr) }, [])
};
$parameters := $[type = "Parameter" and (
$uppercase($substring(name,0, 4)) = "Q_PR" or
$uppercase($substring(name,0, 4)) = "NLRS"
) and values.isProjectParameter = false];
$familyElements := $[type = "FamilyInstance" or type = "FamilySymbol"];
$paramguid := $map($parameters, function($p){ "p_" & $p.values.guid });
$data := $map($paramguid, function($guid){
$map($familyElements, function($fi){
{
"Element_id": $fi.id,
"type": $fi.type,
"name": $fi.name,
"parent": $fi.parent.id,
"familyName": $getFamilyName($fi.parent.id),
"Id": $getFamilyId($fi.parent.id),
"guid": $guid,
"hasValue": $lookup($fi.values, $guid).hasValue
}
})
});
$flatten($data)[$exists(hasValue)]
)