Skip to content

Commit

Permalink
Fixed whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
marcantondahmen committed Oct 14, 2020
1 parent 9e334f5 commit 3787974
Show file tree
Hide file tree
Showing 16 changed files with 1,705 additions and 1,705 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
root = true

[*]
indent_style = space
indent_style = tab
indent_size = 4
82 changes: 41 additions & 41 deletions revitron/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@
The following example demonstrates getting a comment of a given element::
import revitron
from revitron import _
comment = _(element).get('Comments')
import revitron
from revitron import _
comment = _(element).get('Comments')
You can find the documentation of more methods to work with elements in the `revitron.element <revitron.element.html>`_ 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 <revitron.filter.html>`_ 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()
import revitron
filter = revitron.Filter
ids = filter().byStringEquals('param', 'value').noTypes().getElementIds()
.. _module:
Expand All @@ -48,27 +48,27 @@
.. data:: DOC
The currently active document.
The currently active document.
.. data:: UIDOC
The active UI document.
The active UI document.
.. data:: APP
A shortcut for accessing the application object of the active document.
A shortcut for accessing the application object of the active document.
.. data:: ACTIVEVIEW
The active view element.
The active view element.
.. data:: DB
A shortcut for ``Autodesk.Revit.DB``.
A shortcut for ``Autodesk.Revit.DB``.
.. data:: LIB_DIR
The path to the **Revitron** library extension directory.
The path to the **Revitron** library extension directory.
.. _function:
"""
Expand Down Expand Up @@ -96,35 +96,35 @@
parent = os.path.dirname

try:
DOC = __revit__.ActiveUIDocument.Document
UIDOC = __revit__.ActiveUIDocument
APP = DOC.Application
ACTIVEVIEW = DOC.ActiveView
DOC = __revit__.ActiveUIDocument.Document
UIDOC = __revit__.ActiveUIDocument
APP = DOC.Application
ACTIVEVIEW = DOC.ActiveView
except:
pass
pass


DB = Autodesk.Revit.DB
LIB_DIR = parent(parent(__file__))


def _(element):
"""
Shorthand function to init a Revitron element instance based on a Revit element category.
Args:
element (object): The Revit element
Returns:
mixed: A Revitron element instance
"""
category = Element(element).getParameter('Category').getValueString()
switcher = {
'RVT Links': LinkRvt,
'Rooms': Room
}
wrapper = switcher.get(category, Element)
return wrapper(element)
"""
Shorthand function to init a Revitron element instance based on a Revit element category.
Args:
element (object): The Revit element
Returns:
mixed: A Revitron element instance
"""
category = Element(element).getParameter('Category').getValueString()
switcher = {
'RVT Links': LinkRvt,
'Rooms': Room
}
wrapper = switcher.get(category, Element)
return wrapper(element)
158 changes: 79 additions & 79 deletions revitron/boundingbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,89 +4,89 @@
"""

class BoundingBox:
"""
A ``BoundingBox`` class instance is a wrapper element for Revit bounding box object.
Create a new instance as follows::
bbox = revitron.BoundingBox(element)
Or even::
bbox = _(element).getBbox()
.. data:: Min
"""
A ``BoundingBox`` class instance is a wrapper element for Revit bounding box object.
Create a new instance as follows::
bbox = revitron.BoundingBox(element)
Or even::
bbox = _(element).getBbox()
.. data:: Min
The Min Revit point object of the bounding box.
.. data:: Max
The Min Revit point object of the bounding box.
.. data:: Max
The Max Revit point object of the bounding box.
"""
Min = None
Max = None
def __init__(self, element):
"""
Inits a new BoundingBox instance for an element.
In case the element has a scope box applied, the scope box's bounding box is taken.
In case the element has no scope box, but is a view plan, the crop box is used.
The default Revit bounding box is used for all other elements.
The Max Revit point object of the bounding box.
"""
Min = None
Max = None
def __init__(self, element):
"""
Inits a new BoundingBox instance for an element.
In case the element has a scope box applied, the scope box's bounding box is taken.
In case the element has no scope box, but is a view plan, the crop box is used.
The default Revit bounding box is used for all other elements.
Args:
element (object): A Revit Element
"""
import revitron
if revitron._(element).get('Scope Box'):
self.bbox = revitron._(revitron._(element).get('Scope Box')).getBbox().bbox
else:
if revitron._(element).getClassName() == 'ViewPlan':
self.bbox = element.CropBox
else:
self.bbox = element.get_BoundingBox(None)
self.Min = self.bbox.Min
self.Max = self.bbox.Max
def containsXY(self, bbox2):
"""
Checks whether the bounding box contains another bounding box. Only in X and Y dimensions.
Args:
element (object): A Revit Element
"""
import revitron
if revitron._(element).get('Scope Box'):
self.bbox = revitron._(revitron._(element).get('Scope Box')).getBbox().bbox
else:
if revitron._(element).getClassName() == 'ViewPlan':
self.bbox = element.CropBox
else:
self.bbox = element.get_BoundingBox(None)
self.Min = self.bbox.Min
self.Max = self.bbox.Max
def containsXY(self, bbox2):
"""
Checks whether the bounding box contains another bounding box. Only in X and Y dimensions.
Example::
contains = _(element1).getBbox().containsXY(_(element2).getBbox())
Args:
bbox2 (object): A bounding box object
Example::
contains = _(element1).getBbox().containsXY(_(element2).getBbox())
Args:
bbox2 (object): A bounding box object
Returns:
boolean: True if the bounding box entirely contains bbox2
"""
import revitron
if isinstance(bbox2, revitron.BoundingBox):
bbox2 = bbox2.bbox
if self.hasPointXY(bbox2.Min) and self.hasPointXY(bbox2.Max):
return True
return False
def hasPointXY(self, point):
"""
Checks whether a point is inside a bounding box. Only in X and Y dimensions.
Returns:
boolean: True if the bounding box entirely contains bbox2
"""
import revitron
if isinstance(bbox2, revitron.BoundingBox):
bbox2 = bbox2.bbox
if self.hasPointXY(bbox2.Min) and self.hasPointXY(bbox2.Max):
return True
return False
def hasPointXY(self, point):
"""
Checks whether a point is inside a bounding box. Only in X and Y dimensions.
Args:
point (object): A point object
Args:
point (object): A point object
Returns:
boolean: True if the bounding box has the point inside
"""
if self.bbox.Min.X <= point.X <= self.bbox.Max.X and self.bbox.Min.Y <= point.Y <= self.bbox.Max.Y:
return True
return False
Returns:
boolean: True if the bounding box has the point inside
"""
if self.bbox.Min.X <= point.X <= self.bbox.Max.X and self.bbox.Min.Y <= point.Y <= self.bbox.Max.Y:
return True
return False

0 comments on commit 3787974

Please sign in to comment.