Skip to content

db

Revit DB objects wrappers.

Attributes

Classes

BaseWrapper(obj=None)

Bases: object

Base revit databse object wrapper.

Source code in pyrevitlib/pyrevit/revit/db/__init__.py
def __init__(self, obj=None):
    self._wrapped = obj

Functions

unwrap()
Source code in pyrevitlib/pyrevit/revit/db/__init__.py
def unwrap(self):
    return self._wrapped
compare_attr(src, dest, attr_name, case_sensitive=False) staticmethod
Source code in pyrevitlib/pyrevit/revit/db/__init__.py
@staticmethod
def compare_attr(src, dest, attr_name, case_sensitive=False):
    if case_sensitive:
        return safe_strtype(getattr(src, attr_name, '')).lower() == \
               safe_strtype(getattr(dest, attr_name, '')).lower()
    else:
        return safe_strtype(getattr(src, attr_name)) == \
               safe_strtype(getattr(dest, attr_name))
compare_attrs(src, dest, attr_names, case_sensitive=False) staticmethod
Source code in pyrevitlib/pyrevit/revit/db/__init__.py
@staticmethod
def compare_attrs(src, dest, attr_names, case_sensitive=False):
    return [BaseWrapper.compare_attr(src,
                                     dest,
                                     x,
                                     case_sensitive=case_sensitive)
            for x in attr_names]

ElementWrapper(element)

Bases: BaseWrapper

Revit element wrapper.

Source code in pyrevitlib/pyrevit/revit/db/__init__.py
def __init__(self, element):
    super(ElementWrapper, self).__init__(element)
    if not isinstance(self._wrapped, DB.Element):
        raise PyRevitException('Can not wrap object that are not '
                               'derived from Element.')

Attributes

assoc_doc property
name property
symbol_name property
family_name property
id property
unique_id property
workset_id property
mark property
location property
x property
y property
z property

Functions

unwrap()
Source code in pyrevitlib/pyrevit/revit/db/__init__.py
def unwrap(self):
    return self._wrapped
compare_attr(src, dest, attr_name, case_sensitive=False) staticmethod
Source code in pyrevitlib/pyrevit/revit/db/__init__.py
@staticmethod
def compare_attr(src, dest, attr_name, case_sensitive=False):
    if case_sensitive:
        return safe_strtype(getattr(src, attr_name, '')).lower() == \
               safe_strtype(getattr(dest, attr_name, '')).lower()
    else:
        return safe_strtype(getattr(src, attr_name)) == \
               safe_strtype(getattr(dest, attr_name))
compare_attrs(src, dest, attr_names, case_sensitive=False) staticmethod
Source code in pyrevitlib/pyrevit/revit/db/__init__.py
@staticmethod
def compare_attrs(src, dest, attr_names, case_sensitive=False):
    return [BaseWrapper.compare_attr(src,
                                     dest,
                                     x,
                                     case_sensitive=case_sensitive)
            for x in attr_names]
get_param(param_name)
Source code in pyrevitlib/pyrevit/revit/db/__init__.py
def get_param(self, param_name):
    return self._wrapped.LookupParameter(param_name)
safe_get_param(param_name, default=None)
Source code in pyrevitlib/pyrevit/revit/db/__init__.py
def safe_get_param(self, param_name, default=None):
    try:
        return self._wrapped.LookupParameter(param_name)
    except Exception:
        return default

ExternalRef(link, extref)

Bases: ElementWrapper

External reference wraper.

Source code in pyrevitlib/pyrevit/revit/db/__init__.py
def __init__(self, link, extref):
    super(ExternalRef, self).__init__(link)
    self._extref = extref

Attributes

assoc_doc property
symbol_name property
family_name property
id property
unique_id property
workset_id property
mark property
location property
x property
y property
z property
name property
linktype property
path property

Functions

unwrap()
Source code in pyrevitlib/pyrevit/revit/db/__init__.py
def unwrap(self):
    return self._wrapped
compare_attr(src, dest, attr_name, case_sensitive=False) staticmethod
Source code in pyrevitlib/pyrevit/revit/db/__init__.py
@staticmethod
def compare_attr(src, dest, attr_name, case_sensitive=False):
    if case_sensitive:
        return safe_strtype(getattr(src, attr_name, '')).lower() == \
               safe_strtype(getattr(dest, attr_name, '')).lower()
    else:
        return safe_strtype(getattr(src, attr_name)) == \
               safe_strtype(getattr(dest, attr_name))
compare_attrs(src, dest, attr_names, case_sensitive=False) staticmethod
Source code in pyrevitlib/pyrevit/revit/db/__init__.py
@staticmethod
def compare_attrs(src, dest, attr_names, case_sensitive=False):
    return [BaseWrapper.compare_attr(src,
                                     dest,
                                     x,
                                     case_sensitive=case_sensitive)
            for x in attr_names]
get_param(param_name)
Source code in pyrevitlib/pyrevit/revit/db/__init__.py
def get_param(self, param_name):
    return self._wrapped.LookupParameter(param_name)
safe_get_param(param_name, default=None)
Source code in pyrevitlib/pyrevit/revit/db/__init__.py
def safe_get_param(self, param_name, default=None):
    try:
        return self._wrapped.LookupParameter(param_name)
    except Exception:
        return default
reload()
Source code in pyrevitlib/pyrevit/revit/db/__init__.py
def reload(self):
    return self._wrapped.Reload()

ProjectParameter(param_def, param_binding=None, param_ext_def=False)

Bases: BaseWrapper

Project parameter wrapper.

