protected override void SolveInstance(IGH_DataAccess DA) { Types.ParameterKey parameter = null; if (!DA.GetData("ParameterKey", ref parameter)) { return; } if (Enum.IsDefined(typeof(BuiltInParameter), parameter.Value.IntegerValue)) { var builtInParameter = (BuiltInParameter)parameter.Value.IntegerValue; DA.SetData("Name", LabelUtils.GetLabelFor(builtInParameter)); DA.SetData("StorageType", Revit.ActiveDBDocument.get_TypeOfStorage(builtInParameter)); DA.SetData("Visible", true); DA.SetData("Guid", Guid.Empty); } else if (Revit.ActiveDBDocument.GetElement(parameter.Value) is ParameterElement parameterElement) { var definition = parameterElement.GetDefinition(); DA.SetData("Name", definition?.Name); DA.SetData("StorageType", definition?.ParameterType.ToStorageType()); DA.SetData("Visible", definition?.Visible); DA.SetData("Guid", (parameterElement as SharedParameterElement)?.GuidValue ?? Guid.Empty); } }
protected override void TrySolveInstance(IGH_DataAccess DA) { Types.ParameterKey parameterKey = null; if (!DA.GetData("ParameterKey", ref parameterKey)) { return; } if (parameterKey.Value.TryGetBuiltInParameter(out var builtInParameter)) { DA.SetData("Name", DB.LabelUtils.GetLabelFor(builtInParameter)); DA.SetData("StorageType", parameterKey.Document?.get_TypeOfStorage(builtInParameter)); DA.SetData("Class", DBX.ParameterClass.BuiltIn); DA.SetData("Guid", null); } else if (parameterKey.Document?.GetElement(parameterKey.Value) is DB.ParameterElement parameterElement) { var definition = parameterElement.GetDefinition(); DA.SetData("Name", definition?.Name); DA.SetData("StorageType", definition?.ParameterType.ToStorageType()); if (parameterElement is DB.SharedParameterElement shared) { DA.SetData("Class", DBX.ParameterClass.Shared); DA.SetData("Guid", shared.GuidValue); } else { DA.SetData("Guid", null); if (parameterElement is DB.GlobalParameter) { DA.SetData("Class", DBX.ParameterClass.Global); } else { switch (parameterElement.get_Parameter(DB.BuiltInParameter.ELEM_DELETABLE_IN_FAMILY).AsInteger()) { case 0: DA.SetData("Class", DBX.ParameterClass.Family); break; case 1: DA.SetData("Class", DBX.ParameterClass.Project); break; } } } } }
protected override void SolveInstance(IGH_DataAccess DA) { Types.ParameterKey parameterKey = null; if (!DA.GetData("ParameterKey", ref parameterKey)) { return; } if (parameterKey.Value.TryGetBuiltInParameter(out var builtInParameter)) { DA.SetData("Name", LabelUtils.GetLabelFor(builtInParameter)); DA.SetData("StorageType", parameterKey.Document?.get_TypeOfStorage(builtInParameter)); DA.SetData("Visible", true); DA.SetData("Guid", null); } else if (parameterKey.Document?.GetElement(parameterKey.Value) is ParameterElement parameterElement) { var definition = parameterElement.GetDefinition(); DA.SetData("Name", definition?.Name); DA.SetData("StorageType", definition?.ParameterType.ToStorageType()); DA.SetData("Visible", definition?.Visible); DA.SetData("Guid", (parameterElement as SharedParameterElement)?.GuidValue ?? null); } }