def purge(elementIds,
          typeIdsInteger,
          title='Purging duplicate instances - 1st pass'):
    output = script.get_output()
    deletedCount = 0
    max_value = len(elementIds)
    counter = 0
    with forms.ProgressBar(title=title + ' ({value} of {max_value})') as pb:
        for elementId in elementIds:
            counter = counter + 1
            try:
                _element = _(elementId)
                if _element.get(
                        'Family and Type').IntegerValue in typeIdsInteger:
                    if _element.isNotOwned():
                        _element.delete()
                        deletedCount = deletedCount + 1
                    else:
                        print(
                            'The duplicate instance {} is owned by another user!'
                            .format(output.linkify(elementId)))
            except:
                pass
            pb.update_progress(counter, max_value)
    return deletedCount
예제 #2
0
 def add(method, title):
     import revitronui
     roomTagTypes = revitron.Filter().byCategory(
         'Room Tags').onlyTypes().getElements()
     roomTagType = revitronui.SelectType(roomTagTypes, title).show()
     scope = revitron.Selection.get()
     if not scope:
         scope = revitron.ACTIVE_VIEW.Id
     if roomTagType:
         rooms = revitron.Filter(scope).byCategory(
             'Rooms').noTypes().getElements()
         max_value = len(rooms)
         counter = 0
         with forms.ProgressBar(
                 title='Tagging rooms ... ({value} of {max_value})') as pb:
             for room in rooms:
                 counter = counter + 1
                 try:
                     method(room, roomTagType.Id)
                 except:
                     pass
                 pb.update_progress(counter, max_value)
예제 #3
0
# Create Excel object
excel = Excel.ApplicationClass()
excel = Marshal.GetActiveObject("Excel.Application")
workbook = excel.Workbooks.Open(pathFile)
ws = workbook.Worksheets[1]

# Read data
sNumber = ws.Range["A1", "A1000"]
sName = ws.Range["B1", "B1000"]
sheetNumbers = [str(x) for x in retData(sNumber.Value2, sName.Value2)["sheetNumbers"][1:]]
sheetNames = [str(x) for x in retData(sNumber.Value2, sName.Value2)["sheetNames"][1:]]

# Create progress bar
count = 1
finalCount = len(sheetNumbers)
with forms.ProgressBar(step=10) as pb:
    # Create and start transtaction
    t = DB.Transaction(doc, "Create Sheets")
    t.Start()
    # Create sheets
    for sNumb, sNam in zip(sheetNumbers, sheetNames):
        try:
            createSheet(sNumb, sNam, titleBlock)
        except:
            pass
        # Update progress bar
        pb.update_progress(count, finalCount)
        count += 1

    # Commit transaction
    t.Commit()
예제 #4
0
    message='Select loading option:',)
if selected_loading_option is None:
    logger.debug('No loading option selected. Calling script.exit()')
    script.exit()

# User input -> Select loading option (load all, load certain symbols)
logger.debug('Selected loading option: {}'.format(selected_loading_option))
laoding_option = family_loading_options[selected_loading_option]


# Feedback on already loaded families
already_loaded = set()

# Loading selected families
max_value = len(selected_families)
with forms.ProgressBar(title='Loading Family {value} of {max_value}',
                       cancellable=True) as pb:
    for count, family_path in enumerate(selected_families, 1):
        if pb.cancelled:
            break
        pb.update_progress(count, max_value)

        family = FamilyLoader(path_dict[family_path])
        logger.debug('Loading family: {}'.format(family.name))
        loaded = family.is_loaded
        if loaded:
            logger.debug('Family is already loaded: {}'.format(family.path))
            already_loaded.add(family)
            continue
        getattr(family, laoding_option)()

# Feedback on already loaded families
예제 #5
0
 def do_revit_work(self, sender, args):
     # self.dispatch(self.delete_stuff)
     with self.conceal():
         with forms.ProgressBar() as pbar:
             self.delete_stuff(pbar)
