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:

BuiltInParameterNameMap()

A helper class for mapping lists of built-in parameter names to their representation visible to the user.

Parameter(element, name)

A wrapper class for interacting with element parameters.

ParameterNameList()

A helper class for listing all parameter names in the active document.

ParameterTemplate(element, template[, sanitize])

Create a string based on a parameter template where parameter names are wrapped in {...} and get substituted with their value.

ParameterUtils()

A collection of static parameter utilities.

ParameterValueProviders(name)

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.

__init__()[source]

Inits a new BuiltInParameterNameMap instance. The map is a dictionary where the key is a parameter name that is visible to the user and the value is a list of built-in parameters represented by that name.

get(name)[source]

Return the list of matching built-in parameters for a given name.

Parameters

name (string) – The parameter name visible to the user

Returns

The list of built-in parameter ids

Return type

list

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.

getDouble()

Return the parameter value as double.

getElementId()

Return the parameter value as ElementId.

getInteger()

Return the parameter value as integer.

getString()

Return the parameter value as string.

getValueString()

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:

definitionType

The definition parameter type.

unit

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

exists()[source]

Checks if a parameter exists.

Returns

True if existing

Return type

boolean

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

getDouble()[source]

Return the parameter value as double.

Returns

The value

Return type

double

getElementId()[source]

Return the parameter value as ElementId.

Returns

The value

Return type

object

getInteger()[source]

Return the parameter value as integer.

Returns

The value

Return type

integer

getString()[source]

Return the parameter value as string.

Returns

The value

Return type

string

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.

__init__()[source]

Inits a new ParameterNameList instance including all parameter names in the document.

get()[source]

Returns the parameter list.

Returns

The list with all parameters in the document.

Return type

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.

reCallback(match)[source]

The callback function used by the get() method.

Parameters

match (object) – The regex match object

Returns

The processed string

Return type

string

render()[source]

Returns the rendered template string.

Returns

The rendered string

Return type

string

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

static getParameterTypeFromDefinition(definition)[source]

Get the parameter type as string from a definition.

Parameters

definition (object) – The parameter definition

Returns

The name of the type

Return type

string

static getStorageType(name)[source]

Get the storage type of a parameter definition by name.

Parameters

name (string) – The parameter name

Returns

The storage type

Return type

string

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

get()[source]

Returns the list of value providers.

Returns

The list of value providers

Return type

list