Ejemplo n.º 1
0
def ExecuteWindow(_doc):
    # TO DO: create filter if not active 3D view
    current_view = Get3DView(_doc)

    if not isinstance(current_view, DB.View3D):
        print("Please run in 3D view where you can see all Windows")

    cat_filters = [
        DB.ElementCategoryFilter(DB.BuiltInCategory.OST_Windows),
        DB.ElementCategoryFilter(DB.BuiltInCategory.OST_Doors),
        DB.ElementCategoryFilter(DB.BuiltInCategory.OST_Walls)
    ]

    cat_filter = DB.LogicalOrFilter(List[DB.ElementFilter](cat_filters))

    elements = DB.FilteredElementCollector(_doc) \
        .WherePasses(cat_filter) \
        .WhereElementIsNotElementType() \
        .ToElementIds()

    windows = DB.FilteredElementCollector(_doc) \
        .OfCategory(DB.BuiltInCategory.OST_Windows) \
        .WhereElementIsNotElementType() \
        .ToElements()

    # filter nested by not hosted on wall - MAYBE BETTER FILTER
    # this bugs out for some reason on a live project - I added a Type Comment filter, still not good maybe :/
    phpp_win = [
        w for w in windows if _doc.GetElement(w.GetTypeId()).get_Parameter(
            DB.BuiltInParameter.ALL_MODEL_TYPE_COMMENTS).AsString() == "Panel"
    ]
    nested_win = [w for w in windows if not isinstance(w.Host, DB.Wall)]
    host_wall = [w.Host for w in windows if isinstance(w.Host, DB.Wall)]

    if len(phpp_win) == 0:
        print("No panels with Type Comment = 'Panel' found.")

    # with revit.TransactionGroup('Populate Thermal Bridge Values'):
    #     win = revit.pick_element("pick a window") # Keep for visual debugging
    #     PopulateIntersection(win, elements, current_view)

    counter = 0
    max_value = len(phpp_win)

    elements = [
        e for e in elements if "Default" not in _doc.GetElement(e).Name
    ]

    with ProgressBar(cancellable=True, step=1) as pb:
        with DB.TransactionGroup(_doc, 'Populate Thermal Bridge Values') as tg:
            tg.Start()
            for win in phpp_win:
                if pb.cancelled:
                    break
                else:
                    PopulateIntersection(win, elements, current_view, _doc)
                    pb.update_progress(counter, max_value)
                    counter += 1
            tg.Assimilate()
Ejemplo n.º 2
0
def get_elements_by_category(element_bicats, elements=None, doc=None):
    # if source elements is provided
    if elements:
        return [x for x in elements
                if get_builtincategory(x.Category.Name)
                in element_bicats]

    # otherwise collect from model
    cat_filters = [DB.ElementCategoryFilter(x) for x in element_bicats]
    elcats_filter = \
        DB.LogicalOrFilter(framework.List[DB.ElementFilter](cat_filters))
    return DB.FilteredElementCollector(doc or HOST_APP.doc)\
             .WherePasses(elcats_filter)\
             .WhereElementIsNotElementType()\
             .ToElements()
Ejemplo n.º 3
0
	for e in listConv:
		refArray.Append(DB.Reference(e))
	return refArray

# Function to create reference line for dimension
def refLine(grids):
	start = grids[0].Curve.GetEndPoint(0)
	end = grids[1].Curve.GetEndPoint(0)
	line = DB.Line.CreateBound(start, end)
	return line
	
# Get current view
view = doc.ActiveView

# Select all grids by filter
gridsFilter = DB.ElementCategoryFilter(DB.BuiltInCategory.OST_Grids)
gridsCollector = DB.FilteredElementCollector(doc).WherePasses(gridsFilter).WhereElementIsNotElementType()

# Convert gridsCollector into list and split them into parallel groups
grids = list(gridsCollector)
gridGroups = {}
excludedGrids = []
# Loop through all grids
for grid in grids:
	gridName = grid.LookupParameter("Name").AsString()
	gridCurve = grid.Curve
	# Check if grid is already classified
	if gridName not in excludedGrids:
		# Check if the rest of the grids are parallel 
		for g in grids:
			inter = gridCurve.Intersect(g.Curve)
Ejemplo n.º 4
0

           


