def find_rebar_capture_ifc(self, elements): elements = List[ElementId]([i.Id for i in elements]) for host in self.hosts: elements_fec = FilteredElementCollector(self.doc, elements) bb = host.Geometry[self.opt_1].GetBoundingBox() filtered = BoundingBoxIntersectsFilter(Outline(bb.Min, bb.Max)) rebars = elements_fec.WherePasses(filtered).ToElements() for rebar in rebars: all_reb_solids = self.get_solids(rebar) host_is_found = False for rebar_solid in all_reb_solids: if host_is_found: break for host_solid in self.get_solids(host): if host_is_found: break try: union_solid = BooleanOperationsUtils.\ ExecuteBooleanOperation( rebar_solid, host_solid, BooleanOperationsType.Union) sum_area = rebar_solid.SurfaceArea +\ host_solid.SurfaceArea -\ union_solid.SurfaceArea except: sum_area = 1 if sum_area > 0.0001: host_is_found = True rebar.LookupParameter("Номер захватки").\ Set(host.LookupParameter("Номер захватки").\ AsString())
def find_rebar_capture_system(self, elements): """ Находим захватки системной арматуры. """ # hosts = List[ElementId]([i.Id for i in self.hosts]) elements = List[ElementId]([i.Id for i in elements]) for host in self.hosts: elements_fec = FilteredElementCollector(self.doc, elements) bb = host.Geometry[self.opt_1].GetBoundingBox() filtered = BoundingBoxIntersectsFilter(Outline(bb.Min, bb.Max)) rebars = elements_fec.WherePasses(filtered).ToElements() for rebar in rebars: host_is_found = False for host_solid in self.get_solids(host, opt=self.opt_2): if host_is_found: break if isinstance(host_solid, Solid): cur_line = next(iter(rebar.Geometry[self.opt_1])) if host_solid.\ IntersectWithCurve(cur_line, None).\ SegmentCount: rebar.LookupParameter("Номер захватки").\ Set(host.LookupParameter("Номер захватки").AsString()) host_is_found = True
mod_min_pt = XYZ(min_bound_val.X + 0.0000000000001, min_bound_val.Y, min_bound_val.Z) mod_max_pt = XYZ(max_bound_val.X - 0.0000000000001, max_bound_val.Y, max_bound_val.Z) # print(min_bound_val, max_bound_val, mod_min_pt, mod_max_pt) testBB = BoundingBoxXYZ() testBB.Min = mod_min_pt testBB.Max = mod_max_pt try: c = Outline(testBB.Min, testBB.Max) d = BoundingBoxIntersectsFilter(c, float(0)) e = collector.WherePasses(d).ToElements() setlist = [] hostlist = [] hostlist.append(h) setlist.append(e) all_lists = [hostlist, setlist] f = reduce(operator.add, all_lists) superset.append(f) except: superset.append('failed') # print(superset) # ################################################################################################# # activeV = doc.ActiveView
fnrv = FilterStringEquals() fRule = FilterStringRule(pvp, fnrv, values[count], True) elif 'Interger' in str(i.StorageType): fnrv = FilterNumericEquals() fRule = FilterIntegerRule(pvp, fnrv, int(values[count])) elif 'Double' in str(i.StorageType): fnrv = FilterNumericEquals() fRule = FilterDoubleRule(pvp, fnrv, float(values[count]), 0.001) elif 'ElementId' in str(i.StorageType): fnrv = FilterNumericEquals() fRule = FilterElementIdRule(pvp, fnrv, ElementId(int(values[count]))) fRules.append(fRule) count += 1 # Filter all elements based on parameter values selected paramFilters = ElementParameterFilter(fRules) ele = filter.WherePasses(paramFilters).ToElements() elements = [] for i in ele: elements.append(i) # Task Dialogue Creation dialog = TaskDialog('Warning') dialog.CommonButtons = TaskDialogCommonButtons.Ok dialog.DefaultButton = TaskDialogResult.Ok dialog.Title = 'Warning' dialog.MainInstruction = 'You are about to select ' + str( len(elements)) + ' elements' bool = dialog.Show() if str(bool) == 'Ok': revit.get_selection().set_to(elements) else:
This file is part of pyRevit repository at https://github.com/eirannejad/pyRevit pyRevit is a free set of scripts for Autodesk Revit: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. See this link for a copy of the GNU General Public License protecting this package. https://github.com/eirannejad/pyRevit/blob/master/LICENSE ''' from Autodesk.Revit.DB import ElementMulticategoryFilter, FilteredElementCollector, BuiltInCategory from System.Collections.Generic import List doc = __revit__.ActiveUIDocument.Document #lists all sketch based objects as: # ModelLine/ModelArc/ModelEllipse/... <Sketch> #lists all sketch based detail objects as: # DetailLines/DetailArc/DetailEllipse/... whatever_style_type_it_has filter = ElementMulticategoryFilter( List[BuiltInCategory]([BuiltInCategory.OST_Lines, BuiltInCategory.OST_SketchLines])) cl = FilteredElementCollector(doc) cllines = cl.WherePasses( filter ).WhereElementIsNotElementType().ToElements() for c in cllines: print( '{0:<10} {1:<25}{2:<8} {3:<15} {4:<20}'.format(c.Id, c.GetType().Name, c.LineStyle.Id, c.LineStyle.Name, c.Category.Name ) )
def WorksetElements(doc, workset): elementCollector = FilteredElementCollector(doc) elementWorksetFilter = ElementWorksetFilter(workset.Id, False) worksetElemsfounds = elementCollector.WherePasses( elementWorksetFilter).ToElements() return worksetElemsfounds
ueWrapper = None wrappers = clr.GetClrType(Revit.Elements.ElementWrapper).GetMethods() for w in wrappers: if w.ToString().startswith("Revit.Elements.UnknownElement"): ueWrapper = w break if cat is not None: catId = List[ElementId]() for c in tolist(cat): catId.Add(c.Id) catFil = ElementMulticategoryFilter(catId) else: catFil = None for v in views: fec = FilteredElementCollector(doc, v.Id).WhereElementIsNotElementType() if catFil is not None: fec = fec.WherePasses(catFil) viewEl = [] for e in fec: try: viewEl.append(e.ToDSType(True)) except: if ueWrapper: viewEl.append(ueWrapper.Invoke(None, (e, True))) OUT.append(viewEl) fec.Dispose() if catFil is not None: catFil.Dispose()
from Autodesk.Revit.DB import Workset, FilteredWorksetCollector, WorksetKind, FilteredElementCollector, ElementWorksetFilter, Element from Autodesk.Revit.UI import TaskDialog from pprint import pprint uidoc = __revit__.ActiveUIDocument doc = __revit__.ActiveUIDocument.Document cl = FilteredWorksetCollector(doc) worksetlist = cl.OfKind(WorksetKind.UserWorkset) if doc.IsWorkshared: for ws in worksetlist: elementCollector = FilteredElementCollector( doc).WhereElementIsNotElementType() elementWorksetFilter = ElementWorksetFilter(ws.Id, False) els = elementCollector.WherePasses(elementWorksetFilter).ToElements() print('WORKSET: {0} ID: {1} COUNT: {2}'.format(ws.Name.ljust(50), ws.Id, len(els))) els_array = {} for e in els: t = e.GetType().ToString() if t not in els_array.keys(): els_array[t] = [] els_array[t].append(str(e.Id)) # # print(",".join(els_array.keys)) # print("\n") for k in els_array.keys(): print(k, len(els_array[k]))
alliter = [] geo_options = Options() geo_options.ComputeReferences = False geo_options.IncludeNonVisibleObjects = False # for i in items1: # ids.append(i.Id) #endregion #region main итерации, что-то можно заменить на генераторы списков для TransactionManager.Instance.EnsureInTransaction(doc) for i1 in items1: geomSolid = get_geometys(i1) if geomSolid != None: for ost in catIdlist: elems = FilteredElementCollector(doc,i_list_ids).OfCategoryId(ost).WhereElementIsNotElementType() elems_solid_filter = [] elems_solid_filter.append(elems.WherePasses(ElementIntersectsSolidFilter(geomSolid)).ToElements()) els_sol_fil_flat = flatten_List(elems_solid_filter) for els in els_sol_fil_flat: if els.Id.ToString() == i1.Id.ToString(): pass else: if JoinGeometryUtils.AreElementsJoined(doc,els,i1): pass else: results += join(els,i1) TransactionManager.Instance.ForceCloseTransaction() #endregion else: results = 0 #region разделение геометрии items1 = flatten_List(elements)
report('Finding Line Styles using Method 1...') linesCat = doc.Settings.Categories.get_Item("Lines") for cat in linesCat.SubCategories: if 'SW' == cat.Name[:2]: catsToDelete.append(cat) # COLLECT CATS - METHOD 2 report('Finding Line Styles using Method 2...') from Autodesk.Revit.DB import ElementMulticategoryFilter, FilteredElementCollector, BuiltInCategory from System.Collections.Generic import List emcfilter = ElementMulticategoryFilter( List[BuiltInCategory]([BuiltInCategory.OST_Lines])) cl = FilteredElementCollector(doc) cllines = list( cl.WherePasses(emcfilter).WhereElementIsNotElementType().ToElements()) styleIds = cllines[0].GetLineStyleIds() for styleId in styleIds: style = doc.GetElement(styleId) cat = style.GraphicsStyleCategory if 'SW' == cat.Name[:2]: catsToDelete.append(cat) # DELETE CATS total = len(catsToDelete) report('Deleting {0} Line Styles...'.format(total)) report('Deleted Line Styles:') step = 1 / 50.0 threshold = step t = Transaction(doc, 'Delete all SW Lines')
cl = FilteredElementCollector(doc) fregions = cl.OfClass(clr.GetClrType(FilledRegion)).WhereElementIsNotElementType().ToElements() for fr in fregions: fr.Location.Move(XYZ(0.01, 0, 0)) fr.Location.Move(XYZ(-0.01, 0, 0)) try: fromStyle, toStyle = get_styles() line_list = [] cl = FilteredElementCollector(doc) elfilter = ElementMulticategoryFilter(List[BuiltInCategory]([BuiltInCategory.OST_Lines, BuiltInCategory.OST_SketchLines])) detail_lines = cl.WherePasses(elfilter).WhereElementIsNotElementType().ToElements() for detail_line in detail_lines: if detail_line.LineStyle.Name == fromStyle.Name: line_list.append(detail_line) with Transaction(doc, 'Swap Line Styles') as t: t.Start() for line in line_list: if line.Category.Name != '<Sketch>' and line.GroupId < ElementId(0): line.LineStyle = toStyle elif line.Category.Name == '<Sketch>': line.LineStyle = toStyle elif line.GroupId > ElementId(0): logger.debug('Skipping grouped line: {} in group {}'.format(line.Id, line.GroupId))
__author__ = 'MEOS' __title__ = 'CountWindows' from Autodesk.Revit.DB import FilteredElementCollector, ElementCategoryFilter, BuiltInCategory doc = __revit__.ActiveUIDocument.Document collector = FilteredElementCollector(doc) filter = ElementCategoryFilter(BuiltInCategory.OST_Windows) windows = collector.WherePasses( filter).WhereElementIsNotElementType().ToElements() print("Window counted is: {}".format(windows.Count))
component = [ Label('Enter Parameter Name:'), TextBox('textbox1', Text="CheckBalcony"), Label('Enter Room Name:'), TextBox('textbox2', Text="Balcony"), Separator(), Label('Nguyen Khanh Tien - [email protected]'), Button('Select') ] form = FlexForm('Check Parameter Value', component) form.show() paraname = form.values['textbox1'] name = form.values['textbox2'] RmFilter = RoomFilter() collector = FilteredElementCollector(doc) collector.WherePasses(RmFilter) roomIdItr = collector.GetElementIdIterator() roomIdItr.Reset() t = Transaction(doc, "Check Parameter Value") t.Start() print("Checking...") while (roomIdItr.MoveNext()): roomId = roomIdItr.Current room = doc.GetElement(roomId) rmname = room.LookupParameter("Name").AsString() checkbal = room.LookupParameter(paraname) if (name in rmname): checkbal.Set(True) else: checkbal.Set(False)