Developer Guide¶
The Revitron package is a Revit API wrapper written in Python to help you developing clean and powerful Revit plugins in pyRevit. The package consists of a minimal main module and collection of specific submodules covering certain topics of the Revit API.
Concept¶
Basically this package is designed to be a generic Revit API toolbox. It doesn’t focus on a single topic, but tries to combine multiple wrapper classes instead to enable you to create plugins using just one single base library. However, there are two topics that are in the main focus of many pyRevit plugins — working with elements and filtering.
Note
Check out the cheat sheet to get you started quickly with the most common tools.
Working with Elements¶
Revitron elements wrap standard Revit elements and expose additional convenience methods in order to make working with the API a bit less cumbersome:
import revitron
_element = revitron.Element(element)
Alternatively to the default constructor it is also possible to create element instances by using the following shorthand function:
from revitron import _
_element = _(element)
In both cases _element
is a proper Revitron element. This comes in handy in many situations where a quick access to an
element is needed. The following example demonstrates how it is possible to set a parameter value, even though
the parameter itself doesn’t exist yet:
from revitron import _
_(element).set('ParameterName', value)
In that one line we just set a parameter value and also created the parameter if neccessary. In order to get a parameter value of a given element we can use:
from revitron import _
comment = _(element).get('Comments')
You can find the documentation of more available element methods in the revitron.element reference.
Using Filters¶
Besides element properties, filtering is another core functionality of this package. Working with FiteredElementCollector
instances can be quite complex and difficult to debug. Revitron provides a Filter that implements
a powerful tool to also filter the database by parameter values using human readable one-liner:
import revitron
filter = revitron.Filter
ids = filter().byStringEquals('param', 'value').noTypes().getElementIds()
Revitron Module¶
The main Revitron module contains only some global module properties as well as the magic _()
function.
Specific classes are located in the submodules listed below.
- DOC¶
The currently active document.
- UIDOC¶
The active UI document.
- APP¶
A shortcut for accessing the application object of the active document.
- ACTIVE_VIEW¶
The active view element.
- DB¶
A shortcut for
Autodesk.Revit.DB
.
- LIB_DIR¶
The path to the Revitron library extension directory.
- REVIT_VERSION¶
The version number string of the running Revit application.
Subpackages¶
Submodules¶
- revitron.boundingbox
- revitron.category
- revitron.create
- revitron.document
- revitron.element
Element
Element.__getattr__()
Element.__init__()
Element.delete()
Element.element
Element.get()
Element.getBbox()
Element.getCategoryName()
Element.getClassName()
Element.getDependent()
Element.getFamilyAndTypeName()
Element.getFamilyName()
Element.getFromType()
Element.getGeometry()
Element.getParameter()
Element.getTags()
Element.isNotOwned()
Element.isType()
Element.set()
- revitron.excel
- revitron.export
- revitron.externalreference
- revitron.failure
- revitron.filter
Filter
Filter.__init__()
Filter.byCategory()
Filter.byClass()
Filter.byIntersection()
Filter.byNumberIsEqual()
Filter.byNumberIsGreater()
Filter.byNumberIsGreaterOrEqual()
Filter.byNumberIsLess()
Filter.byNumberIsLessOrEqual()
Filter.byOneInCsv()
Filter.byRegex()
Filter.byStringBeginsWith()
Filter.byStringContains()
Filter.byStringContainsOneInCsv()
Filter.byStringEndsWith()
Filter.byStringEquals()
Filter.byStringEqualsOneInCsv()
Filter.getElementIds()
Filter.getElements()
Filter.noTypes()
Filter.onlyTypes()
- revitron.geometry
- revitron.grid
- revitron.link
LinkRvt
LinkRvt.__getattr__()
LinkRvt.__init__()
LinkRvt.delete()
LinkRvt.element
LinkRvt.get()
LinkRvt.getBbox()
LinkRvt.getCategoryName()
LinkRvt.getClassName()
LinkRvt.getDependent()
LinkRvt.getFamilyAndTypeName()
LinkRvt.getFamilyName()
LinkRvt.getFromType()
LinkRvt.getGeometry()
LinkRvt.getParameter()
LinkRvt.getPath()
LinkRvt.getTags()
LinkRvt.getType()
LinkRvt.isNotOwned()
LinkRvt.isType()
LinkRvt.set()
- revitron.parameter
- revitron.raytrace
- revitron.room
Room
Room.__getattr__()
Room.__init__()
Room.delete()
Room.element
Room.get()
Room.getBbox()
Room.getBboxCenter()
Room.getBoundary()
Room.getBoundaryInsetPoints()
Room.getBoundaryPoints()
Room.getCategoryName()
Room.getClassName()
Room.getDependent()
Room.getFamilyAndTypeName()
Room.getFamilyName()
Room.getFromType()
Room.getGeometry()
Room.getParameter()
Room.getPointBottomLeft()
Room.getPointBottomRight()
Room.getPointClosest()
Room.getPointGrid()
Room.getPointTopLeft()
Room.getPointTopRight()
Room.getTags()
Room.isNotOwned()
Room.isType()
Room.set()
Room.traceHeight()
- revitron.roomtag
- revitron.selection
- revitron.transaction
- revitron.transmissiondata
- revitron.unit
- revitron.view