#新規にレビット立ち上げ時に、updater生成
updater = sampleUpdater(HOST_APP.addin_id)

#既に登録されているUpdaterがあったら、UpdaterRegistryをアンレジスター
if DB.UpdaterRegistry.IsUpdaterRegistered(updater.GetUpdaterId()):
    DB.UpdaterRegistry.UnregisterUpdater(updater.GetUpdaterId())
    
#UpdaterRegistryを登録
DB.UpdaterRegistry.RegisterUpdater(updater)

#フック対象エレメントにパーツを指定
elements_filter = DB.ElementCategoryFilter(DB.BuiltInCategory.OST_PointClouds, True)
#全ての変更タイプを取得
change_type = DB.Element.GetChangeTypeAny()
#追加変更タイプを取得
additional_type = DB.Element.GetChangeTypeElementAddition()
#変更トリガー登録
DB.UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), elements_filter, change_type)
#追加トリガー登録
DB.UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), elements_filter, additional_type)

#DocumentChangedハンドラー取得
HOST_APP.app.DocumentChanged += \
        framework.EventHandler[DB.Events.DocumentChangedEventArgs](
        updater.docchanged_eventhandler
        )
Ejemplo n.º 5
0
                                   location_pt, direction_right)

    PopulateThermalValue(_win, "up", up)
    PopulateThermalValue(_win, "down", down)
    PopulateThermalValue(_win, "left", left)
    PopulateThermalValue(_win, "right", right)


# TO DO: create filter if not active 3D view
current_view = revit.active_view

if not isinstance(current_view, DB.View3D):
    print("Please run in 3D view where you can see all Windows")

cat_filters = [
    DB.ElementCategoryFilter(DB.BuiltInCategory.OST_Windows),
    DB.ElementCategoryFilter(DB.BuiltInCategory.OST_Doors),
    DB.ElementCategoryFilter(DB.BuiltInCategory.OST_Walls)
]

cat_filter = DB.LogicalOrFilter(List[DB.ElementFilter](cat_filters))

elements = DB.FilteredElementCollector(revit.doc) \
    .WherePasses(cat_filter) \
    .WhereElementIsNotElementType() \
    .ToElementIds()

windows = DB.FilteredElementCollector(revit.doc) \
    .OfCategory(DB.BuiltInCategory.OST_Windows) \
    .WhereElementIsNotElementType() \
    .ToElements()
                self.value7 = self.textboxDiv7.Text
                self.value8 = self.textboxDiv8.Text
                self.value9 = self.textboxDiv9.Text
                self.value10 = self.textboxDiv10.Text
                self.finalValue = [
                    self.value, self.value1, self.value2, self.value3,
                    self.value4, self.value5, self.value6, self.value7,
                    self.value8, self.value9, self.value10
                ]
                self.Close()
            except:
                self.Close()


# Select all doors
doorsFilter = DB.ElementCategoryFilter(DB.BuiltInCategory.OST_Doors)
doorsCollector = DB.FilteredElementCollector(doc).WherePasses(
    doorsFilter).WhereElementIsNotElementType().ToElements()

# Create set of Room Name
roomNames = sorted(
    list(
        set([
            d.LookupParameter("Room Name").AsString() for d in doorsCollector
        ])))

# Create form to select doors by Room Name
roomNameDoors = forms.SelectFromList.show(
    roomNames,
    "Select Rooms with Doors to Add Parameters",
    600,
Ejemplo n.º 7
0
from pyrevit import forms

# Store current document into variable
doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument

# Select opened documents to transfer View Templates
selProject = forms.select_open_docs(
    title="Select project/s to transfer View Templates",
    button_name='OK',
    width=500,
    multiple=True,
    filterfunc=None)

# Filter Views
viewsFilter = DB.ElementCategoryFilter(DB.BuiltInCategory.OST_Views)


# Function to retrieve View Templates
def retrieveVT(docList, currentDoc):
    storeDict = {}
    if isinstance(docList, list):
        for pro in docList:
            viewsCollector = DB.FilteredElementCollector(pro).WherePasses(
                viewsFilter)
            for view in viewsCollector:
                if view.IsTemplate == True:
                    storeDict[view.Name + " - " + pro.Title] = view
    elif currentDoc == True:
        viewsCollector = DB.FilteredElementCollector(docList).WherePasses(
            viewsFilter)