def AnnotationSymbolCheck(doc): collector = FilteredElementCollector(doc) instances = collector.OfClass(FamilySymbol) name = [] for i in instances: cate = i.Category.Name if cate == 'Generic Annotations' or 'Symbol' in cate or 'Tag' in cate or 'Annotation' in cate: name.append([i.Family.Name]) return(name)
def CadImportsbyName(doc, names): collector = FilteredElementCollector(doc) linkInstances = collector.OfClass(ImportInstance) link = [] for i in linkInstances: if str(i.LookupParameter( "Name").AsString()) in names and not i.IsLinked: link.append(i) return link
def CadImportsName(doc): collector = FilteredElementCollector(doc) linkInstances = collector.OfClass(ImportInstance) linkName = [] for i in linkInstances: name = str(i.LookupParameter("Name").AsString()) if not name in linkName and not i.IsLinked: linkName.append(name) return linkName
def _list_sheets(self): open_doc = self._get_linked_model_doc() if open_doc: cl_sheets = FilteredElementCollector(open_doc) sheetsnotsorted = cl_sheets.OfClass(clr.GetClrType( ViewSheet)).WhereElementIsNotElementType().ToElements() linked_sheets = sorted(sheetsnotsorted, key=lambda x: x.SheetNumber) self.linkedsheets_lb.ItemsSource = linked_sheets
def _find_linked_models(self): cl = FilteredElementCollector(doc) all_linked_models = cl.OfClass( clr.GetClrType(RevitLinkType)).ToElements() self.linked_models = [ lm for lm in all_linked_models if RevitLinkType.IsLoaded(doc, lm.Id) ] self.linkedmodels_lb.ItemsSource = self.linked_models self.linkedmodels_lb.SelectedIndex = 0
def shake_filled_regions(view): vcl = FilteredElementCollector(doc).OwnedByView(view.Id) fregions = vcl.OfClass(clr.GetClrType(FilledRegion)).WhereElementIsNotElementType().ToElements() print('Shaking Filled Regions in: {}'.format(view.ViewName)) for i, fr in enumerate(fregions): with Transaction(doc, 'Shake FilledRegion #{}'.format(i)) as t: t.Start() fr.Location.Move(XYZ(0.01, 0, 0)) fr.Location.Move(XYZ(-0.01, 0, 0)) t.Commit()
def collect_curtain_panels(): doc = DocumentManager.Instance.CurrentDBDocument collector = FilteredElementCollector(doc) collector.OfCategory(BuiltInCategory.OST_CurtainWallPanels) collector.OfClass(FamilyInstance) cw_element_collector = collector.GetElementIdIterator() cw_element_collector.Reset() cw_collector = (doc.GetElement(cw_id) for cw_id in cw_element_collector) return tuple(cw.ToDSType(True) for cw in cw_collector if cw.Symbol.Family.Name == 'System Panel')
def CadImportsCheck(doc): docLink = [] collector = FilteredElementCollector(doc) linkInstances = collector.OfClass(ImportInstance) linkName, linkPin = [], [] for i in linkInstances: linkName.append(str(i.Id.IntegerValue)) try: linkPin.append(str(i.Pinned)) except: linkPin.append("Error") count = 0 for i in linkName: line = [] line.append(linkName[count]) line.append(linkPin[count]) docLink.append(line) count += 1 return docLink
def get_elems_by_builtinCategory(cls, built_in_cat, include=[], active_view=None): """Получение элемента по встроенному классу.""" if not include: if not active_view: els = FilteredElementCollector(doc).OfCategory(built_in_cat) else: els = FilteredElementCollector(doc, active_view).\ OfCategory(built_in_cat) return els.ToElements() if include: new_list = [] for i in include: if not active_view: els = FilteredElementCollector(doc).OfCategory( built_in_cat) else: els = FilteredElementCollector(doc, active_view).\ OfCategory(built_in_cat) new_list += els.OfClass(i).ToElements() return new_list
def _get_sheet_index_list(self): cl_schedules = FilteredElementCollector(doc) schedules = cl_schedules.OfClass(clr.GetClrType( ViewSchedule)).WhereElementIsNotElementType().ToElements() return [sched for sched in schedules if self._is_sheet_index(sched)]
gridsIntersection = [] # Create IntersectionArray object interRes = clr.Reference[IntersectionResultArray]() # Check for intersections and append grids names as pairs and intersection points for gC in gridsColumn: for gR in gridsRow: inter = gC.Curve.Intersect(gR.Curve, interRes) gCName = gC.LookupParameter("Name").AsString() gRName = gR.LookupParameter("Name").AsString() gridsPair.append((gCName, gRName)) gridsIntersection.append(interRes.Item[0].XYZPoint) # Select family to place in intersections markingSymbol = FilteredElementCollector(doc).OfCategory( BuiltInCategory.OST_GenericModel) markingSymbol.OfClass(FamilySymbol).ToElements() familyToPlace = markingSymbol.FirstElement() for element in markingSymbol: if element.FamilyName == "CoG": cogSymbol = element # Place families in the intersection grids for point in gridsIntersection: familyPlaced = doc.Create.NewFamilyInstance( point, familyToPlace, Structure.StructuralType.NonStructural) print(gridsIntersection)
def PositionCheck(doc): modelLst = [] line = ['Shared Point'] # Survey Point survey = [] base = [] outProjBasePt = [] outProjSurvPt = [] outProjLoc = [] ft2mm = 304.8 coll = FilteredElementCollector(doc) basePt = coll.OfClass(BasePoint).ToElements() for e in basePt: a = e.Category.Name if a == "Project Base Point": outProjBasePt.append('Project Base Point"') pbpEW = e.LookupParameter("E/W") pbpNS = e.LookupParameter("N/S") pbpElev = e.LookupParameter("Elev") pbpAngle = e.LookupParameter("Angle to True North") outProjBasePt.append(str(round(pbpEW.AsDouble(), 6))) outProjBasePt.append(str(round(pbpNS.AsDouble(), 6))) outProjBasePt.append(str(round(pbpElev.AsDouble(), 6))) outProjBasePt.append(str(round(pbpAngle.AsDouble() * 180 / math.pi, 6))) outProjBasePt.append('N/A') outProjBasePt.append('N/A') outProjBasePt.append('N/A') elif a == "Survey Point": outProjSurvPt.append('Project Survey Point') pspEW = e.LookupParameter("E/W") pspNS = e.LookupParameter("N/S") pspElev = e.LookupParameter("Elev") outProjSurvPt.append(str(round(pspEW.AsDouble(), 6))) outProjSurvPt.append(str(round(pspNS.AsDouble(), 6))) outProjSurvPt.append(str(round(pspElev.AsDouble(), 6))) outProjSurvPt.append('N/A') outProjSurvPt.append('N/A') outProjSurvPt.append('N/A') outProjSurvPt.append('N/A') projLoc = doc.ActiveProjectLocation origin = XYZ(0.0, 0.0, 0.0) projPos = projLoc.get_ProjectPosition(origin) if projPos == None: outProjLoc.append("No Project Position at origin point") else: outProjLoc.append(round(projPos.EastWest * ft2mm, 6)) outProjLoc.append(round(projPos.NorthSouth * ft2mm, 6)) modelLst.append(outProjBasePt) modelLst.append(outProjSurvPt) # Shared Point shared = () SharedPoint = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Site).ToElements() for i in SharedPoint: try: if 'Shared' in i.Name: shared = i except: pass try: location = LocationShift(doc,shared.Location.Point) line.append(str(location.X)) line.append(str(location.Y)) line.append(str(location.Z)) line.append('N/A') if shared.Pinned == True: line.append('Pinned') else: line.append('Not Pinned') discipline = shared.LookupParameter('Discipline').AsString() line.append(discipline) workset = shared.LookupParameter('Workset').AsValueString() line.append(workset) except: line.append('Error') line.append('Error') line.append('Error') line.append('N/A') line.append('Error') line.append('Error') line.append('Error') modelLst.append(line) return modelLst
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 FilteredElementCollector, BuiltInCategory, Element, ElementType uidoc = __revit__.ActiveUIDocument doc = __revit__.ActiveUIDocument.Document vps = [] cl_views = FilteredElementCollector(doc) vptypes = cl_views.OfClass(ElementType).ToElements() for type in vptypes: if type.FamilyName == 'Viewport': print('ID: {1}TYPE: {0}'.format( Element.Name.GetValue(type), str(type.Id).ljust(10), ))
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 """ __doc__ = 'Exports all original imported images to user desktop.' import os.path as op from Autodesk.Revit.DB import FilteredElementCollector, Element, ImageType uidoc = __revit__.ActiveUIDocument doc = __revit__.ActiveUIDocument.Document selection = [ doc.GetElement(elId) for elId in __revit__.ActiveUIDocument.Selection.GetElementIds() ] destDir = op.expandvars('%userprofile%\\desktop') cl = FilteredElementCollector(doc) list = cl.OfClass(ImageType).ToElements() for el in list: image = el.GetImage() imageName = op.basename(el.Path) # imageName = Element.Name.GetValue( el ) print('EXPORTING: {0}'.format(imageName)) image.Save(op.join(destDir, imageName))
''' Copyright (c) 2014-2016 Ehsan Iran-Nejad Python scripts for Autodesk Revit 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 FilteredElementCollector, FamilySymbol, Element, ElementType doc = __revit__.ActiveUIDocument.Document cl = FilteredElementCollector(doc) list = cl.OfClass(ElementType) for f in list: print(Element.Name.GetValue(f), ElementType.FamilyName.GetValue(f))
import clr uidoc = __revit__.ActiveUIDocument doc = __revit__.ActiveUIDocument.Document tobeDeleted = set() try: location = doc.PathName modelPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(location) transData = TransmissionData.ReadTransmissionData(modelPath) externalReferences = transData.GetAllExternalFileReferenceIds() cl = FilteredElementCollector(doc) impInstances = list( cl.OfClass(clr.GetClrType(ImportInstance)).ToElements()) for refId in externalReferences: lnk = doc.GetElement(refId) extRef = transData.GetLastSavedReferenceData(refId) path = ModelPathUtils.ConvertModelPathToUserVisiblePath( extRef.GetPath()) if isinstance(lnk, RevitLinkType): print('REMOVING REVIT LINK\nID: {1}\tADDRESS: {0}\n'.format( path, refId)) # tobeDeleted.append( refId ) tobeDeleted.add(lnk.Id.IntegerValue) elif isinstance(lnk, CADLinkType): for inst in impInstances: if inst.GetTypeId() == refId and not inst.IsLinked: impType = doc.GetElement(inst.GetTypeId())
'Revisions', 'Revision Clouds', 'Sheets', 'System Categories', 'System Postable Commands', 'Worksets', ]), 'List elements of type:').pickCommandSwitch() if selected_switch is not '': __window__.Show() else: __window__.Close() if selected_switch == 'Graphic Styles': cl = FilteredElementCollector(doc) gstyles = [i for i in cl.OfClass(GraphicsStyle).ToElements()] for gs in gstyles: if gs.GraphicsStyleCategory.Parent: parent = gs.GraphicsStyleCategory.Parent.Name else: parent = '---' if gs.GraphicsStyleCategory.GetHashCode() > 0: print('NAME: {0} CATEGORY:{2} PARENT: {3} ID: {1}'.format( gs.Name.ljust(50), gs.Id, gs.GraphicsStyleCategory.Name.ljust(50), parent.ljust(50))) elif selected_switch == 'Grids': cl = FilteredElementCollector(doc) list = cl.OfCategory( BuiltInCategory.OST_Grids).WhereElementIsNotElementType().ToElements()
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 FilteredElementCollector, GraphicsStyle, Transaction doc = __revit__.ActiveUIDocument.Document cl = FilteredElementCollector(doc) list = [i for i in cl.OfClass(GraphicsStyle).ToElements()] for gs in list: if gs.GraphicsStyleCategory.Parent: parent = gs.GraphicsStyleCategory.Parent.Name else: parent = '---' if gs.GraphicsStyleCategory.GetHashCode() > 0: print('NAME: {0} CATEGORY:{2} PARENT: {3} ID: {1}'.format( gs.Name.ljust(50), gs.Id, gs.GraphicsStyleCategory.Name.ljust(50), parent.ljust(50), ))
printmanager = doc.PrintManager printmanager.PrintRange = PrintRange.Select viewsheetsetting = printmanager.ViewSheetSetting # Collect selected views myviewset = ViewSet() for elId in uidoc.Selection.GetElementIds(): el = doc.GetElement(elId) if isinstance(el, View): myviewset.Insert(el) if myviewset.IsEmpty: TaskDialog.Show('pyRevit', 'At least one view must be selected.') else: # Collect existing sheet sets cl = FilteredElementCollector(doc) viewsheetsets = cl.OfClass(clr.GetClrType(ViewSheetSet)).WhereElementIsNotElementType().ToElements() allviewsheetsets = {vss.Name: vss for vss in viewsheetsets} with Transaction(doc, 'Created Print Set') as t: t.Start() # Delete existing matching sheet set if sheetsetname in allviewsheetsets.keys(): viewsheetsetting.CurrentViewSheetSet = allviewsheetsets[sheetsetname] viewsheetsetting.Delete() # Create new sheet set viewsheetsetting.CurrentViewSheetSet.Views = myviewset viewsheetsetting.SaveAs(sheetsetname) t.Commit()
def _find_linked_models(self): cl = FilteredElementCollector(doc) self.linked_models = cl.OfClass( clr.GetClrType(RevitLinkType)).ToElements() self.linkedmodels_lb.ItemsSource = self.linked_models self.linkedmodels_lb.SelectedIndex = 0
def FindFilledRegions(document, viewId): collector = FilteredElementCollector(document, viewId) return collector.OfClass(FilledRegion)
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 """ __doc__ = 'List all detail groups that include a text element inside them. This is helpful for spell checking.' import clr from Autodesk.Revit.DB import FilteredElementCollector, BuiltInCategory, Element, Group, GroupType, Transaction, \ BuiltInParameter, TextNote uidoc = __revit__.ActiveUIDocument doc = __revit__.ActiveUIDocument.Document cl = FilteredElementCollector(doc) grps = list(cl.OfClass(clr.GetClrType(Group)).ToElements()) grpTypes = set() for g in grps: mems = g.GetMemberIds() for el in mems: mem = doc.GetElement(el) if isinstance(mem, TextNote): grpTypes.add(g.GroupType.Id) for gtId in grpTypes: print(Element.Name.GetValue(doc.GetElement(gtId)))
''' Copyright (c) 2014-2016 Ehsan Iran-Nejad Python scripts for Autodesk Revit 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 FilteredElementCollector, Family doc = __revit__.ActiveUIDocument.Document cl = FilteredElementCollector(doc) list = [i for i in cl.OfClass(Family).ToElements()] for family in list: print('NAME: {0} CATEGORY: {1}'.format( family.Name.ljust(50), family.FamilyCategory.Name.ljust(15)))
''' Copyright (c) 2014-2016 Ehsan Iran-Nejad Python scripts for Autodesk Revit 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 ''' __doc__ = 'Lists all sketch planes in this model.' from Autodesk.Revit.DB import FilteredElementCollector, SketchPlane, Transaction doc = __revit__.ActiveUIDocument.Document cl = FilteredElementCollector(doc) list = [i for i in cl.OfClass(SketchPlane).ToElements()] for gs in list: print('NAME: {0} ID: {1}'.format(gs.Name.ljust(50), gs.Id))
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 ''' __window__.Close() from Autodesk.Revit.DB import FilteredElementCollector, ElementId, BuiltInCategory, TextNote, Group from System.Collections.Generic import List uidoc = __revit__.ActiveUIDocument doc = __revit__.ActiveUIDocument.Document cl = FilteredElementCollector(doc) list = cl.OfClass(TextNote).WhereElementIsNotElementType().ToElements() selSet = [] for el in list: selSet.append(el.Id) uidoc.Selection.SetElementIds(List[ElementId](selSet))