示例#1
0
def action(doc, curview, filter_class, eq_symbol):
    walls = \
            DB.FilteredElementCollector(doc,curview.Id)\
            .OfCategory(DB.BuiltInCategory.OST_Walls)\
            .WhereElementIsNotElementType()\
            .ToElements()
    if walls:
        target_parameter = DB.BuiltInParameter.CURVE_ELEM_LENGTH
        cur_units = get_type(walls[0], target_parameter)
        length = float(
            forms.ask_for_string("Enter length in {0}".format(cur_units)))
        length_feet = convert_to_internal(length, cur_units)
        param_filter = filter_rule(target_parameter, filter_class, length_feet)

        same_cat_elements = \
                DB.FilteredElementCollector(doc,curview.Id)\
                .OfCategory(DB.BuiltInCategory.OST_Walls)\
                .WhereElementIsNotElementType()\
                .WherePasses(param_filter)\
                .ToElements()

        filered_elements = [i.Id for i in same_cat_elements]
        num_walls = len(filered_elements)
        revit.get_selection().set_to(filered_elements)

        print_output(num_walls, length, cur_units, eq_symbol)
    else:
        forms.alert("No wall found in current view", exitscript=True)
示例#2
0
def select_tag_elements(tags):
    """Select elements of the given tag.

    Args:
        tag (Tag): tag object
    """
    elements = []
    for tag in tags:
        elements.extend(get_all_tag_elements(tag))
    revit.get_selection().set_to(elements)
示例#3
0
def sendSelection(sender, args):
    global elements
    if script.get_envvar(SYNC_VIEW_ENV_VAR):
        event_doc = sender.ActiveUIDocument.Document
        # TaskDialog.Show("Count 3", str(len(elements)))

        elements = get_selected_elements(event_doc)

        # TaskDialog.Show("Count 4", str(len(elements)))
        revit.get_selection().set_to(elements[0])
示例#4
0
def select_clouds(revision_element):
    cl = DB.FilteredElementCollector(revit.doc)
    revclouds = cl.OfCategory(DB.BuiltInCategory.OST_RevisionClouds)\
                  .WhereElementIsNotElementType()

    clouds = []

    for revcloud in revclouds:
        if revcloud.RevisionId == revision_element.Id:
            clouds.append(revcloud.Id)

    revit.get_selection().set_to(clouds)
示例#5
0
    def copy(self):
        views = revit.get_selection().only_views()
        if views:
            view = views[0]
            view_filters = revit.query.get_view_filters(view)
            if not view_filters:
                raise PyRevitException('Active view has no fitlers applied')

            selected_filters = forms.SelectFromList.show(
                view_filters,
                name_attr='Name',
                title='Select filters to copy',
                button_name='Select filters',
                multiselect=True
            )

            if not selected_filters:
                raise PyRevitException('No filters selected. Cancelled.')

            script.store_data(
                slot_name=self.__class__.__name__,
                data=FilterOverridesData(
                    source_viewid=view.Id,
                    filter_ids=[f.Id for f in view_filters]
                )
            )
示例#6
0
def flip_hand():
    with revit.Transaction('Flip Hand Selected'):
        for el in revit.get_selection():
            if hasattr(el, 'flipHand'):
                el.flipHand()
            elif hasattr(el, 'Flip'):
                el.Flip()
示例#7
0
def flip_facing():
    with revit.Transaction('Flip Facing Selected'):
        for el in revit.get_selection():
            if hasattr(el, 'flipFacing'):
                el.flipFacing()
            elif hasattr(el, 'Flip'):
                el.Flip()
示例#8
0
    def __init__(self, xaml_file_name):
        selection = revit.get_selection()
        sel_cnt = len(selection)
        if sel_cnt:
            forms.alert(
                'You are managing tags on {} selected elements only.'.format(
                    sel_cnt))

        forms.WPFWindow.__init__(self, xaml_file_name)
        if sel_cnt > 0:
            self.Title += ' (for {} Selected Elements)'.format(sel_cnt)  #pylint: disable=E1101
            # self.hide_element(self.select_elements_b)
            self._target_elements = selection.elements
            self._context = \
                tagsmgr.get_available_tags(self._target_elements)
        else:
            self._target_elements = None
            self._context = tagsmgr.get_available_tags()
            elmnt_count = tagsmgr.get_last_metadata()['count']
            self.Title += ' (for {} Elements)'.format(elmnt_count)  #pylint: disable=E1101

        self.tagmodif_template = \
            self.Resources["ModifierListItemControlTemplate"]
        self._list_options()
        self.hide_element(self.clrsearch_b)
        self.clear_search(None, None)
        self.search_tb.Focus()
示例#9
0
 def get_suitable_views():
     selected_views = revit.get_selection().only_views()
     if not selected_views:
         selected_views = [revit.uidoc.ActiveGraphicalView]
     return [
         view for view in selected_views
         if view.AreGraphicsOverridesAllowed()
     ]
示例#10
0
 def get_cropable_views():
     # py3 returns a filter object but py3 returns filtered list
     # list() makes it consistent
     # py2 filter does not support keyword arguments
     selected_views = revit.get_selection().only_views()
     if not selected_views:
         selected_views = [revit.uidoc.ActiveGraphicalView]
     return list(filter(revit.query.is_cropable_view, selected_views))
示例#11
0
def add_plusminus():
    with revit.Transaction('add plusMinus to dims'):
        for el in revit.get_selection():
            if isinstance(el, DB.Dimension):
                if len(list(el.Segments)) > 0:
                    for seg in el.Segments:
                        seg.Prefix = u'\xb1'
                else:
                    el.Prefix = u'\xb1'
示例#12
0
文件: script.py 项目: BimRoss/pyRevit
def set_to_question():
    with revit.Transaction('(?) dimensions'):
        for el in revit.get_selection():
            if isinstance(el, DB.Dimension):
                if len(list(el.Segments)) > 0:
                    for seg in el.Segments:
                        seg.Suffix = '(?)'
                else:
                    el.Suffix = '(?)'
示例#13
0
def set_to_eq():
    with revit.Transaction('EQ dimensions'):
        for el in revit.get_selection():
            if isinstance(el, DB.Dimension):
                if len(list(el.Segments)) > 0:
                    for seg in el.Segments:
                        seg.ValueOverride = 'EQ'
                else:
                    el.ValueOverride = 'EQ'
示例#14
0
def set_to_vif():
    with revit.Transaction('VIF dimensions'):
        for el in revit.get_selection():
            if isinstance(el, DB.Dimension):
                if len(list(el.Segments)) > 0:
                    for seg in el.Segments:
                        seg.Below = 'VIF'
                else:
                    el.Below = 'VIF'
示例#15
0
def decode_valuestring(target_parameter_value, target_category,
                       target_parameter):
    "Value strings are Revit representation and as such cannot be filtered using fast filters"
    doc = __revit__.ActiveUIDocument.Document
    curview = doc.ActiveView

    elementids = DB.FilteredElementCollector(doc, curview.Id)\
        .OfCategory(target_category)\
        .WhereElementIsNotElementType()\
        .ToElementIds() # select category
    collect_eleid = []
    for eleid in elementids:
        ele = revit.doc.GetElement(eleid)
        ele_parameter_value = ele.Parameter[target_parameter].AsValueString()
        if ele_parameter_value == target_parameter_value:
            collect_eleid.append(eleid)

    revit.get_selection().set_to(collect_eleid)
    sys.exit()
示例#16
0
def flip_wall_location_line():
    for el in revit.get_selection():
        if isinstance(el, DB.Wall):
            param = el.LookupParameter('Location Line')
            current_value = param.AsInteger()
            for pair in location_line_values.values():
                if pair[0] == current_value:
                    with revit.Transaction('Flip Wall Location Line'):
                        param.Set(pair[1])
                    return
示例#17
0
def sendKey(sender, args):
    global elements
    if script.get_envvar(SYNC_VIEW_ENV_VAR):
        event_doc = sender.ActiveUIDocument.Document
        uiapp = UIApplication(event_doc.Application)
        while True:
            if len(get_selected_elements(event_doc)) == 1:
                time.sleep(1)
                # TaskDialog.Show("Count Total", str(len(elements)))
                #TaskDialog.Show("Count Current", str(len(get_selected_elements(doc))))
                #time.sleep(1)
                # SendKeys.SendWait("+{K}")

                break
            else:
                return
        # TaskDialog.Show("Count 1", str(len(elements)))

        revit.get_selection().set_to(elements[1:])
示例#18
0
文件: script.py 项目: Melca-G/Aeolus
def sendKey(sender, args):
    global elements
    global ROTATION_KEY

    if script.get_envvar(SYNC_EXPLODE_ENV_VAR) and ROTATION_KEY == "STATEONE":
        f = open("U:\\B52\\ids.txt", "r")
        ele = f.readline().split(",")
        e = ele[0]
        event_doc = sender.ActiveUIDocument.Document
        f.close()
        line = ""
        logging.debug("Selection setting to first Element of list")
        explodeElement = event_doc.GetElement(ElementId(int(e)))
        '''
        # Activate View
        viewId = explodeElement.OwnerViewId
        ownerView = event_doc.GetElement(viewId)
        sender.ActiveView = ownerView
        time.sleep(0.5)
        '''
        revit.get_selection().set_to(explodeElement)
        for k in ele[1:]:
            line += k + ","
        updateLine = line[0:len(line) - 1]
        w = open("U:\\B52\\ids.txt", "w")
        w.write(updateLine)
        w.close()
        ROTATION_KEY = "STATETWO"

    elif script.get_envvar(
            SYNC_EXPLODE_ENV_VAR) and ROTATION_KEY == "STATETWO":
        pass

        logging.debug("Key Press Start!")
        time.sleep(0.5)
        # TaskDialog.Show("Count 1", str(len(elements)))
        logging.debug("Key Setting Selection to global")
        # revit.get_selection().set_to(elements[1:])
        # elements = elements[1:]
        # revit.get_selection().set_to(elements[1:])
        logging.debug("Key Set Selection successful")

        ROTATION_KEY = "STATEONE"
示例#19
0
def grab_dims():
    dims = []
    for el in revit.get_selection():
        if isinstance(el, DB.Dimension):
            if len(list(el.Segments)) > 0:
                for seg in el.Segments:
                    dims.append(seg)
            else:
                dims.append(el)
    return dims
示例#20
0
def flip_wall_location_line():
    for el in revit.get_selection():
        if isinstance(el, DB.Wall):
            param = el.Parameter[DB.BuiltInParameter.WALL_KEY_REF_PARAM]
            current_value = param.AsInteger()
            for pair in location_line_values.values():
                if pair[0] == current_value:
                    with revit.Transaction('Flip Wall Location Line'):
                        param.Set(pair[1])
                    return
示例#21
0
def pick_by_category(category_opt):
    try:
        selection = revit.get_selection()
        msfilter = PickByCategorySelectionFilter(category_opt)
        selection_list = revit.pick_rectangle(pick_filter=msfilter)
        filtered_list = []
        for element in selection_list:
            filtered_list.append(element.Id)
        selection.set_to(filtered_list)
    except Exception as err:
        logger.debug(err)
示例#22
0
 def validate_context():
     return revit.get_selection().is_empty \
         and isinstance(
             revit.active_view,
             (
                 DB.ViewPlan,
                 DB.ViewSection,
                 DB.View3D,
                 DB.ViewSheet,
                 DB.ViewDrafting
             ))
示例#23
0
def set_to_vfrmfr():
    with revit.Transaction('VWM dimensions'):
        for el in revit.get_selection():
            if isinstance(el, DB.Dimension):
                if len(list(el.Segments)) > 0:
                    for seg in el.Segments:
                        seg.Suffix = 'R.O.'
                        seg.Below = 'VERIFY W/ MFR'
                else:
                    el.Suffix = 'R.O.'
                    el.Below = 'VERIFY W/ MFR'
示例#24
0
def override_dim_value():
    with revit.Transaction('Overrride dims value'):
        for el in revit.get_selection():
            if isinstance(el, DB.Dimension):
                if len(list(el.Segments)) > 0:
                    for seg in el.Segments:
                        exitingValue = seg.ValueString
                        seg.ValueOverride = u'\u200e' + exitingValue
                else:
                    exitingValue = el.ValueString
                    el.ValueOverride = u'\u200e' + exitingValue
示例#25
0
def flip_wall_location():
    with revit.TransactionGroup("Flip Wall On CenterLine"):
        for el in revit.get_selection():
            if isinstance(el, DB.Wall):
                param = el.Parameter[DB.BuiltInParameter.WALL_KEY_REF_PARAM]
                current_value = param.AsInteger()
                with revit.Transaction('Change Wall Location Line'):
                    param.Set(location_line_values['Core Centerline'][0])

                with revit.Transaction('Flip Selected Wall'):
                    el.Flip()
                    param.Set(current_value)
示例#26
0
def lasteCreated():
	curview = revit.activeview


	elements = DB.FilteredElementCollector(revit.doc, curview.Id)\
				 .WhereElementIsNotElementType()\
				 .ToElementIds()

	element_to_isolate = []
	for elid in elements:
		el = revit.doc.GetElement(elid)
		if not el.ViewSpecific:  # and not isinstance(el, DB.Dimension):
			element_to_isolate.append(elid)

	element_to_id = [i.IntegerValue for i in element_to_isolate]

	element_to_id.sort()


	selected=element_to_id[-1]

	revit.get_selection().set_to(selected)
