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
''' Create a text annotation element. | |
Does not include start/commit transaction.''' | |
def create_text(view, text, point, align): | |
"""Creates a Revit Text. | |
create_test(view, text_string, point) | |
view: view object to insert text | |
text: text to be inserted | |
point: insertion point - XYZ() instance | |
align: 'left', 'right', or 'center' |
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
from Autodesk.Revit.DB import Phase, FilteredElementCollector | |
def get_phase_by_name(phase_name): | |
phase_collector = FilteredElementCollector(doc).OfClass(Phase) | |
for phase in phase_collector: | |
if phase.Name.Equals(phase_name): | |
return phase | |
phase = get_phase_by_name('01 - Existing') | |
print phase.Name |
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
from Autodesk.Revit.DB import Element, FilteredElementCollector | |
from Autodesk.Revit.DB import FilledRegionType, FilledRegion | |
def fregion_id_by_name(name=None): | |
"""Get Id of Filled Region Type by Name. | |
Loops through all types, tries to match name. | |
If name not supplied, first type is used. | |
If name supplied does not match any existing types, last type is used | |
""" |
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
""" | |
Crop Image | |
Crops an Image to a Filled Region Boundary | |
TESTED REVIT API: 2015 | |
Copyright (c) 2014-2016 Gui Talarico | |
github.com/gtalarico | |
This script is part of PyRevitPlus: Extensions for PyRevit | |
github.com/gtalarico/pyrevitplus |
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
""" | |
Make Floors | |
Create Floors from Selected Rooms | |
TESTED REVIT API: 2015 | |
Gui Talarico | |
github.com/gtalarico | |
""" | |
import sys |
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
uidoc = __revit__.ActiveUIDocument | |
def get_selected_elements(): | |
"""Return Selected Elements as a list[]. Returns empty list if no elements are selected. | |
Usage: | |
- Select 1 or more elements | |
> selected_elements = get_selected_elements() | |
> [<Autodesk.Revit.DB.FamilyInstance object at 0x0000000000000034 [Autodesk.Revit.DB.FamilyInstance]>] | |
""" | |
selection = uidoc.Selection |
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
# Import Image | |
# http://www.revitapidocs.com/2015/05c3dbe2-fe7e-c293-761d-b11f356a011b.htm | |
from clr import StrongBox | |
from Autodesk.Revit.DB import XYZ, ImageImportOptions, BoxPlacement, BuiltInParameter | |
# Import Options | |
import_options = ImageImportOptions() | |
import_options.Placement = BoxPlacement.Center | |
import_options.RefPoint = XYZ(0,0,0) |
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
# http://stackoverflow.com/questions/1855095/how-to-create-a-zip-archive-of-a-directory | |
import os | |
import zipfile | |
import hashlib | |
import time | |
def zipdir(path, ziph): | |
for root, dirs, files in os.walk(path): | |
if '.git' not in root: | |
for file in files: |
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
""" | |
CycleType | |
Cycle through available types in family manager | |
TESTED REVIT API: 2015 | |
github.com/gtalarico | |
""" | |
__doc__ = 'Cycles through available types in family manager. \n' \ | |
'Must be in Family Document.' |
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
import logging | |
import sys | |
class LoggerWrapper(): | |
""" Logger Wrapper to extend loggers functionality. | |
Usage: | |
logger = LoggerWrapper() | |
Additional Features: | |
logger.title('Message'): Outputs lines above and below, uses clean format | |
logger.error('Message'): appends errmsg to self.errors. |