예제 #1
0
def remove_all_external_links():
    """Remove All External Links"""
    def confirm_removal(link_el):
        return isinstance(link_el, RevitLinkType) or isinstance(
            link_el, CADLinkType)

    print_header('REMOVE ALL EXTERNAL LINKS')

    if doc.PathName:
        modelPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(
            doc.PathName)
        try:
            transData = TransmissionData.ReadTransmissionData(modelPath)
            externalReferences = transData.GetAllExternalFileReferenceIds()
            xref_links = [doc.GetElement(x) for x in externalReferences]
        except:
            logger.warning(
                'Model must be saved for external links to be removed.')
            return

        remove_action('Remove All External Links',
                      'External Link',
                      xref_links,
                      validity_func=confirm_removal)
    else:
        logger.warning('Model must be saved for external links to be removed.')
예제 #2
0
def _check_for_updates():
    if _check_connection():
        logger.info('Checking for updates...')

        for repo in updater.get_all_extension_repos():
            if updater.has_pending_updates(repo):
                return True
    else:
        logger.warning('No internet access detected. '
                       'Skipping check for updates.')
        return False
예제 #3
0
    def _process_sheet_code(self):
        for sheet_code in str(self.sheets_tb.Text).split('\n'):
            if coreutils.is_blank(sheet_code):
                continue

            if '\t' not in sheet_code:
                logger.warning(
                    'Sheet name must be separated from sheet number by a single tab: {}'
                    .format(sheet_code))
                return False

            sheet_code = re.sub('\t+', '\t', sheet_code)
            sheet_code = sheet_code.replace('\n', '').replace('\r', '')
            num, name = sheet_code.split('\t')
            self._sheet_dict[num] = name

        return True
예제 #4
0
    def PreprocessFailures(self, failures_accessor):
        trans_name = failures_accessor.GetTransactionName()
        fmas = list(failures_accessor.GetFailureMessages())

        if len(fmas) == 0:
            return FailureProcessingResult.Continue

        # We already know the transaction name.
        if trans_name == self.transaction_name:
            # DeleteWarning mimics clicking 'Ok' button
            for fma in fmas:
                logger.warning('Revit failure occured | {}: {}'.format(fma.GetId().Guid, fma.GetDescriptionText()))
                failures_accessor.DeleteWarning(fma)

            return FailureProcessingResult.ProceedWithCommit

        return FailureProcessingResult.Continue
예제 #5
0
def find_duplicates_on_view(tags, view_name):
    tags_dict = {}

    linked_found = 0

    for tag in tags:
        # try:
        #     # TODO find the way to check tags connected to linked file
        if type(tag) == FamilyInstance:
            continue
        elif type(tag) == RoomTag:
            k = tag.Room.Id
        elif type(tag) == AreaTag:
            k = tag.Area.Id
        else:
            k = tag.TaggedLocalElementId

        # except:
        #     continue

        if k.IntegerValue == -1:
            linked_found += 1
            continue

        if k not in tags_dict:
            tags_dict[k] = []

        tags_dict[k].append(tag.Id)
        # except:
        #     logger.info(str(tag.Id) + " unknown exception")

    duplicates_id = []

    for t in tags_dict.keys():
        if len(tags_dict[t]) > 1:
            tags_sorted = sorted(tags_dict[t], key=lambda x: x.IntegerValue)
            # append all ids except the first
            duplicates_id += list(tags_sorted)[1:]

    if linked_found:
        logger.warning(
            "View %s has %d tags connected to linked model. They can't be checked"
            % (view_name, linked_found))
    return duplicates_id
예제 #6
0
파일: script.py 프로젝트: kjanik11/pyRevit
"""Verifies that the wall cores are vertically aligned and walls are stacked."""

from scriptutils import logger

logger.warning('Work in progress tool.')
예제 #7
0
#===============================================================================
#--- SETUP Config
#===============================================================================
from __future__ import print_function

#===============================================================================
#--- SETUP Logging
#===============================================================================

from scriptutils import logger, this_script
from scriptutils.userinput import CommandSwitchWindow

logger.info('Test Log Level :ok_hand_sign:')

logger.warning('Test Log Level')

logger.critical('Test Log Level')

#===============================================================================
#--- SETUP Standard modules
#===============================================================================
import sys
from collections import namedtuple
from customcollections import DefaultOrderedDict

#===============================================================================
#--- SETUP Custom modules
#===============================================================================
path_exergy_util_dir = r"C:\LOCAL_REPO\py_ExergyUtilities"

sys.path.insert(0,path_exergy_util_dir)
예제 #8
0
#===============================================================================
#--- SETUP Config
#===============================================================================
from __future__ import print_function

