Last active
September 15, 2024 16:16
-
-
Save zeffii/14c9d65c6e3bb0cfd0bf6f9601ff32a4 to your computer and use it in GitHub Desktop.
pyrevit shell scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
PyRevit | |
Final Checklist | |
[x] list all levels in the current doc | |
[x] name and | |
[x] level value | |
[x] associated with any plan view? | |
[x] list all plan views | |
[x] crop region enabled? | |
[x] crop region visible? | |
[x] list all elevation views | |
[ ] if they have a earth hatch region | |
[ ] if they do, is it 150 below 0.0 or G.F. ? | |
[ ] do all views* have a view template assigned? | |
* except user 3d views and non capitalized Views. | |
[ ] hide off all reference planes in all views. | |
''' | |
from Autodesk.Revit.DB import BuiltInCategory as Bic | |
from Autodesk.Revit.DB import FilteredElementCollector as Fec | |
import Autodesk.Revit.DB as DB | |
def feet_to_meters(feet): | |
return round(feet * 0.3048 * 1000, 5) | |
def checkReferencePlanes(doc): | |
print("---- ref planes: ----") | |
refPlaneCollector = (Fec(doc).OfClass(DB.ReferencePlane).ToElements()) | |
for idx, refPlane in enumerate(refPlaneCollector): | |
print(f"idx: {idx}, name: {refPlane.Name}, ID {refPlane.Id}") | |
def checkLevels(doc): | |
print("---- levels: ---- ") | |
levelCollector = (Fec(doc).OfClass(DB.Level).ToElements()) | |
plan_view_ids = [] | |
for idx, level in enumerate(levelCollector): | |
associated_plan = level.FindAssociatedPlanViewId().IntegerValue | |
assoc_comment = "No Associated Plan" if associated_plan == -1 else f"associated plan: {associated_plan}" | |
height = feet_to_meters(level.Elevation) | |
print(f"idx: {idx}, name: {level.Name}, ID {level.Id}, Elevation: {height} {assoc_comment}") | |
if associated_plan >= 0: | |
plan_view_ids.append(level.FindAssociatedPlanViewId()) | |
return plan_view_ids | |
def displayPlanViewDetails(doc, plan_view_ids): | |
# print(plan_view_ids) | |
for view_id in plan_view_ids: | |
level_ref = doc.GetElement(view_id) | |
active = "[x]" if level_ref.CropBoxActive else "[ ]" | |
visible = "[x]" if level_ref.CropBoxVisible else "[ ]" | |
print(f"plan name: {level_ref.Name}, crop box: {active}, visible: {visible}") | |
def check_hatches_in_elevation_views(doc): | |
elevationCollector = (Fec(doc).OfClass(DB.Level).ToElements()) | |
info = "ViewType enumeration: Elevation Elevation type of view." | |
Elevation = DB.ViewType.Elevation | |
views = (Fec(doc).OfClass(DB.View).ToElements()) | |
elevation_views = {} | |
for view in views: | |
if view.ViewType == Elevation: | |
if view.Name in {'Architectural Elevation', 'Architectural Section'}: | |
... | |
else: | |
elevation_views[view.Name] = view | |
for k, v in elevation_views.items(): | |
print(f"{k} {v}") | |
if k == 'North': | |
subs = v.GetDependentElements(filter=None) | |
''' | |
Part_type=typeof(part)#making the part type | |
filter=ElementClassFilter(Part_type)#making the filter#making the filter | |
Part_List=List[ElementId]()#making the part list receiver | |
PartList.Add(GetDependentelElements(filter)) #getting parts ids | |
subs = views[5].GetDependentElements(filter=DB.ElementClassFilter(DB.FilledRegion)) | |
''' | |
for element in subs: | |
elem = doc.GetElement(element) | |
if elem.GetType() == DB.FilledRegion: | |
# region = elem | |
# region.GetBoundaries() | |
# region.GetSubelements() | |
print(f' region {elem}') | |
# List[CurveLoop]([<Autodesk.Revit.DB.CurveLoop object at 0x000000000000013B | |
# [Autodesk.Revit.DB.CurveLoop]>]) | |
checkReferencePlanes(doc) | |
plan_view_ids = checkLevels(doc) | |
displayPlanViewDetails(doc, plan_view_ids) | |
check_hatches_in_elevation_views(doc) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment