From af53b70514411a211b7b0848a939017911301063 Mon Sep 17 00:00:00 2001 From: connorivy <43247197+connorivy@users.noreply.github.com> Date: Wed, 24 Jul 2024 12:15:07 -0500 Subject: [PATCH] Support shared parameter in schedules (#3585) * add check for shared parameter - to Speckle * update FieldType metadata logic * formatting * correctly assign isReadOnly parameter --------- Co-authored-by: Eduardo Di Loreto Co-authored-by: Connor Ivy --- .../PartialClasses/ConvertView.Schedule.cs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Objects/Converters/ConverterRevit/ConverterRevitShared/PartialClasses/ConvertView.Schedule.cs b/Objects/Converters/ConverterRevit/ConverterRevitShared/PartialClasses/ConvertView.Schedule.cs index 2dc43fefce..bf6de53479 100644 --- a/Objects/Converters/ConverterRevit/ConverterRevitShared/PartialClasses/ConvertView.Schedule.cs +++ b/Objects/Converters/ConverterRevit/ConverterRevitShared/PartialClasses/ConvertView.Schedule.cs @@ -244,7 +244,7 @@ Element firstElement var columnMetadata = new Base(); columnMetadata["BuiltInParameterInteger"] = info.field.ParameterId.IntegerValue; - columnMetadata["FieldType"] = info.field.FieldType.ToString(); + string fieldType = info.field.FieldType.ToString(); Parameter param; if (info.field.FieldType == ScheduleFieldType.ElementType) @@ -257,10 +257,26 @@ Element firstElement } else if (info.field.FieldType == ScheduleFieldType.Instance) { + // All shared parameters also use this type, regardless of whether they are instance or type parameters. + // ref: https://www.revitapidocs.com/2024/9888db7d-00d0-4fd7-a1a9-cdd1fb5fce16.htm if (firstElement != null) { param = firstElement.get_Parameter(builtInParameter); - columnMetadata["IsReadOnly"] = param?.IsReadOnly; + + // if the parameter is shared, we need to check the type parameterer too + if (firstType != null) + { + Parameter typeParam = firstType.get_Parameter(builtInParameter); + + // If the parameter is readonly in the element but not in the type, is a type parameter + if (typeParam != null && !typeParam.IsReadOnly && param != null && param.IsReadOnly) + { + columnMetadata["IsReadOnly"] = false; + fieldType = ScheduleFieldType.ElementType.ToString(); + } + } + + columnMetadata["IsReadOnly"] ??= param?.IsReadOnly ?? true; } } else @@ -273,6 +289,8 @@ Element firstElement info.field.FieldType.ToString() ); } + + columnMetadata["FieldType"] = fieldType; speckleTable.DefineColumn(columnMetadata); }