Materials: Set array quantity format (#21647)

* Materials: Set array quantity format

When setting quantity formats, the default format is not actually the
default. Instead fixed format is, which causes issues for very small
and very large values. This was fixed for C++ but arrays created in
Python were not setting the format correctly.

* Apply suggestions from code review

Co-authored-by: Benjamin Nauck <benjamin@nauck.se>
This commit is contained in:
David Carter
2025-06-04 16:27:37 +00:00
committed by GitHub
parent 7105a2332e
commit 657da35e6b
2 changed files with 21 additions and 7 deletions

View File

@@ -159,7 +159,9 @@ PyObject* Array2DPy::setValue(PyObject* args)
if (PyArg_ParseTuple(args, "iiO!", &row, &column, &PyUnicode_Type, &valueObj)) {
Py::String item(valueObj);
try {
QVariant variant = QVariant::fromValue(Base::Quantity::parse(item.as_string()));
auto quantity = Base::Quantity::parse(item.as_string());
quantity.setFormat(MaterialValue::getQuantityFormat());
QVariant variant = QVariant::fromValue(quantity);
getArray2DPtr()->setValue(row, column, variant);
}
catch (const InvalidIndex&) {