#===============================================================================
#--- SETUP Logging
#===============================================================================

from scriptutils import logger, this_script
from scriptutils.userinput import CommandSwitchWindow

logger.info('Test Log Level :ok_hand_sign:')

logger.warning('Test Log Level')

logger.critical('Test Log Level')

#===============================================================================
#--- SETUP Standard modules
#===============================================================================
import sys
from collections import namedtuple
from customcollections import DefaultOrderedDict

#===============================================================================
#--- SETUP Custom modules
#===============================================================================
path_exergy_util_dir = r"C:\LOCAL_REPO\py_ExergyUtilities"

sys.path.insert(0, path_exergy_util_dir)
예제 #9
0
                        format(vp.Id, change_err))

    # Correct all hidden viewport elements that use the viewport types to be purged
    with Action('Correct Hidden Viewport Types'):
        for vp_type_name, linked_elements in purge_dict.items():
            has_error = False
            logger.info(
                'Converting all viewports of type: {}'.format(vp_type_name))
            for linked_elid in linked_elements:
                linked_el = doc.GetElement(linked_elid)
                try:
                    if isinstance(linked_el, Viewport) and linked_el.GetTypeId(
                    ) in purge_vp_ids:
                        logger.debug(
                            'Changing viewport type for hidden viewport with id: {}'
                            .format(linked_el.Id))
                        linked_el.ChangeTypeId(dest_vp_typeid)
                except Exception as change_err:
                    has_error = True
                    logger.debug(
                        'Can not change type for hidden viewport with id: {} | {}'
                        .format(linked_el.Id, change_err))
            if has_error:
                logger.warning('Exceptions occured while converting viewport type: {}\n' \
                               'This is minor and the type might still be purgable.'.format(vp_type_name))

TaskDialog.Show(
    'pyRevit',
    'Conversion Completed.\nNow you can remove the unused viewport types using Purge tool.'
)
예제 #10
0
from revitutils import doc

# noinspection PyUnresolvedReferences
from Autodesk.Revit.DB import Transaction, BuiltInCategory, GraphicsStyleType
# noinspection PyUnresolvedReferences
from Autodesk.Revit.UI import TaskDialog

if doc.IsFamilyDocument:
    det_item_cat = doc.OwnerFamily.FamilyCategory

    if 'Detail Item' in det_item_cat.Name:
        with Transaction(doc, 'Wipe Detail Item Categories') as t:
            t.Start()

            for sub_cat in det_item_cat.SubCategories:
                logger.debug('Removing sub category: {}'.format(sub_cat.Name))
                try:
                    doc.Delete(sub_cat.Id)
                    pass
                except:
                    logger.warning('Can not delete sub category: {}'.format(
                        sub_cat.Name))
                    continue

            t.Commit()
    else:
        TaskDialog.Show('pyRevit', 'Family must be of type Detail Item.')
else:
    TaskDialog.Show('pyRevit',
                    'This script works only on an active family editor.')
예제 #11
0
def log_error(el_type='', el_id=0, delete_err=None):
    err_msg = str(delete_err).replace('\n', ' ').replace('\r', '')
    logger.warning('Error Removing Element with Id: {} Type: {} | {}'.format(
        el_id, el_type, err_msg))
예제 #12
0
def main():
    active_view = get_active_view()
    if not active_view:
        logger.warning('Activate a view to copy')
        return

    logger.info('Source view selected: %s id%s' % (active_view.Name, active_view.Id.ToString()))

    """
    Filters selection
    """
    active_template_filters_ch = get_view_filters(doc, active_view)

    sel_set = read_checkboxes_state()
    vt_list = get_view_templates(doc, sel_set=sel_set)

    if not vt_list:
        logger.warning('Project has no view templates')
        return

    if not active_template_filters_ch:
        logger.warning('Active view has no filter overrides')
        return

    filter_checkboxes = SelectFromList.show(active_template_filters_ch, name_attr='Name',
                                            title='Select filters to copy',
                                            button_name='Select filters', multiselect=True)
    filter_checkboxes_sel = []

    # Select filters from active view
    for checkbox in filter_checkboxes:
        if checkbox:
            filter_checkboxes_sel.append(checkbox)

    if not filter_checkboxes_sel:
        return

    """
    Target view templates selection
    """
    view_checkboxes = SelectFromList.show(vt_list, name_attr='Name', title='Select templates to apply filters',
                                          button_name='Apply filters to templates', multiselect=True)
    view_checkboxes_sel = []

    # Select view templates to copy
    for checkbox in view_checkboxes:
        if checkbox:
            view_checkboxes_sel.append(checkbox)

    if not view_checkboxes_sel:
        return

    save_checkboxes_state(view_checkboxes_sel)

    # active_template = doc.GetElement(active_view.ViewTemplateId)

    t = Transaction(doc)
    t.Start(__title__)

    for vt in view_checkboxes_sel:
        if vt.Id == active_view.ViewTemplateId:
            logger.debug('Current template found')
            continue

        for f in filter_checkboxes_sel:
            try:
                vt.RemoveFilter(f.Id)
                logger.info('filter %s deleted from template %s' % (f.Id.IntegerValue.ToString(), vt.Name))
            except:
                pass

            try:
                fr = active_view.GetFilterOverrides(f.Id)
                vt.SetFilterOverrides(f.Id, fr)
            except Exception as e:
                logger.warning('filter %s was not aplied to view %s\n%s' % (f.Id.IntegerValue.ToString(),
                                                                            vt.Name, e))

    t.Commit()

    print("Completed")
