[Cherry-pick] DYN-9604: Fix blank quantity dropdown in unit nodes #16624
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cherry-pick of #16621 to
RC4.0.0_masterPurpose
Fixes DYN-9604: Unit conversion node quantity dropdown appears blank when opening v1 schema graphs in environments with ASC 2026+ installed.
Background:
When Dynamo graphs are saved without ASC available (using
ForgeUnits.Schemas v1.0.4), unit conversion nodes serialize with v1 schema identifiers likeautodesk.unit.quantity:length-1.0.5. When these graphs are opened in environments where ASC 2026+ is installed, Dynamo automatically loads v2 schemas from ASC instead of the bundled v1 schemas.During deserialization, the JSON constructor first populates
QuantityConversionSourceby callingGetAllQuantities(), which returns only the latest v2 schemas from ASC. Then, whenSelectedQuantityConversionis deserialized,Quantity.ByTypeID()is called with the v1 TypeId from the DYN file (e.g.,"autodesk.unit.quantity:length-1.0.5"), creating a newQuantityobject instance. Since WPF ComboBoxSelectedItembinding uses reference equality by default, the deserializedQuantitycannot find a matching instance in theItemsSource, causing the dropdown to appear blank.For example, after loading a v1 DYN file:
QuantityConversionSource(the ComboBox ItemsSource):[Quantity@0x1234 {TypeId="length-2.0.0"}, ...]- v2 schemas fromGetAllQuantities()in the constructorSelectedQuantityConversion(the ComboBox SelectedItem):Quantity@0x5678 {TypeId="length-1.0.5"}- a different instance created byByTypeID()during JSON deserializationThe ComboBox cannot find a match because the deserialized
Quantityhas TypeId"length-1.0.5"(v1), but the collection only contains v2 schemas like"length-2.0.0". Even though they represent the same quantity type (Length), the TypeIds don't match.The same issue affects the from/to unit dropdowns, though they were less visible because the unit sources are populated from the deserialized Quantity's
.Unitsproperty, which may return units from multiple schema versions.Solution:
Introduced a reconciliation mechanism that matches deserialized items to their corresponding collection entries by comparing
typeName(TypeId without version suffix). This ensures reference equality for WPF binding while maintaining backward compatibility with v1 schemas.Declarations
Release Notes
Fixed an issue where the quantity dropdown in "Convert By Units" nodes would appear blank when opening graphs saved with v1 schemas in environments with ASC 2026+ installed. The node now correctly displays and functions with schema version upgrades.
Reviewers
(Assign appropriate reviewer)
Testing Notes:
FYIs
(Optional)