Skip to content

The drawback of the previous shared-parameter filter

⚠️ Advanced pattern

This chapter introduces a model-aware shared-parameter access pattern. It assumes familiarity with DAQS object types and should be used as a foundation for validation logic — not as a standalone rule.

In the earlier filter, the helper function relied only on $object.values and a static GUID map:

$lookup($object.values, "p_" & $guid)

Why this is a problem

That approach assumes:

  • The parameter exists on the element → ❌ not always true
  • The parameter metadata (name, definition) is irrelevant → ❌ not ideal
  • The GUID map is the single source of truth → ❌ brittle

In practice, this causes two issues:

  1. You cannot distinguish between:

  2. “parameter does not exist in the project”

  3. “parameter exists but is not bound to this element”

  4. You lose access to authoritative metadata:

  5. Real parameter name

  6. Confirmation that the GUID actually exists in the model

This is exactly what you fixed later by introducing Parameter objects as a truth source.


The improved pattern — applied to the earlier filter

Below is the corrected and upgraded version of your earlier filter, now using the robust parameter-metadata approach, but still focused on:

  • FamilyInstance
  • NLRS_C_bouwwerk_laag

✅ Improved, reusable version

(
  /* 1. Logical name → GUID */
  $paramGuids := {
    "NLRS_C_bouwwerk_laag": "beca98b3-5207-4cde-a26b-7e9797c4eb26"
  };

  /* 2. Build parameter metadata index from Parameter objects */
  $paramMetaByGuid := $merge(
    $$[
      type = "Parameter"
      and values.guid in $paramGuids.*
    ].{
      $string(values.guid): {
        "paramExist": true,
        "guid": values.guid,
        "name": values.name
      }
    }
  );

  /* 3. Shared parameter helper (robust) */
  $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
      }
    )
  };

  /* 4. Main query */
  $[type = "FamilyInstance"].{
    "id": id,
    "type": type,
    "name": name,
    "NLRS_C_bouwwerk_laag": $getSharedParam($, "NLRS_C_bouwwerk_laag")
  }
)

What changed compared to the earlier version

1. Parameter existence is now model-aware

This line is the key upgrade:

$$[type = "Parameter" and values.guid in $paramGuids.*]

You are now saying:

“Only trust GUIDs that actually exist as Parameter objects in this model.”

This means:

  • You can detect misconfigured projects
  • You avoid false assumptions
  • You align with how DAQS Assist structures data

2. Metadata is no longer guessed

Instead of returning:

"name": "NLRS_C_bouwwerk_laag"

You now return the real parameter name from the model when available:

"name": values.name

This is crucial for:

  • Error messages
  • Reports
  • User trust (“this is what Revit actually calls it”)

3. The helper function becomes truly generic

The function now separates concerns:

Concern Source
Logical naming $paramGuids
Parameter existence Parameter objects
Element value $object.values

This is what makes it a power script, not a shortcut.