예제 #13
0
        pyrevit_repo = updater.get_pyrevit_repo()
        thirdparty_repos = updater.get_thirdparty_ext_repos()

        logger.debug('List of thirdparty repos to be updated: {}'
                     .format(thirdparty_repos))

        for thirdparty_repo_info in thirdparty_repos:
            _update_repo(thirdparty_repo_info)

        if not updater.has_core_updates():
            _update_repo(pyrevit_repo)
            # perform upgrade tasks
            logger.info('Upgrading settings...')
            upgrade.upgrade_existing_pyrevit()

            # Call pyRevit reload command to reload pyRevit
            # The reason to call the command instead of using sessionmgr module
            # to realod is that the repo has been just updatedm so all
            # modules need to be re-imported again in a clean engine.
            from pyrevit.loader.sessionmgr import execute_command
            execute_command(PYREVIT_CORE_RELOAD_COMMAND_NAME)

            this_script.results.newsession = get_session_uuid()

        else:
            this_script.output.print_html(COREUPDATE_MESSAGE
                                          .format(home=HOME_DIR))
            logger.debug('Core updates. Skippin update and reload.')
    else:
        logger.warning('No internet access detected. Skipping update.')
예제 #14
0
파일: script.py 프로젝트: ufaoleg/pyApex
def main():
    allowed_types = [
        ViewPlan,
        View3D,
        ViewSection,
        ViewSheet,
        ViewDrafting
    ]

    selection = uidoc.Selection.GetElementIds()
    if type(doc.ActiveView)!=View:
        active_view = doc.ActiveView
    else:
        active_view = doc.GetElement(selection[0])
        if type(active_view) not in allowed_types:
            logger.error('Selected view is not allowed. Please select or open view from which you want to copy template settings VG Overrides - Filters')
            return
    logger.info('Source view selected: %s id%s' % (active_view.Name, active_view.Id.ToString()))
    active_template = doc.GetElement(active_view.ViewTemplateId)
    logger.info('Source template: %s id%s' % (active_template.Name, active_template.Id.ToString()))

    active_template_filters = active_template.GetFilters()
    
    # print(active_template_filter_rules)
    # return

    selset = read_states()
    # print(selset)
    vt_dict = get_view_templates(doc,selset=selset)
    active_template_filters_ch = get_view_filters(doc,active_template)

    all_checkboxes = SelectFromCheckBoxes.show(active_template_filters_ch)
    sel_checkboxes_filter = []
    # now you can check the state of checkboxes in your program
    for checkbox in all_checkboxes:
        if checkbox:
            sel_checkboxes_filter.append(checkbox)
    if len(sel_checkboxes_filter)==0:
        return


    all_checkboxes = SelectFromCheckBoxes.show(vt_dict)
    sel_checkboxes = []
    # now you can check the state of checkboxes in your program
    for checkbox in all_checkboxes:
        if checkbox:
            sel_checkboxes.append(checkbox)
    if len(sel_checkboxes)==0:
        return
    write_state(sel_checkboxes)


    t = Transaction(doc)
    t.Start("Copy VG")

    for ch in sel_checkboxes:
        vt = doc.GetElement(ch.id)

        if vt.Id == active_template.Id:
            print('current template found')
            continue

        for f in sel_checkboxes_filter:
            fId = f.id
            try:
                vt.RemoveFilter(fId)
                logger.info('filter %s deleted from template %s' % (fId.ToString(), vt.Name))
            except:
                pass
            try:
                fr = active_template.GetFilterOverrides(fId)
                vt.SetFilterOverrides(fId,fr)
            except Exception as e:
                logger.warning('filter not aplied to active view %s\n%s' % (fId.ToString(), e))
    t.Commit()
    print("finished")