I'd like to set the parameter "Define Thermal Properties by" of window and door families to the value "User Defined".
Actually I only know how to get the parameter:
FamilyParameter familyParameter = familyManager.get_Parameter(BuiltInParameter.ANALYTICAL_DEFINE_THERMAL_PROPERTIES_BY);
I assume that I have to set it via an elementId:
familyManager.Set(familyParameter, elementId);
But where to get the Id for "User Defined"?
I suggest you explore the parameter data type and the possible values that it can take via RevitLookup or some other database exploration tools. The parameter StorageType specifies what type of data can be store in it:
None | None represents an invalid storage type. This value should not be used. |
Integer | The internal data is stored in the form of a signed 32 bit integer. |
Double | The data will be stored internally in the form of an 8 byte floating point number. |
String | The internal data will be stored in the form of a string of characters. |
ElementId | The data type represents an element and is stored as the id of the element. |
Unfortunately, some parameters have the storage type None. in that case, the data that they contain cannot be accessed via API, only by internal Revit methods. In that case, there is normally some BIM constraint driving the value, or a more complex user interface widget that cannot be represented by any of the simple storage types.
To expand on @jeremy_tammik and as relates directly to your question:
You know how to get the parameter. Use that to query the parameter to determine what value type it contains. You will find that your assumption as to it being an ElementId is incorrect. This suprized me as well as I also expected that it would return as an ElementId and expected the User defined option to end up being the "InvalidElementId" of -1.
It is, in fact, an Integer (Revit 2023, haven't checked to see if they changed that type from 32 bit to 64 bit but this info should get you headed in the right direction).
0 = Building Type
1 = Schematic Type
2 = User Defined
I don't know if it can be reset since setting it to a value outside of these could have unexpected consequences so they may have it defined in such a way as to prevent it being changed outside of the UI.
-G
Can't find what you're looking for? Ask the community or share your knowledge.