Assembly

AssemblyInstance

class rpw.db.AssemblyInstance(element, doc=None)

Bases: rpw.db.element.Element, rpw.utils.mixins.CategoryMixin

DB.AssemblyInstance Wrapper

Attribute:
_revit_object (DB.AssemblyInstance): Wrapped DB.AssemblyInstance
category

Wrapped DB.Category

classmethod collect(**kwargs)

Collect all elements of the wrapper using the default collector. This method is defined on the main Element wrapper, but the collector parameters are defined in each wrapper. For example, WallType uses the _collector_params: {‘of_class’: DB.WallType, ‘is_type’: True}

These default collector parameters can be overriden by passing keyword args to the collectors call.

>>> from rpw import db
>>> wall_types_collector = db.WallType.collect()
<rpw:Collector % FilteredElementCollector [count:4]>
>>> wall_types_collector.get_elements()  # All Wall Types
[<rpw:WallType [name:Wall 1] [id:1557]>, ... ]
>>> wall_types_collector.get_elements()
[<rpw:Area % DB.Area | Rentable:30.2>]
>>> rooms = db.WallInstance.collect(level="Level 1")
[<rpw:WallInstance % DB.Wall symbol:Basic Wall>]
delete()

Deletes Element from Model

get_category(wrapped=True)

Wrapped DB.Category

get_elements(wrapped=True)

Get other elements inside parent assembly.

Returns:other elements inside the assembly
name

Name Property

symbol

Alias to AssemblyInstance.type

type

Get’s Element Type using the default GetTypeId() Method. For some Elements, this is the same as element.Symbol or wall.WallType

Parameters:doc (DB.Document, optional) – Document of Element [default: revit.doc]
Returns:Wrapped rpw.db.Element element type
Return type:(Element)
unwrap()

Returns the Original Wrapped Element

AssemblyType

class rpw.db.AssemblyType(element, doc=None)

Bases: rpw.db.family.FamilySymbol, rpw.utils.mixins.CategoryMixin

DB.AssemblyType Wrapper Inherits from Element

Attribute:
_revit_object (DB.AssemblyType): Wrapped DB.AssemblyType
category

Wrapped DB.Category

classmethod collect(**kwargs)

Collect all elements of the wrapper using the default collector. This method is defined on the main Element wrapper, but the collector parameters are defined in each wrapper. For example, WallType uses the _collector_params: {‘of_class’: DB.WallType, ‘is_type’: True}

These default collector parameters can be overriden by passing keyword args to the collectors call.

>>> from rpw import db
>>> wall_types_collector = db.WallType.collect()
<rpw:Collector % FilteredElementCollector [count:4]>
>>> wall_types_collector.get_elements()  # All Wall Types
[<rpw:WallType [name:Wall 1] [id:1557]>, ... ]
>>> wall_types_collector.get_elements()
[<rpw:Area % DB.Area | Rentable:30.2>]
>>> rooms = db.WallInstance.collect(level="Level 1")
[<rpw:WallInstance % DB.Wall symbol:Basic Wall>]
delete()

Deletes Element from Model

family

Wrapped DB.Family of the symbol

Type:Returns
Type:Family
get_category(wrapped=True)

Wrapped DB.Category

get_family(wrapped=True)
Returns:Wrapped DB.Family of the symbol
Return type:Family
get_instances(wrapped=True)
Returns:
List of model instances of
the symbol (unwrapped)
Return type:[DB.FamilyInstance]
get_siblings(wrapped=True)
Returns:
List of symbol Types
of the same Family (unwrapped)
Return type:[DB.FamilySymbol]
name

Name Property

siblings

Returns all assembly types

type

Get’s Element Type using the default GetTypeId() Method. For some Elements, this is the same as element.Symbol or wall.WallType

Parameters:doc (DB.Document, optional) – Document of Element [default: revit.doc]
Returns:Wrapped rpw.db.Element element type
Return type:(Element)
unwrap()

Returns the Original Wrapped Element


Implementation

""" Assembly Wrappers """

from rpw import revit, DB
from rpw.db.element import Element
from rpw.db.family import FamilyInstance, FamilySymbol

from rpw.utils.coerce import to_elements
from rpw.utils.mixins import CategoryMixin


# TODO: Tests
# TODO: Inherit from FamilyInstance Instead

class AssemblyInstance(Element, CategoryMixin):
    """
    `DB.AssemblyInstance` Wrapper

    Attribute:
        _revit_object (DB.AssemblyInstance): Wrapped ``DB.AssemblyInstance``
    """

    _revit_object_class = DB.AssemblyInstance
    _collector_params = {'of_class': _revit_object_class, 'is_type': False}

    @property
    def symbol(self):
        """ Alias to AssemblyInstance.type """
        return self.type

    def get_elements(self, wrapped=True):
        """
        Get other elements inside parent assembly.

        Returns:
            other elements inside the assembly

        """
        member_ids = self._revit_object.GetMemberIds()
        elements = to_elements(member_ids, doc=self._revit_object.Document)
        return [Element(e) if wrapped else e for e in elements]

    def __repr__(self):
        return Element.__repr__(self, data={'name': self.Name})


class AssemblyType(FamilySymbol, CategoryMixin):
    """
    `DB.AssemblyType` Wrapper
    Inherits from :any:`Element`

    Attribute:
        _revit_object (DB.AssemblyType): Wrapped ``DB.AssemblyType``
    """

    _revit_object_class = DB.AssemblyType
    _collector_params = {'of_class': _revit_object_class, 'is_type': True}

    @property
    def siblings(self):
        """ Returns all assembly types """
        return [Element.from_id(t) for t in self._revit_object.GetSimilarTypes()]

    @property
    def instances(self):
        raise NotImplemented
        """ Returns all Instances of the assembly type """
        # bip = BipEnum.get_id('AREA_SCHEME_ID')
        # param_filter = rpw.db.Collector.ParameterFilter(bip, equals=self._revit_object.Id)
        # collector = rpw.db.Collector(parameter_filter=param_filter,
        #                              **Area._collector_params)
        # return collector.wrapped_elements


    def __repr__(self):
        return Element.__repr__(self, data={'name': self.name})