revitron.parameter¶
Besides the element
and the filter
submodules,
this submodule is one of the most elementary submodules of the Revitron package.
It contains all classes related to parameters, built-in parameters and value providers.
Classes:
A helper class for mapping lists of built-in parameter names to their representation visible to the user. |
|
|
A wrapper class for interacting with element parameters. |
A helper class for listing all parameter names in the active document. |
|
|
Create a string based on a parameter template where parameter names are wrapped in |
A collection of static parameter utilities. |
|
|
A wrapper for parameter value providers used for filtering elements. |
- class BuiltInParameterNameMap[source]¶
Bases:
object
A helper class for mapping lists of built-in parameter names to their representation visible to the user.
Methods:
__init__
()Inits a new BuiltInParameterNameMap instance.
get
(name)Return the list of matching built-in parameters for a given name.
- class Parameter(element, name)[source]¶
Bases:
object
A wrapper class for interacting with element parameters.
Note
In most cases it is not required to actually create a Parameter class instance in order to access paramter values of a given element. The fastest way of getting or setting parameter values is using the
_(element).get('parameter')
shortcut function or an instance of the revitron.element class.Methods:
__init__
(element, name)Init a new parameter instance.
exists
()Checks if a parameter exists.
get
()Return the parameter value.
Return the parameter value as double.
Return the parameter value as ElementId.
Return the parameter value as integer.
Return the parameter value as string.
Return the parameter value as value string.
hasValue
()Checks if parameter has a value.
set
(value[, paramType])Set a parameter value for an element.
Attributes:
The definition parameter type.
The displayed unit type of a parameter.
- __init__(element, name)[source]¶
Init a new parameter instance.
Getting a parameter by name visible to the user:
value = revitron.Parameter(element, 'parameterName').get()
Or the short version:
value = _(element).get('parameterName')
To be language independent it is possible to get a parameter value by its built-in parameter name like for example the view scale:
scale = _(view).get('VIEW_SCALE')
- Parameters
element (object) – Revit element
name (string) – The parameter name or the name of a built-Iin parameter
- property definitionType¶
The definition parameter type.
- Returns
The definition parameter type name
- Return type
string
- get()[source]¶
Return the parameter value.
Note
As mentioned above, the fastest way of getting a parameter value is to use the get method of the
revitron.Element
class.- Returns
The value
- Return type
mixed
- getElementId()[source]¶
Return the parameter value as ElementId.
- Returns
The value
- Return type
object
- getValueString()[source]¶
Return the parameter value as value string.
- Returns
The value
- Return type
string
- hasValue()[source]¶
Checks if parameter has a value.
- Returns
True if the parameter has a value
- Return type
boolean
- set(value, paramType=False)[source]¶
Set a parameter value for an element. The parameter will be automatically created if not existing. The parameter type can be specified. If not type is given, it will be determined automatically in case of text, integer or float values.
Note
As mentioned above, the fastest way of setting a parameter value is to use the set method of the
revitron.Element
class.Example:
_(element).set('name', 'value', 'type')
Some possible parameter types are:
Text
Integer
Number
Length
Angle
Material
YesNo
MultilineText
FamilyType
You can find a list of all types here.
- Parameters
value (string) – The value
paramType (string, optional) – The parameter type
- property unit¶
The displayed unit type of a parameter.
Note that since Revit 2021 the preferred return value is of type
ForgeTypeId
.- Returns
The displayed unit type (ForgeTypeId or DisplayUnitType)
- Return type
mixed
- class ParameterNameList[source]¶
Bases:
object
A helper class for listing all parameter names in the active document.
Methods:
__init__
()Inits a new ParameterNameList instance including all parameter names in the document.
get
()Returns the parameter list.
- class ParameterTemplate(element, template, sanitize=True)[source]¶
Bases:
object
Create a string based on a parameter template where parameter names are wrapped in
{...}
and get substituted with their value:This sheet has the number {Sheet Number}
It is also possible to get parameter values from the project information instead by wrapping the parameter names in
{%...%}
instead:This sheet of the project {%Project Name%} has the number {Sheet Number}
Methods:
__init__
(element, template[, sanitize])Inits a new ParameterTemplate instance.
reCallback
(match)The callback function used by the
get()
method.render
()Returns the rendered template string.
- __init__(element, template, sanitize=True)[source]¶
Inits a new ParameterTemplate instance.
- Parameters
element (object) – A Revit element
template (string) – A template string
sanitize (bool, optional) – Optionally sanitize the returned string. Defaults to True.
- class ParameterUtils[source]¶
Bases:
object
A collection of static parameter utilities.
Methods:
bind
(category, paramName[, paramType, ...])Bind a new parameter to a category.
externalDefinitionCreationOptions
(paramName, ...)Create proper definition creation options based on a given name and type, that is passed as string.
getParameterTypeFromDefinition
(definition)Get the parameter type as string from a definition.
getStorageType
(name)Get the storage type of a parameter definition by name.
- static bind(category, paramName, paramType='Text', typeBinding=False)[source]¶
Bind a new parameter to a category.
- Parameters
category (string) – The built-in category
paramName (string) – The parameter name
paramType (string) –
The parameter type (see here) Defaults to “Text”.
typeBinding (bool) – Bind parameter to type instead of instance. Defaults to False.
- Returns
Returns True on success and False on error.
- Return type
boolean
- static externalDefinitionCreationOptions(paramName, paramType)[source]¶
Create proper definition creation options based on a given name and type, that is passed as string.
- Parameters
paramName (string) – The name of the parameter definition
paramType (string) – The name of the type
- Returns
The ExternalDefinitionCreationOptions object
- Return type
ExternalDefinitionCreationOptions
- class ParameterValueProviders(name)[source]¶
Bases:
object
A wrapper for parameter value providers used for filtering elements.
Methods:
__init__
(name)Inits a new ParameterValueProviders instance by name.
get
()Returns the list of value providers.
- __init__(name)[source]¶
Inits a new ParameterValueProviders instance by name. Such an instance consists of a list of value providers matching a parameters with a name visible to the user. Note that this list can have more than one value provider, since a parameter name possible matches multiple built-in parameters.
- Parameters
name (string) – Name