Skip to content
Merged
Show file tree
Hide file tree
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
29 changes: 29 additions & 0 deletions 0-python-code/HowTo_RotateToReference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""
Function for rotating an element based on rotation of another element.

TESTED REVIT API: 2016, 2017

Author: Jared Friedman | github.com/jbf1212

This file is shared on www.revitapidocs.com
For more information visit http://github.com/gtalarico/revitapidocs
License: http://github.com/gtalarico/revitapidocs/blob/master/LICENSE.md
"""
from Autodesk.Revit.DB import Line, XYZ

# Works for point-based elements
# Assumes rotations in XY plane
# Function should be called within a Transaction

def rotate_to_ref(ref_element, transform_element):
"""Match rotation between a reference element and an element to rotate"""
try:
orientation_angle = ref_element.Location.Rotation
ref_location = ref_element.Location.Point
except Exception as errmsg:
print('Could not get element Rotation or Point')
print('Error: {}'.format(errmsg))

rot_ang = orientation_angle - transform_element.Location.Rotation
rot_axis = Line.CreateBound(ref_location, XYZ(ref_location.X, ref_location.Y, ref_location.Z+1.0))
transform_element.Location.Rotate(rot_axis, rot_ang)
35 changes: 35 additions & 0 deletions 0-python-code/HowTo_SelectUnboundRooms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
Selects unbound rooms in model

TESTED REVIT API: 2015, 2016, 2017

Author: Jared Friedman | github.com/jbf1212

This file is shared on www.revitapidocs.com
For more information visit http://github.com/gtalarico/revitapidocs
License: http://github.com/gtalarico/revitapidocs/blob/master/LICENSE.md
"""
from Autodesk.Revit.DB import Transaction, Element
from Autodesk.Revit.DB import FilteredElementCollector
from Autodesk.Revit.UI import TaskDialog
from System.Collections.Generic import List

uidoc = __revit__.ActiveUIDocument
doc = __revit__.ActiveUIDocument.Document

# GET ALL ROOMS IN MODEL
rooms = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms)
ub_rooms = []

for r in rooms:
if r.Area > 0:
pass
else:
ub_rooms.append(r)

# SELECT UNBOUND ROOMS
collection = List[ElementId]([r.Id for r in ub_rooms])
selection = uidoc.Selection
selection.SetElementIds(collection)

TaskDialog.Show('Unbound Rooms', "{} unbound rooms selected". format(len(ub_rooms)))