Exemplo n.º 1
0
    def paste(self):
        # load data
        vzps_data = script.load_data(slot_name=self.__class__.__name__,
                                     this_project=False)

        view_type = vzps_data.view_type
        vc1, vc2 = vzps_data.corner_pts
        dir_orient = vzps_data.dir_orient

        active_ui_view = revit.uidoc.GetOpenUIViews()[0]
        if not self.is_compatible_viewtype(revit.active_view, view_type):
            raise PyRevitException(
                'Saved view type (%s) is different from active view (%s)' %
                (vzps_data.view_type, type(revit.active_view).ViewType))
        # load ViewOrientation3D
        if isinstance(revit.active_view, DB.View3D):
            if revit.active_view.IsLocked:
                raise PyRevitException('Current view orientation is locked')
            revit.active_view.SetOrientation(dir_orient)
        elif isinstance(revit.active_view, DB.ViewSection):
            angle = dir_orient.AngleTo(revit.active_view.ViewDirection)
            if not pyutils.almost_equal(angle, math.pi) \
                    and not pyutils.almost_equal(angle, 0):
                raise PyRevitException("Views are not parallel")
        active_ui_view.ZoomAndCenterRectangle(vc1, vc2)
Exemplo n.º 2
0
    def paste(self):
        sb3d_data = script.load_data(slot_name=self.__class__.__name__)

        active_ui_view = revit.uidoc.GetOpenUIViews()[0]
        with revit.Transaction('Paste Section Box Settings'):
            revit.active_view.SetSectionBox(sb3d_data.section_box)
            revit.active_view.SetOrientation(sb3d_data.view_orientation)
        active_ui_view.ZoomToFit()
Exemplo n.º 3
0
 def paste(self):
     cr_data = script.load_data(slot_name=self.__class__.__name__)
     crv_loop = cr_data.cropregion_curveloop
     with revit.Transaction('Paste Crop Region'):
         for view in CropRegionAction.get_cropable_views():
             if isinstance(view, DB.View3D):
                 if cr_data.crop_bbox:
                     view.CropBox = cr_data.crop_bbox
             else:
                 revit.update.set_crop_region(view, crv_loop)
             view.CropBoxActive = cr_data.is_active
     revit.uidoc.RefreshActiveView()
Exemplo n.º 4
0
    def paste(self):
        fo_data = script.load_data(slot_name=self.__class__.__name__)

        source_view = revit.doc.GetElement(fo_data.source_viewid)
        source_filter_ids = fo_data.filter_ids

        # to view template or to selected view
        mode_templates = \
            forms.CommandSwitchWindow.show(
                ['Active View', 'Select View Templates'],
                message='Where do you want to paste filters?'
                ) == 'Select Templates'
        if mode_templates:
            views = forms.select_viewtemplates()
        else:
            views = [revit.active_view]
            views_controlled_by_template = \
                [x for x in views
                 if FilterOverridesAction.controlled_by_template(x)]
            if views_controlled_by_template:
                forms.alert(
                    'You have selected views with template applied.'
                    ' They will be skipped'
                    )
        if not views:
            raise PyRevitException('Nothing selected')

        # check if there are views controlled by template
        with revit.TransactionGroup('Paste Filter Overrides'):
            for view in views:
                with revit.Transaction('Paste filter'):
                    # check if filters are controlled by template
                    if FilterOverridesAction.controlled_by_template(view):
                        mlogger.warn('Skip view \'{}\''.format(
                            revit.query.get_name(view)))
                        continue

                    view_filters_ids = view.GetFilters()
                    for filter_id in source_filter_ids:
                        # remove filter override if exists
                        if filter_id in view_filters_ids:
                            view.RemoveFilter(filter_id)
                        # add new fitler override
                        filter_overrides = source_view.GetFilterOverrides(
                            filter_id)
                        view.SetFilterOverrides(filter_id, filter_overrides)
Exemplo n.º 5
0
    def paste(self):
        vp_data = script.load_data(slot_name=self.__class__.__name__,
                                   this_project=False)

        viewports = revit.get_selection().include(DB.Viewport)
        align_axis = None
        if __shiftclick__:  # pylint: disable=undefined-variable
            align_axis = forms.CommandSwitchWindow.show(
                ['X', 'Y', 'XY'], message='Align specific axis?')
        # read saved values
        alignment = vp_data.alignment
        center = vp_data.center
        offset_uv = vp_data.offset_uv
        if alignment == ALIGNMENT_CROPBOX:
            corner_alignment = forms.CommandSwitchWindow.show(
                ALIGNMENT_OPTIONS, message='Select Alignment Option')

        with revit.TransactionGroup('Paste Viewport Location'):
            for viewport in viewports:
                view = revit.doc.GetElement(viewport.ViewId)
                title_block_pt = \
                    ViewportPlacementAction.get_title_block_placement(viewport)
                crop_region_current = None
                cropbox_values_current = None
                hidden_elements = None
                # set temporary settings: hide elements, set cropbox visibility
                #  if cropbox is not active, do nothing (use visible elements)
                if alignment == ALIGNMENT_BASEPOINT or view.CropBoxActive:
                    with revit.Transaction('Temporary settings'):
                        # 'base point' mode - set cropbox to 'zero' temporary
                        if alignment == ALIGNMENT_BASEPOINT:
                            crop_region_current = revit.query.get_crop_region(
                                view)
                            revit.update.set_crop_region(
                                view,
                                ViewportPlacementAction.zero_cropbox(view))
                        cropbox_values_current = \
                            ViewportPlacementAction.activate_cropbox(view)
                        hidden_elements = \
                            ViewportPlacementAction.hide_all_elements(view)

                with revit.Transaction('Apply Viewport Placement'):
                    new_center = center
                    # 'crop box' mode - align to vp corner if necessary
                    if alignment == ALIGNMENT_CROPBOX \
                            and corner_alignment:
                        offset_xyz = ViewportPlacementAction.calculate_offset(
                            view, offset_uv, corner_alignment)
                        new_center += offset_xyz
                    # isolate alignment by x- or y-axis if necessary
                    new_center = ViewportPlacementAction.isolate_axis(
                        viewport, new_center, align_axis)
                    # apply new viewport position
                    viewport.SetBoxCenter(new_center + title_block_pt)
                # unset temporary values
                if crop_region_current:
                    with revit.Transaction('Recover crop region form'):
                        revit.update.set_crop_region(view, crop_region_current)
                if cropbox_values_current:
                    with revit.Transaction('Recover crop region values'):
                        ViewportPlacementAction.recover_cropbox(
                            view, cropbox_values_current)
                if hidden_elements:
                    with revit.Transaction('Recover hidden elements'):
                        ViewportPlacementAction.unhide_elements(
                            view, hidden_elements)
Exemplo n.º 6
0
 def paste(self):
     vg_data = script.load_data(slot_name=self.__class__.__name__)
     with revit.Transaction('Paste Visibility Graphics'):
         revit.active_view.ApplyViewTemplateParameters(
             revit.doc.GetElement(vg_data.source_viewid))