def METHOD_NAME():
    selview = selvp = None
    vpboundaryoffset = 0.01
    selviewports = []
    selboundary = []
    # pick viewport and line boundary from selection
    for el in selection:
        if isinstance(el, DB.Viewport):
            selviewports.append(el)
        elif isinstance(el, DB.CurveElement):
            selboundary.append(el)
    if len(selviewports) > 0:
        selvp = selviewports[0]
        selview = revit.doc.GetElement(selvp.ViewId)
    else:
        forms.alert('At least one viewport must be selected.')
    if len(selboundary) < 3:
        forms.alert('At least one closed polygon must be '
                    'selected (minimum 3 detail lines).')
    # making sure the cropbox is active.
    if not selview.CropBoxActive:
        with revit.Transaction('Activate Crop Box'):
            selview.CropBoxActive = True
    # get vp min max points in sheetUCS
    ol = selvp.GetBoxOutline()
    vptempmin = ol.MinimumPoint
    vpmin = DB.XYZ(vptempmin.X + vpboundaryoffset,
                   vptempmin.Y + vpboundaryoffset,
                   0.0)
    vptempmax = ol.MaximumPoint
    vpmax = DB.XYZ(vptempmax.X - vpboundaryoffset,
                   vptempmax.Y - vpboundaryoffset,
                   0.0)
    if DEBUG:
        print('VP MIN MAX: {0}\n'
              '            {1}\n'.format(vpmin, vpmax))
    # get view min max points in modelUCS.
    modelucsx = []
    modelucsy = []
    crsm = selview.GetCropRegionShapeManager()
    cl = crsm.GetCropShape()[0]
    for l in cl:
        modelucsx.append(l.GetEndPoint(0).X)
        modelucsy.append(l.GetEndPoint(0).Y)
        if DEBUG:
            print('CROP LINE POINTS: {0}\n'
                  '                  {1}\n'.format(l.GetEndPoint(0),
                                                   l.GetEndPoint(1)))
    cropmin = DB.XYZ(min(modelucsx), min(modelucsy), 0.0)
    cropmax = DB.XYZ(max(modelucsx), max(modelucsy), 0.0)
    if DEBUG:
        print('CROP MIN MAX: {0}\n'
              '              {1}\n'.format(cropmin, cropmax))
    if DEBUG:
        print('VIEW BOUNDING BOX ON THIS SHEET: {0}\n'
              '                                 {1}\n'
              .format(selview.BoundingBox[selview].Min,
                      selview.BoundingBox[selview].Max))
    transmatrix.sourcemin = vpmin
    transmatrix.sourcemax = vpmax
    transmatrix.destmin = cropmin
    transmatrix.destmax = cropmax
    with revit.Transaction('Set Crop Region'):
        curveloop = []
        for bl in selboundary:
            newlinestart = sheet_to_view_transform(bl.GeometryCurve.GetEndPoint(0))
            newlineend = sheet_to_view_transform(bl.GeometryCurve.GetEndPoint(1))
            geomLine = DB.Line.CreateBound(newlinestart, newlineend)
            if MAKELINES:
                sketchp = selview.SketchPlane
                mline = revit.doc.Create.NewModelCurve(geomLine, sketchp)
            curveloop.append(geomLine)
            if DEBUG:
                print('VP POLY LINE POINTS: {0}\n'
                      '                     {1}\n'
                      .format(bl.GeometryCurve.GetEndPoint(0),
                              bl.GeometryCurve.GetEndPoint(1)))
            if DEBUG:
                print('NEW CROP LINE POINTS: {0}\n'
                      '                      {1}\n'.format(newlinestart,
                                                           newlineend))
        sortedcurves = sortcurvescontiguous(curveloop)
        if sortedcurves:
            crsm.SetCropShape(DB.CurveLoop.Create(List[DB.Curve](sortedcurves)))
        else:
            forms.alert('Curves must be in a closed loop.')