예제 #6
0
                for f in fams:
                    p = f.get_Parameter(
                        DB.BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS)
                    type_id = f.GetTypeId()
                    fam_type = revit.doc.GetElement(type_id)
                    p.Set("SPEC_" + fam_type.FamilyName + "-1")

            # p = fam.get_Parameter(DB.BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS)
            # type_id = fam.GetTypeId()
            # fam_type = revit.doc.GetElement(type_id)
            # p.Set(fam_type.FamilyName)

    max_value = len(source_elements)
    count = 0

    with forms.ProgressBar(
            title="PDF Creation ({value} of {max_value})") as pb:
        # Iterate through selection, create view with section box
        for idx, source_element in enumerate(source_elements):
            with revit.Transaction("Create Spec PDF"):
                type_id = source_element.GetTypeId()
                ele_type = revit.doc.GetElement(type_id)
                ele_name = ele_type.FamilyName
                print("Creating SPEC for {}".format(ele_name))

                name_1 = "SPEC_" + ele_name + "-1"
                name_2 = "SPEC_" + ele_name + "-2"
                # If the family has more than max rows
                if ele_name in overflow:
                    # Check if second sheet already exists for this family
                    if name_2 in sheet_names:
                        sheet_2 = [s for s in all_sheets
예제 #7
0
from pyrevit import script
from pyrevit import forms
import sys, os

sheets = forms.select_sheets()

if not sheets:
    sys.exit()

dwg = DWG()
dirs = []

max_value = len(sheets)
counter = 1

with forms.ProgressBar(
        title='Exporting DWG ... ({value} of {max_value})') as pb:
    for sheet in sheets:
        counter = counter + 1
        path = dwg.export(sheet)
        if path:
            dirs.append(os.path.dirname(path))
        else:
            script.get_output().print_html(
                ':pouting_face: Error exporting <em>{}</em>'.format(
                    os.path.basename(path)))
        pb.update_progress(counter, max_value)

dirs = list(set(dirs))

for d in dirs:
    script.show_folder_in_explorer(d)
from System.Collections.Generic import *
from Autodesk.Revit.DB import ElementId, PartUtils, ViewOrientation3D, XYZ, FilteredElementCollector, BuiltInCategory, Transaction
from Autodesk.Revit.DB import TransactionGroup, BuiltInParameter, Line, Point, SketchPlane, Plane, Structure, Electrical, GraphicsStyle
from Autodesk.Revit.UI.Selection import ObjectType, ISelectionFilter
from math import ceil
from pyrevit import script
from pyrevit import forms
output = script.get_output()


def set_progress(pb, progress):
    pb.update_progress(progress, 100)
    pb.title = 'Расчет MVS: ' + str(progress) + ' %'


with forms.ProgressBar() as pb:

    set_progress(pb, 5)

    doc = __revit__.ActiveUIDocument.Document
    uidoc = __revit__.ActiveUIDocument
    k = 304.8

    default = 2000
    dict_ = {
       # КабельСигнальный                                        0 Наименование и техническая…              1 Тип, марка…                       2 Запас на разделку 3 Изготовитель
        'FTP 4x2x0,52 cat 5e':                                  ['Кабель парной скрутки',                   'FTP 4x2x0,52 cat 5e',              default,            'Россия'                                ],  # noqa
        'FTP 5e':                                               ['Кабель парной скрутки',                   'FTP 2x2x0,52 cat 5e',              default,            'Россия'                                ],  # noqa
        'RG174':                                                ['Кабель коаксильный',                      'RG174',                            default,            'Россия'                                ],  # noqa
        'RG-174':                                               ['Кабель коаксильный',                      'RG174',                            default,            'Россия'                                ],  # noqa
        'RG-6U (75 Ом)':                                        ['Кабель коаксильный',                      'RG-6U (75 Ом)',                    default,            'Россия'                                ],  # noqa
예제 #9
0
    FIELDS,
    message='Sorting options:',
)
if not sort_by:
    script.exit()

all_fams = DB.FilteredElementCollector(revit.doc)\
             .OfClass(DB.Family)\
             .ToElements()

all_family_items = []
opened_families = [
    od.Title for od in HOST_APP.uiapp.Application.Documents
    if od.IsFamilyDocument
]
with forms.ProgressBar(title=__title__, cancellable=True) as pb:
    i = 0

    for fam in all_fams:
        with revit.ErrorSwallower() as swallower:
            if fam.IsEditable:
                fam_doc = revit.doc.EditFamily(fam)
                fam_path = fam_doc.PathName
                # if the family path does not exists, save it temporary
                #  only if the wasn't opened when the script was started
                if fam_doc.Title not in opened_families and (
                        not fam_path or not os.path.exists(fam_path)):
                    # edit family
                    fam_doc = revit.doc.EditFamily(fam)
                    # save with temporary path, to know family size
                    fam_path = os.path.join(temp_dir, fam_doc.Title)
예제 #10
0
파일: script.py 프로젝트: Melca-G/Aeolus
modelRegex = re.compile(r'\w\d\d\d\d\d\d\d\d-\S\S_CENTRAL')
modelRegex2 = re.compile(r'\w\d\d\d\d\d\d\d\d-\S\S_CENTRAL_\w?\w?\w')
ElementIDRegex = re.compile(r'Element ID:\D+?\d+')
IDRegex = re.compile(r'\d+')
nameLst = []
for clashFile in clashFiles:
    nameLst.append(os.path.basename(clashFile))

xPntdata = []
yPntdata = []
zPntdata = []
lstLen = []
newfilename = ()
count = 0
print('We found ' + str(len(clashFiles)) + ' Clash Files.')
pb = forms.ProgressBar(title='Files Processing')

# Write data
for filename in clashFiles:
    newFilename = nameLst[count]
    a = 0
    clashFile = open(filename)
    clashSoup = bs4.BeautifulSoup(clashFile, "html.parser")
    pnt = clashSoup.select('body')
    # Locate clash data
    clashData = pnt[0].getText()
    # Search for File name in Soup
    fileNames = modelNameRegex.findall(clashData)
    currentFile = fileNames[::2]
    otherFile = fileNames[1::2]
    # Search for element ID in Soup