From cc10c97c6430dd1c1fbd21943286176215f87cb4 Mon Sep 17 00:00:00 2001 From: kike-garbo Date: Fri, 11 Oct 2024 19:44:57 +0200 Subject: [PATCH 1/2] Fix on `ValueSet.GetItemIcon`. --- .../Grasshopper/Special/ValueSet.cs | 20 +++++++++---------- src/RhinoInside.Revit.GH/Types/Reference.cs | 9 +++++---- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/RhinoInside.Revit.GH/Extensions/Grasshopper/Special/ValueSet.cs b/src/RhinoInside.Revit.GH/Extensions/Grasshopper/Special/ValueSet.cs index e9e41abab..86fb77418 100644 --- a/src/RhinoInside.Revit.GH/Extensions/Grasshopper/Special/ValueSet.cs +++ b/src/RhinoInside.Revit.GH/Extensions/Grasshopper/Special/ValueSet.cs @@ -235,10 +235,10 @@ public DataCulling Culling public virtual DataCulling CullingMask => DataCulling.Nulls | DataCulling.Invalids | DataCulling.Duplicates | DataCulling.Empty; static readonly Dictionary TypeIcons = new Dictionary(); - protected virtual Bitmap GetItemIcon(T value, Size size) + protected virtual Bitmap GetItemIcon(IGH_Goo value, Size size) { var type = value.GetType(); - if (TypeIcons.TryGetValue(GetType(), out var icon)) + if (TypeIcons.TryGetValue(type, out var icon)) return icon; var bitmap = default(Bitmap); @@ -251,19 +251,19 @@ protected virtual Bitmap GetItemIcon(T value, Size size) { // Try with a parameter that has the same name. var typeName = value.TypeName; - var location = value.GetType().Assembly.Location; - var proxy = Instances.ComponentServer.ObjectProxies. + var assembly = type.Assembly; + var proxies = Instances.ComponentServer.ObjectProxies. Where ( - x => typeof(IGH_Param).IsAssignableFrom(x.Type) && - string.Equals(x.Desc.Name, typeName, StringComparison.OrdinalIgnoreCase) && - string.Equals(x.Location, location, StringComparison.OrdinalIgnoreCase) + x => x.Kind == GH_ObjectType.CompiledObject && + typeof(IGH_Param).IsAssignableFrom(x.Type) && + Equals(x.Type?.Assembly, assembly) && + string.Equals(x.Desc.Name, typeName, StringComparison.OrdinalIgnoreCase) ). OrderBy(x => !x.SDKCompliant). - ThenBy(x => x.Obsolete). - FirstOrDefault(); + ThenBy(x => x.Obsolete); - bitmap = proxy?.Icon; + bitmap = proxies.FirstOrDefault()?.Icon; } return TypeIcons[type] = bitmap; diff --git a/src/RhinoInside.Revit.GH/Types/Reference.cs b/src/RhinoInside.Revit.GH/Types/Reference.cs index 03aba6c48..e15619ef7 100755 --- a/src/RhinoInside.Revit.GH/Types/Reference.cs +++ b/src/RhinoInside.Revit.GH/Types/Reference.cs @@ -131,13 +131,14 @@ Bitmap IGH_ItemDescription.GetTypeIcon(Size size) if (typeName.StartsWith("Revit ")) typeName = typeName.Substring(6); - var location = GetType().Assembly.Location; + var assembly = GetType().Assembly; var proxy = Instances.ComponentServer.ObjectProxies. Where ( - x => typeof(IGH_Param).IsAssignableFrom(x.Type) && - string.Equals(x.Desc.Name, typeName, StringComparison.OrdinalIgnoreCase) && - string.Equals(x.Location, location, StringComparison.OrdinalIgnoreCase) + x => x.Kind == GH_ObjectType.CompiledObject && + typeof(IGH_Param).IsAssignableFrom(x.Type) && + Equals(x.Type?.Assembly, assembly) && + string.Equals(x.Desc.Name, typeName, StringComparison.OrdinalIgnoreCase) ). OrderBy(x => !x.SDKCompliant). ThenBy(x => x.Obsolete). From 6b7d002d4086af455139275b0a9479d875af2511 Mon Sep 17 00:00:00 2001 From: kike-garbo Date: Fri, 11 Oct 2024 19:46:19 +0200 Subject: [PATCH 2/2] Keep it generic. --- .../Extensions/Grasshopper/Special/ValueSet.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RhinoInside.Revit.GH/Extensions/Grasshopper/Special/ValueSet.cs b/src/RhinoInside.Revit.GH/Extensions/Grasshopper/Special/ValueSet.cs index 86fb77418..083060822 100644 --- a/src/RhinoInside.Revit.GH/Extensions/Grasshopper/Special/ValueSet.cs +++ b/src/RhinoInside.Revit.GH/Extensions/Grasshopper/Special/ValueSet.cs @@ -235,7 +235,7 @@ public DataCulling Culling public virtual DataCulling CullingMask => DataCulling.Nulls | DataCulling.Invalids | DataCulling.Duplicates | DataCulling.Empty; static readonly Dictionary TypeIcons = new Dictionary(); - protected virtual Bitmap GetItemIcon(IGH_Goo value, Size size) + protected virtual Bitmap GetItemIcon(T value, Size size) { var type = value.GetType(); if (TypeIcons.TryGetValue(type, out var icon))