示例#27
0
    def __init__(self, xaml_file_name):
        selection = revit.get_selection()
        sel_cnt = len(selection)
        if sel_cnt:
            forms.alert(
                'You are managing packages on {} selected sheets only.'.format(
                    sel_cnt))

        forms.WPFWindow.__init__(self, xaml_file_name)

        # prepare default privates
        self._last_filter_len = 0

        # prepare wpf resources
        self.dt_template = None
        self.column_header_template = \
            self.sheets_dg.Resources['ColumnHeaderTemplate']
        self.package_column_cell_style = \
            self.sheets_dg.Resources['PackageCellStyle']
        self.revision_column_cell_style = \
            self.sheets_dg.Resources['RevisionCellStyle']
        self.committype_template = \
            self.Resources["CommitTypeListItemControlTemplate"]
        self._read_resources()

        # grab commit points
        self._commit_points = pkgmgr.get_commit_points()
        # prepare columns
        self._build_columns()

        # collect sheets and wrap in sheetitem
        committed_sheets = pkgmgr.get_commited_sheets()
        sheet_numbers = [
            x.SheetNumber for x in selection if isinstance(x, DB.ViewSheet)
        ]

        if sheet_numbers:
            sheetitems = [
                SheetItem(x) for x in committed_sheets
                if x.number in sheet_numbers
            ]
        else:
            sheetitems = [SheetItem(x) for x in committed_sheets]

        self._sheetitems = sorted(sheetitems, key=lambda x: x.number)
        self._setup_item_params_combobox(committed_sheets)

        # list all sheets
        self._list_sheets()
        if isinstance(revit.active_view, DB.ViewSheet):
            self.search_tb.Text = revit.active_view.SheetNumber
示例#28
0
def who_created_selection():
    selection = revit.get_selection()
    if revit.doc.IsWorkshared:
        if selection and len(selection) == 1:
            eh = revit.query.get_history(selection.first)

            forms.alert('Creator: {0}\n'
                        'Current Owner: {1}\n'
                        'Last Changed By: {2}'.format(eh.creator, eh.owner,
                                                      eh.last_changed_by))
        else:
            forms.alert('Exactly one element must be selected.')
    else:
        forms.alert('Model is not workshared.')
示例#29
0
    def copy(self):
        viewports = revit.get_selection().include(DB.Viewport)
        if len(viewports) != 1:
            raise Exception('Exactly one viewport must be selected')
        viewport = viewports[0]
        view = revit.doc.GetElement(viewport.ViewId)

        title_block_pt = \
            ViewportPlacementAction.get_title_block_placement(viewport)

        if view.ViewType in [DB.ViewType.DraftingView, DB.ViewType.Legend]:
            alignment = ALIGNMENT_CROPBOX
        else:
            alignment = forms.CommandSwitchWindow.show(
                ALIGNMENT_OPTIONS_COPY,
                message='Select Alignment Option')

        if not alignment:
            return

        with revit.DryTransaction('Activate & Read Cropbox, Copy Center'):
            if alignment == ALIGNMENT_BASEPOINT:
                revit.update.set_crop_region(
                    view,
                    ViewportPlacementAction.zero_cropbox(view)
                    )
            # use cropbox as alignment if it active
            if alignment == ALIGNMENT_BASEPOINT or view.CropBoxActive:
                ViewportPlacementAction.activate_cropbox(view)
                ViewportPlacementAction.hide_all_elements(view)
                revit.doc.Regenerate()

            if alignment == ALIGNMENT_CROPBOX:
                outline = view.Outline
                offset_uv = (outline.Max - outline.Min) / 2
            center = viewport.GetBoxCenter() - title_block_pt

        script.store_data(
            slot_name=self.__class__.__name__,
            data=ViewportPlacementData(
                alignment=alignment,
                center=center,
                offset_uv=offset_uv if alignment == ALIGNMENT_CROPBOX else None
            )
        )
示例#30
0
def who_created_selection():
    selection = revit.get_selection()
    if revit.doc.IsWorkshared:
        if selection and len(selection) == 1:
            wti = DB.WorksharingUtils.GetWorksharingTooltipInfo(
                revit.doc,
                selection.first.Id
                )

            forms.alert('Creator: {0}\n'
                        'Current Owner: {1}\n'
                        'Last Changed By: {2}'.format(wti.Creator,
                                                      wti.Owner,
                                                      wti.LastChangedBy))
        else:
            forms.alert('Exactly one element must be selected.')
    else:
        forms.alert('Model is not workshared.')