# Error evaluating attribute with unit

**URL:** <https://forum.sensmetry.com/t/error-evaluating-attribute-with-unit/199>\
**Category:** Feature Requests\
**Tags:** automator\
**Created:** [August 19, 2025, 1:59pm UTC](https://forum.sensmetry.com/t/error-evaluating-attribute-with-unit/199 "2025-08-19T13:59:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![clement.jonglez](https://yyz2.discourse-cdn.com/flex008/user_avatar/forum.sensmetry.com/clement.jonglez/32/82_2.png) [@clement.jonglez](https://forum.sensmetry.com/u/clement.jonglez)\
**Post date:** [August 19, 2025, 1:59pm UTC](https://forum.sensmetry.com/t/error-evaluating-attribute-with-unit/199/1 "2025-08-19T13:59:18Z")

</div>

When using physical units in an attribute, I get an error while evaluating the feature value expression.

Here’s my SysML v2 code:

```sysml
package 'Part Tree Example' {
    private import ISQ::mass;
    private import SI::kg;

    part def PhysicalPart {
        attribute mass :> ISQ::mass;
    }
    part def Electrical specializes PhysicalPart;
    part def Mechanical specializes PhysicalPart;

    part automobile {
        part drive_train {
            part battery : Electrical {
                attribute redefines mass = 150 [kg];
            }
            part motor : Electrical {
                attribute redefines mass = 200 [kg];
            }
        }
        part chassis {
            part suspension : Mechanical {
                attribute redefines mass = 100 [kg];
            }
            part body : Mechanical {
                attribute redefines mass = 150 [kg];
            }
        }
    }
}

```

And here’s my Python code:

```python
import syside

def find_part_usage(element: syside.Element, part_name: str) -> syside.PartUsage:
    if element.try_cast(syside.PartUsage) and element.name == part_name:
        return element
    else:
        for owned_element in element.owned_elements:
            found_part = find_part_usage(owned_element, part_name)
            if found_part:
                return found_part
        return

def find_attribute_usage(
    element: syside.Element, attr_name: str
) -> syside.AttributeUsage | None:
    for owned in element.owned_members.collect():
        if owned.try_cast(syside.AttributeUsage):
            if owned.name == attr_name:
                return owned

model, diagnostics = syside.load_model(["models/example_model_mass.sysml"])

assert not diagnostics.contains_errors(warnings_as_errors=True)
for doc in model.user_docs:
    with doc.lock() as locked:
        found_part = find_part_usage(locked.root_node, "battery")

print(found_part.name)

found_attr = find_attribute_usage(found_part, "mass")
print(found_attr.name)

assert found_attr.feature_value_expression is not None

evaluation = syside.Compiler().evaluate(found_attr.feature_value_expression)
if evaluation[1].fatal:
    print(
        f"Error evaluating {found_attr.name} attribute of part usage {found_part.name}"
    )
    for diag in evaluation[1].diagnostics:
        print(f'Diagnostic code: "{diag.code}", message: "{diag.message}"')
else:
    total_mass = evaluation[0]

```

Will print:

```auto
battery
mass
Error evaluating mass attribute of part usage battery
Diagnostic code: "unsupported-operator", message: "Operator '[' is not model-level evaluable"

```

I am using syside automator 0.6.3.

---

<div class="post-metadata">

**Author:** ![clement.jonglez](https://yyz2.discourse-cdn.com/flex008/user_avatar/forum.sensmetry.com/clement.jonglez/32/82_2.png) [@clement.jonglez](https://forum.sensmetry.com/u/clement.jonglez)\
**Post date:** [August 19, 2025, 2:01pm UTC](https://forum.sensmetry.com/t/error-evaluating-attribute-with-unit/199/2 "2025-08-19T14:01:25Z")

</div>

My bad I just saw in the documentation that this is not supported yet: [Advanced Technical Guide](https://docs.sensmetry.com/latest/automator/advanced.html#expression-evaluation)

When do you think this feature will be added?

---

<div class="post-metadata">

**Author:** ![Daumantas](https://yyz2.discourse-cdn.com/flex008/user_avatar/forum.sensmetry.com/daumantas/32/19_2.png) [@Daumantas](https://forum.sensmetry.com/u/Daumantas)\
**Post date:** [August 19, 2025, 2:05pm UTC](https://forum.sensmetry.com/t/error-evaluating-attribute-with-unit/199/3 "2025-08-19T14:05:45Z")

</div>

There is no timeline for quantities and units support yet, however it is certainly on our radar.
