Skip to content

Update roomSvgExporter.py #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions revitAPI/roomSvgExporter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'''
ROOM SVG EXPORTER - EXPORT A SINGLE LEVELS ROOM BOUNDARIES
ROOM OR SPACE SVG EXPORTER - EXPORT A SINGLE LEVELS ROOM OR SPACE BOUNDARIES
-
a dynamoPython script, visit the website for more details
https://github.com/Amoursol/dynamoPython
Expand All @@ -10,7 +10,7 @@
__version__ = '1.0.1'

'''
for large projects with lots of room data it is useful to analyse in
for large projects with lots of room or space data it is useful to analyse in
a business inteligence or data visualisation tool such as ms power bi.
To visualise rooms in power bi they can be cnoverted to svg and read
with the synoptic panel in power bi. This script collects rooms for a
Expand Down Expand Up @@ -46,6 +46,8 @@
FilterDoubleRule, FilterNumericGreater, LogicalAndFilter, \
ModelPathUtils, ParameterValueProvider, SpatialElement, \
SpatialElementBoundaryOptions, SpatialElementBoundaryLocation
# added ElementCategoryFilter class so elements can be filtered by category - JPS
from Autodesk.Revit.DB import ElementCategoryFilter
# to create svg of areas instead of rooms import the room filter
# so that rooms can be filtered instead of areas
from Autodesk.Revit.DB.Architecture import RoomFilter
Expand Down Expand Up @@ -74,6 +76,10 @@
# which can then be used to find the name of the level
levelInput = IN[0]
levelName = levelInput.Name
# added category input so elements can be filtered by category - JPS
categoryInput = IN[1]
# added directory input so SVG can be saved to desired location - JPS
directoryInput = IN[2]

# the units of room boundary curves will need to be scaled so that
# they display suitable as pixles in the svg
Expand Down Expand Up @@ -196,6 +202,14 @@ def ListChopUnevenly(chopList, chopLengths) :
# filter elements by the unwrapped level id
levelFilter = ElementLevelFilter(levelUnwrappedId)

# added categoryFilter so elements can be filtered by category - JPS
# unwrap the category selected from the dynamo node
categoryUnwrapped = UnwrapElement(categoryInput)
# get the Id of the category
categoryUnwrappedId = categoryUnwrapped.Id
# filter elements by the unwrapped category id
categoryFilter = ElementCategoryFilter(categoryUnwrappedId)

# alias areaFilter, for areas (not rooms) we will want to exclude
areaFilter = AreaFilter()
# change to room filter if you want svg of areas not rooms
Expand All @@ -208,11 +222,15 @@ def ListChopUnevenly(chopList, chopLengths) :
# create empty set and list to store elements in
element_set = ElementSet()
excludes = List[ElementId]()

# added list of filters that can be used with LogicalAndFiler below - JPS
filterList = [levelFilter, categoryFilter, filterArea0]
# check if there are any areas to exclude
if len(areaExcludes) == 0 :
# if there are no areas to exclude then
# filter for levelFilter and filterArea0
filters = LogicalAndFilter(levelFilter, filterArea0)
#filters = LogicalAndFilter(levelFilter, filterArea0)
filters = LogicalAndFilter(filterList)
# otherwise if there are areas to exclude
else:
# for each item in areaExcludes
Expand All @@ -229,8 +247,11 @@ def ListChopUnevenly(chopList, chopLengths) :
afterExclusion = ExclusionFilter(excludes)
# include levelFilter and afterExclusion
filtLevExc = LogicalAndFilter(levelFilter, afterExclusion)
# include categoryFilter and afterExclusion
filtCatExc = LogicalAndFilter(categoryFilter, afterExclusion)
# include previous filters and filterArea0
filters = LogicalAndFilter(filtLevExc, filterArea0)
#filters = LogicalAndFilter(filtLevExc, filterArea0)
filters = LogicalAndFilter(filterList)

# create empty list to store room numbers in
roomNumbers = []
Expand Down Expand Up @@ -506,7 +527,9 @@ def ListChopUnevenly(chopList, chopLengths) :

# save the svg to the same folder as the revit file
# include the level name in the svg file name
svgPath = docPathFolder + levelName + ' - rooms.svg'
#svgPath = docPathFolder + levelName + ' - rooms.svg'
# assemble svgPath with user selected destination - JPS
svgPath = directoryInput + '/' + levelName + ' - rooms.svg'
# use try to allow a message to be displayed if fails
try :
# use with so that file does not need to be manually closed
Expand Down