revitron.element

This submodule provides convenient wrappers for the interaction with elements. Getting parameter values or other information can be quite complicated using the plain Revit API. Methods like revitron.Element(element).get(parameter) simplify that process.

Note

Note that there is also the _() shortcut function available to be even more efficient in getting properties of Revit elements. More here

For example getting a parameter value or even a bounding box object works as follows:

form revitron import _
value = _(element).get('parameter')
boundingBox = _(element).getBbox()

Or setting parameter values:

_(element).set('parameter', value)

Classes:

Element(element)

A wrapper class for Revit elements.

class Element(element)[source]

Bases: object

A wrapper class for Revit elements.

Example:

value = revitron.Element(element).get('parameter')

Or in short:

from revitron import _
value = _(element).get('parameter')

Methods:

__getattr__(name)

Define default method to be returned on attribute errors.

__init__(element)

Inits a new element instance.

delete()

Delete an element.

get(paramName)

Returns a parameter value.

getBbox()

Returns a bounding box for the element.

getCategoryName()

Returns the category name of the element.

getClassName()

Returns the class name of the element.

getDependent([filterClass])

Returns a list of dependent elements.

getFamilyAndTypeName()

Returns the family name of the element.

getFamilyName()

Returns the family name of the element.

getFromType(paramName)

Returns a parameter value of the element type.

getGeometry()

Return the Revitron Geometry instance for this element.

getParameter(paramName)

Returns a parameter object.

getTags()

Get possibly existing tags of an element.

isNotOwned()

Checks whether an element is owned by another user.

isType()

Checks whether an element is a type or not.

set(paramName, value[, paramType])

Sets a parameter value.

Attributes:

element

The actual Revit element.

__getattr__(name)[source]

Define default method to be returned on attribute errors.

Since this is a generic element class that is extended by other more specialized classes such as the Room class, a default method along with an error message is returned when accidently calling a special methods that only exists in one of the derived classes on an element of another class.

Parameters

name (string) – The name of the called method

Returns

An empty method

Return type

method

__init__(element)[source]

Inits a new element instance.

Parameters

element (object) – The Revit element or an element ID

delete()[source]

Delete an element.

Example:

_(element).delete()
property element

The actual Revit element.

Returns

The Revit element object

Return type

object

get(paramName)[source]

Returns a parameter value.

Example:

value = _(element).get('name')
Parameters

paramName (string) – The name of the parameter

Returns

The parameter value

Return type

mixed

getBbox()[source]

Returns a bounding box for the element.

Returns

The bounding box or false on error

Return type

object

getCategoryName()[source]

Returns the category name of the element.

Returns

The category name

Return type

string

getClassName()[source]

Returns the class name of the element.

Returns

The class name

Return type

string

getDependent(filterClass=None)[source]

Returns a list of dependent elements.

Parameters

filterClass (class, optional) – An optional class to filter the list of dependent elements by. Defaults to None.

Returns

The list with the dependent Revit elements.

Return type

list

getFamilyAndTypeName()[source]

Returns the family name of the element.

Returns

The family name

Return type

string

getFamilyName()[source]

Returns the family name of the element.

Returns

The family name

Return type

string

getFromType(paramName)[source]

Returns a parameter value of the element type.

Example:

value = _(element).getFromType('name')
Parameters

paramName (string) – The name of the parameter

Returns

The parameter value

Return type

mixed

getGeometry()[source]

Return the Revitron Geometry instance for this element.

Returns

A Revitron Geometry object

Return type

object

getParameter(paramName)[source]

Returns a parameter object.

Parameters

paramName (string) – The name of the parameter

Returns

The parameter object

Return type

object

getTags()[source]

Get possibly existing tags of an element.

Returns

A list of Revit tag objects depending on the element class

Return type

list

isNotOwned()[source]

Checks whether an element is owned by another user.

Returns

True if the element is not owned by another user.

Return type

boolean

isType()[source]

Checks whether an element is a type or not.

Returns

True if element is a type.

Return type

bool

set(paramName, value, paramType=False)[source]

Sets a parameter value.

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
  • paramName (string) – The parameter name

  • value (mixed) – The value

  • paramType (string, optional) – The parameter type. Defaults to ‘Text’.

Returns

The element instance

Return type

object