Source code in pyrevitlib/pyrevit/revit/db/__init__.py
def __init__(self, param_def, param_binding=None, param_ext_def=False):
    super(ProjectParameter, self).__init__()
    self.param_def = param_def
    self.param_binding = param_binding
    self.param_binding_type = self._determine_binding_type()

    self.shared = False
    self.param_ext_def = None
    self.param_guid = ''
    if param_ext_def:
        self.shared = True
        self.param_ext_def = param_ext_def
        self.param_guid = self.param_ext_def.GUID.ToString()

    self.name = self.param_def.Name

    # Revit <2017 does not have the Id parameter
    self.param_id = getattr(self.param_def, 'Id', None)

    if HOST_APP.is_exactly(2021):
        # Revit >2021 does not have the UnitType property
        self.unit_type = self.param_def.GetSpecTypeId()
        self.param_type = self.param_def.ParameterType
        self.param_group = self.param_def.ParameterGroup
    elif HOST_APP.is_newer_than(2022, or_equal=True):
        # GetSpecTypeId() Removed in Revit 2022
        self.unit_type = self.param_def.GetDataType()
        # Revit >2022 does not have the ParameterType property
        self.param_type = self.param_def.GetDataType()
        # ParameterGroup deprecated
        self.param_group = self.param_def.GetGroupTypeId().TypeId
    else:
        self.unit_type = self.param_def.UnitType
        self.param_type = self.param_def.ParameterType
        self.param_group = self.param_def.ParameterGroup

Attributes

param_def = param_def instance-attribute
param_binding = param_binding instance-attribute
param_binding_type = self._determine_binding_type() instance-attribute
shared = False instance-attribute
param_ext_def = None instance-attribute
param_guid = '' instance-attribute
name = self.param_def.Name instance-attribute
param_id = getattr(self.param_def, 'Id', None) instance-attribute
unit_type = self.param_def.GetSpecTypeId() instance-attribute
param_type = self.param_def.ParameterType instance-attribute
param_group = self.param_def.ParameterGroup instance-attribute

Functions

unwrap()
Source code in pyrevitlib/pyrevit/revit/db/__init__.py
def unwrap(self):
    return self._wrapped
compare_attr(src, dest, attr_name, case_sensitive=False) staticmethod
Source code in pyrevitlib/pyrevit/revit/db/__init__.py
@staticmethod
def compare_attr(src, dest, attr_name, case_sensitive=False):
    if case_sensitive:
        return safe_strtype(getattr(src, attr_name, '')).lower() == \
               safe_strtype(getattr(dest, attr_name, '')).lower()
    else:
        return safe_strtype(getattr(src, attr_name)) == \
               safe_strtype(getattr(dest, attr_name))
compare_attrs(src, dest, attr_names, case_sensitive=False) staticmethod
Source code in pyrevitlib/pyrevit/revit/db/__init__.py
@staticmethod
def compare_attrs(src, dest, attr_names, case_sensitive=False):
    return [BaseWrapper.compare_attr(src,
                                     dest,
                                     x,
                                     case_sensitive=case_sensitive)
            for x in attr_names]

ProjectInfo(doc)

Bases: BaseWrapper

Project information.

Source code in pyrevitlib/pyrevit/revit/db/__init__.py
def __init__(self, doc):
    super(ProjectInfo, self).__init__()
    self._doc = doc

Attributes

name property
number property
address property
author property
building_name property
client_name property
issue_date property
org_name property
org_desc property
status property
location property
path property
filename property

Functions

unwrap()
Source code in pyrevitlib/pyrevit/revit/db/__init__.py
def unwrap(self):
    return self._wrapped
compare_attr(src, dest, attr_name, case_sensitive=False) staticmethod
Source code in pyrevitlib/pyrevit/revit/db/__init__.py
@staticmethod
def compare_attr(src, dest, attr_name, case_sensitive=False):
    if case_sensitive:
        return safe_strtype(getattr(src, attr_name, '')).lower() == \
               safe_strtype(getattr(dest, attr_name, '')).lower()
    else:
        return safe_strtype(getattr(src, attr_name)) == \
               safe_strtype(getattr(dest, attr_name))
compare_attrs(src, dest, attr_names, case_sensitive=False) staticmethod
Source code in pyrevitlib/pyrevit/revit/db/__init__.py
@staticmethod
def compare_attrs(src, dest, attr_names, case_sensitive=False):
    return [BaseWrapper.compare_attr(src,
                                     dest,
                                     x,
                                     case_sensitive=case_sensitive)
            for x in attr_names]

XYZPoint(obj=None)

Bases: BaseWrapper

Wrapper for XYZ point.

Source code in pyrevitlib/pyrevit/revit/db/__init__.py
def __init__(self, obj=None):
    self._wrapped = obj

Attributes

x property
y property
z property

Functions

unwrap()
Source code in pyrevitlib/pyrevit/revit/db/__init__.py
def unwrap(self):
    return self._wrapped
compare_attr(src, dest, attr_name, case_sensitive=False) staticmethod
Source code in pyrevitlib/pyrevit/revit/db/__init__.py
@staticmethod
def compare_attr(src, dest, attr_name, case_sensitive=False):
    if case_sensitive:
        return safe_strtype(getattr(src, attr_name, '')).lower() == \
               safe_strtype(getattr(dest, attr_name, '')).lower()
    else:
        return safe_strtype(getattr(src, attr_name)) == \
               safe_strtype(getattr(dest, attr_name))
compare_attrs(src, dest, attr_names, case_sensitive=False) staticmethod
Source code in pyrevitlib/pyrevit/revit/db/__init__.py
@staticmethod
def compare_attrs(src, dest, attr_names, case_sensitive=False):
    return [BaseWrapper.compare_attr(src,
                                     dest,
                                     x,
                                     case_sensitive=case_sensitive)
            for x in attr_names]

Functions