What is the recommended way to access a parameter by its GUID? get_Parameter(...) accepts a GUID but its successor LookupParameter(...) doesn't anymore.
Regards,
Thomas Schmidt
|
What is the recommended way to access a parameter by its GUID? get_Parameter(...) accepts a GUID but its successor LookupParameter(...) doesn't anymore.
Regards,
Thomas Schmidt
Apparently only Shared Parameters have GUIDs. According to the Revit 2016 SDK help, you use this static method which returns a SharedParameterElement:
SharedParameterElement SharedParameterElement.Lookup(Guid)
Element.get_Parameter(System.Guid guid) is still there. Element.LookupParameter(string name) replace Element.get_Parameter(string name) because you can have multiple shared parameters with the same name (but different Guids) coming from different shared parameter files.
According to Revit 2016 SDK definition:
Parameter.GUID is "The Guid for a shared parameter"
ParameterElement is "User Defined parameter which includes Shared and non-Shared parameters"
But this element does not have a GUID property.
SharedParameterElement inherits from ParameterElement
SharedParameterElement is defined as "An element that stores the definition of a shared parameter which is loaded into the document"
This means that SharedParameterElement is a subset of the ParameterElement objects and thus GUID can be an additional property specific to Shared Parameters Elements only.
The Parameter.get_Element is not documented, and is probably being phased out.
To make a story short and to answer the question "what is best practice to get a parameter from Guid", you should use this method:
SharedParameterElement.Lookup(Guid)
I'm supposing that non-shared parameters (user defined and built-in) don't have Guids, as this is what the SDK documentation says. Also I checked using the RevitLookup Addin to read the Guid property of a parameter within Revit and it gives the following message in the value of the Guid: "Parameter is not shared parameter."
See attached screenshot.
2017-03-22 21_13_18-Snoop Parameters.png
There are 2 types of parameters and ID strings. (type and instance) (guid and a 6 number value)