def get_tasks(user_name, fixme_task_list): doc = __revit__.ActiveUIDocument.Document uidoc = __revit__.ActiveUIDocument jrn_drive = op.abspath(op.splitdrive(doc.Application.RecordingJournalFilename)[0]) disk_space_left(jrn_drive) if fixme_task_list.endswith("ini"): ini_file = fixme_task_list config = ConfigParser() config.read(ini_file) presented_ids = 0 for sec in config.sections(): this_script.output.print_md("**{}**".format(sec)) print("--- list of ids to fix:") for elem in config.items(sec): topic = elem[0] print("--- topic: {0}".format(topic)) for str_id in elem[1].split(","): # print(str_id) elem_id = ElementId(int(str_id.strip())) if doc.GetElement(elem_id): # print(elem_id) this_script.output.print_md("--- " + this_script.output.linkify(elem_id)) presented_ids += 1 if presented_ids == 5: break elif fixme_task_list.endswith(".json"): json_file = fixme_task_list presented_ids = 0 warn_id_dict = read_json_to_dict(json_file) for topic in warn_id_dict: this_script.output.print_md("**{}**".format(topic)) for date in warn_id_dict[topic]: for str_id in warn_id_dict[topic][date]: elem_id = ElementId(int(str_id)) elem = doc.GetElement(elem_id) elem_cat = elem.Category.Name.strip("<>") if elem.ViewSpecific: location = doc.GetElement(elem.OwnerViewId).Name else: location = doc.GetElement(elem.LevelId).Name elem_info = " - {} - {}".format(elem_cat, location) last_changer = WorksharingUtils.GetWorksharingTooltipInfo(doc, elem_id).LastChangedBy if last_changer == user_name: this_script.output.print_md("--- " + this_script.output.linkify(elem_id) + elem_info) this_script.output.print_md("--- " + elem.Category.Name) presented_ids += 1 if presented_ids == 9: break print("-" * 59) print("| thank you, that is all I have for now,") this_script.output.print_md("| **have a great day!**") print("-" * 59)
detail_lines = defaultdict(int) all_lines = Fec(doc).OfCategory(BuiltInCategory.OST_Lines).WhereElementIsNotElementType().ToElements() for line in all_lines: if line.CurveElementType.ToString() == "DetailCurve": view_id_int = line.OwnerViewId.IntegerValue detail_lines[view_id_int] += 1 this_script.output.print_md("####LINE COUNT IN CURRENT VIEW:") this_script.output.print_md('By: [{}]({})'.format(__author__, __contact__)) for line_count, view_id_int in sorted(zip(detail_lines.values(), detail_lines.keys()), reverse=True): view_id = ElementId(view_id_int) view_creator = WorksharingUtils.GetWorksharingTooltipInfo(doc, view_id).Creator try: view_name = doc.GetElement(view_id).ViewName except: view_name = "<no view name available>" this_script.output.print_md("\n**{0} Lines in view:** {3}\n" \ "View id:{1}\n" \ "View creator: {2}\n".format(line_count, this_script.output.linkify(view_id), view_creator, view_name)) print("\n" + str(sum(detail_lines.values())) + " Lines in " + str(len(detail_lines)) + " Views.")
size_unit = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB") i = int(math.floor(math.log(size_bytes, 1024))) p = math.pow(1024, i) size = round(size_bytes / p, 2) return "{}{}".format(size, size_unit[i]) all_fams = Fec(doc).OfClass(Autodesk.Revit.DB.Family).ToElements() fams_creator = defaultdict(list) for fam in all_fams: if fam.IsEditable: fam_doc = doc.EditFamily(fam) fam_path = fam_doc.PathName fam_size = "0" fam_creator = WorksharingUtils.GetWorksharingTooltipInfo( doc, fam.Id).Creator if fam_path: if op.exists(fam_path): fam_size = str(op.getsize(fam_path)) fams_creator[fam_creator].append(fam_size + "; " + fam.Name) print("Families overview:") for creator in fams_creator: print(50 * "-") print("{} created:".format(creator)) sum_size_created = 0 for fam in fams_creator[creator]: size_prefix = int(fam.split(";")[0]) fam_name = fam.split(";")[1] sum_size_created += int(size_prefix) if size_prefix == 0:
from System.Collections.Generic import List uidoc = __revit__.ActiveUIDocument doc = __revit__.ActiveUIDocument.Document # selection = [ doc.GetElement( elId ) for elId in __revit__.ActiveUIDocument.Selection.GetElementIds() ] filteredlist = [] viewlist = [] if doc.IsWorkshared: currentviewid = uidoc.ActiveGraphicalView.Id viewlist.append(currentviewid) if isinstance(uidoc.ActiveGraphicalView, ViewSheet): vportids = uidoc.ActiveGraphicalView.GetAllViewports() for vportid in vportids: viewlist.append(doc.GetElement(vportid).ViewId) for view in viewlist: curviewelements = FilteredElementCollector(doc).OwnedByView( view).WhereElementIsNotElementType().ToElements() if len(curviewelements) > 0: for el in curviewelements: wti = WorksharingUtils.GetWorksharingTooltipInfo(doc, el.Id) # wti.Creator, wti.Owner, wti.LastChangedBy if wti.Owner == __revit__.Application.Username: filteredlist.append(el.Id) uidoc.Selection.SetElementIds(List[ElementId](filteredlist)) else: pass else: TaskDialog.Show('pyRevit', 'Model is not workshared.')
""" Copyright (c) 2018 Daniel J. Swearson """ __author__ = 'Daniel J. Swearson' __doc__ = 'Reports author of created element within a worksharing enviornment' from Autodesk.Revit.DB import WorksharingUtils uidoc = __revit__.ActiveUIDocument doc = __revit__.ActiveUIDocument.Document import clr show_view = doc.ActiveView show_id = show_view.Id.ToString() show_name = show_view.Name show_author = WorksharingUtils.GetWorksharingTooltipInfo(doc, show_view.Id).Creator print("Current view: " + show_name) print("ID number: " + show_id) print("Author: " + show_author)
rev_view_id = rev_cloud.OwnerViewId rev_view = doc.GetElement(rev_view_id) if rev_view.ViewType.ToString() == "Legend": clouded_views[rev_view_id].append(rev_cloud) this_script.output.print_md("####LEGENDS WITH REVISION CLOUDS:") this_script.output.print_md('By: [{}]({})'.format(__author__, __contact__)) for view_id in clouded_views: view = doc.GetElement(view_id) this_script.output.print_md("{1} **Legend: {0}**".format( view.Name, this_script.output.linkify(view_id))) for rev_cloud in clouded_views[view_id]: rev_cloud_id = rev_cloud.Id rev_date = doc.GetElement(rev_cloud.RevisionId).RevisionDate rev_creator = WorksharingUtils.GetWorksharingTooltipInfo( doc, rev_cloud.Id).Creator if rev_cloud.LookupParameter("Comments").HasValue: rev_comments = rev_cloud.LookupParameter("Comments").AsString() else: rev_comments = "" #print(" " + rev_date + " - " + rev_creator + " - " + rev_comments) print('{0} Revision (On {1} By {2}. Comments: {3}'.format( this_script.output.linkify(rev_cloud_id), rev_date, rev_creator, rev_comments)) this_script.output.print_md('----') print(notification)
dwgs = Fec(doc).OfClass( ImportInstance).WhereElementIsNotElementType().ToElements() dwgInst = defaultdict(list) workset_table = doc.GetWorksetTable() for dwg in dwgs: if dwg.IsLinked: dwgInst["LINKED DWGs:"].append(dwg) else: dwgInst["IMPORTED DWGs:"].append(dwg) cview = uidoc.ActiveGraphicalView for link_mode in dwgInst: this_script.output.print_md("####{}".format(link_mode)) for dwg in dwgInst[link_mode]: dwg_id = dwg.Id dwg_name = dwg.LookupParameter("Name").AsString() dwg_workset = workset_table.GetWorkset(dwg.WorksetId).Name dwg_instance_creator = WorksharingUtils.GetWorksharingTooltipInfo( doc, dwg.Id).Creator if cview.Id == dwg.OwnerViewId: this_script.output.print_md("\n**DWG name:** {}\n" \ "DWG created by:{}\n" \ "DWG id: {}\n" \ "DWG workset: {}\n".format(dwg_name, dwg_instance_creator, this_script.output.linkify(dwg_id), dwg_workset))
Copyright (c) 2017 Frederic Beaupere github.com/frederic-beaupere -------------------------------------------------------- PyRevit Notice: Copyright (c) 2014-2017 Ehsan Iran-Nejad pyRevit: repository at https://github.com/eirannejad/pyRevit """ __author__ = 'Frederic Beaupere' __contact__ = 'https://github.com/frederic-beaupere' __credits__ = 'http://eirannejad.github.io/pyRevit/credits/' __doc__ = """Shows the creator of the active view.""" import clr clr.AddReference("RevitAPI") # noinspection PyUnresolvedReferences from Autodesk.Revit.DB import WorksharingUtils from revitutils import doc active_view = doc.ActiveView view_id = active_view.Id.ToString() view_name = active_view.Name view_creator = WorksharingUtils.GetWorksharingTooltipInfo( doc, active_view.Id).Creator print("Creator of the current view: " + view_name) print("with the id: " + view_id) print("is: " + view_creator)
for r in allRevs: if revc.RevisionId.IntegerValue == r.Id.IntegerValue: revDict[revcDesc][2].add(revc.RevisionId.IntegerValue) # for s in sheets: # revIds = [x.IntegerValue for x in s.GetAllRevisionIds()] # if revc.RevisionId.IntegerValue in revIds: # revDict[revcDesc][0].append((s.Id.IntegerValue, s.LookupParameter('Sheet Number').AsString())) parent = doc.GetElement(revc.OwnerViewId) if isinstance(parent, ViewSheet): revDict[revcDesc][0].add( (parent.Id.IntegerValue, parent.LookupParameter('Sheet Number').AsString())) else: # todo: What if the parent is not a sheet? pass if doc.IsWorkshared: wti = WorksharingUtils.GetWorksharingTooltipInfo(doc, revc.Id) revDict[revcDesc][1].add(str(wti.Creator)) revDict[revcDesc][1].add(str(wti.LastChangedBy)) # printing results and exporting to file: destDir = op.expandvars('%userprofile%\\desktop') reportfname = op.join(destDir, 'Revision Report.txt') revisionline = '' # with open(reportfname, 'w+') as reportfile: print('PRINTING REVISIONS GROUPED BY COMMENT:') print('DESCRIPTION\tREVISION\tDRAWING/SHEET\tREVISED BY\n') for k, v in revDict.items(): revisionline = '' print('\n' + '-' * 100) print('REVISION COMMENT:\n{0}'.format(k))