-1

Please tell me how to change the ShouldHideWhenNoValue parameter in the SharedParameter loaded in the project.

var collector = new FilteredElementCollector(doc).OfClass(typeof(SharedParameterElement)).WhereElementIsNotElementType().Cast<SharedParameterElement>().FirstOrDefault(gp => gp.GuidValue.Equals(ADSK.Tolshina_Stenki));
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • Sorry, I do not understand what you would like to achieve. You can create a new shared parameter, but you cannot change an existing non-shared parameter into a shared one. Furthermore, the Revit API only supports the same functionality as the user interface, so it will help to research how to achieve the desired result in the UI, and what best practices to follow in doing so. I hope this helps, even without understanding your task. – Jeremy Tammik Jul 24 '23 at 07:42
  • Hi @JeremyTammik! Sorry for my English, I am from Ukraine and I translate my question with translator. I wanted to use ClearValue Method for Shared parameters, but it works when those have their HideWhenNoValue property set to true. I wanted to know if there is any way to change this property using Revit Api or if it can only be changed in the Shared parameters text file. – MrVoLaNd Jul 27 '23 at 10:30

1 Answers1

0

Thank you for your further explanation in your comment. I was previously unaware of this functionality. Prompted by your explanation, I found it in the What's New in the Revit 2020 API section on Hiding empty parameters:

The new property

  • ExternalDefinition.HideWhenNoValue

Indicates if the shared parameter should be hidden from the property palette and Element.GetOrderedParameters() when it has no value.

Similar functionality has been added to other classes:

  • ExternalDefinitionCreationOptions.HideWhenNoValue
  • SharedParameterElement.ShouldHideWhenNoValue()

The new method:

  • Parameter.ClearValue()

can reset the value of a shared parameter which has the HideWhenNoValue flag set back to a cleared state. (This method is not applicable to clear the value of any other parameter type).

Jeremy Tammik
  • 7,333
  • 2
  • 12
  • 17