Dim SK As Shape, SF1 As Shape, SF2 As Shape, ch As Shape, ch1 As Shape, ch2 As Shape, ch3 As Shape, ch4 As Shape, ch5 As Shape, ch6 As Shape, ch7 As Shape, ch8 As Shape, ch9 As Shape, ch10 As Shape, ch11 As Shape, ch12 As Shape, s As Shape, ch13 As Shape, ch14 As Shape, ch15 As Shape
Dim SPs As Node
Dim al As Layer
Dim CurModel As FAS_TYPE
Dim OrigSelection As ShapeRange, sDupShape As Shape, sh11 As ShapeRange, ActSelRange As ShapeRange
Dim vW As Double, DeltaY As Double, DeltaX As Double, vSizeW As Double, vSizeH As Double, yGlob As Double, xGlob As Double, ar2(4, 2) As Double, t As Double, vTop As Double, vBottom As Double, vLeft As Double, vRight As Double, vOtstup As Double
Dim k As Integer, i As Integer
Dim d As Document
Dim shape_count As Long
Dim vOtsDoOsnFr As Double ' отступ до основной фрезеровки

'On Error GoTo errOk_Click
        
        shape_count = ActiveSelection.Shapes.Count
        If shape_count = 1 Then
            Set d = ActiveDocument
            xGlob = ActiveDocument.DrawingOriginX
            yGlob = ActiveDocument.DrawingOriginY
            Set sDupShape = ActiveShape
            d.DrawingOriginX = xGlob + sDupShape.PositionX - (tbWidth / 2) / 25.4
            d.DrawingOriginY = yGlob + sDupShape.PositionY - (tbHeight / 2) / 25.4
            
        Else
            MsgBox "Необходимо выделить замкнутый контур"
            Exit Sub
        End If
 
    'формирование образца в начале координат
        Set MPage = ActivePage
        Set al = MPage.Layers.Find(PODPISI)
        If al Is Nothing Then
            Set al = MPage.CreateLayer(PODPISI)
        End If
            
        Set al = MPage.Layers.Find(MODEL)
        If al Is Nothing Then
            Set al = MPage.CreateLayer(MODEL)
        End If
    
        CurModel = FTypeArray(cbRisunok.ListIndex + 1)  '   ссылка на текущую модель
       
        'создание векторов модели
        Select Case FTypeArray(cbRisunok.ListIndex + 1).FModel
            
        Case 1: ' Анталия ящик
            Set SK = al.CreateCurve(Curve_F1_K())
            Set SF1 = al.CreateCurve(Curve_F1_F1())
            Set SF2 = Nothing
        Case 2, 3: ' Анталия
            Set SK = al.CreateCurve(Curve_F2_K())
            Set SF1 = al.CreateCurve(Curve_F2_F1())
            Set SF2 = Nothing
        Case 4: ' Мария ящик
            Set SK = al.CreateCurve(Curve_F4_K())
            Set SF1 = al.CreateCurve(Curve_F4_F1())
            Set SF2 = Nothing
        Case 5, 6: ' Мария
            Set SK = al.CreateCurve(Curve_F5_K())
            Set SF1 = al.CreateCurve(Curve_F5_F1())
            Set SF2 = Nothing
        Case 10, 11, 79, 111:
            Set SK = al.CreateCurve(Curve_F10_K())
            Set SF1 = al.CreateCurve(Curve_F10_F1())
            Set SF2 = Nothing
        Case 20, 21, 22:
            Set SK = al.CreateCurve(Curve_F20_K())
            Set SF1 = al.CreateCurve(Curve_F20_F1())
            Set SF2 = Nothing
        Case 23, 24, 7:
            Set SK = al.CreateCurve(Curve_F23_K())
            Set SF1 = al.CreateCurve(Curve_F23_F1())
            Set SF2 = Nothing
        Case 25, 26:
            Set SK = al.CreateCurve(Curve_F25_K())
            Set SF1 = al.CreateCurve(Curve_F25_F1())
            Set SF2 = Nothing
        Case 30:
            Set SK = al.CreateCurve(Curve_F30_K())
            Set SF1 = al.CreateCurve(Curve_F30_F1())
            Set SF2 = Nothing
        Case 40, 42, 43:
            Set SK = al.CreateCurve(Curve_F40_K())
            Set SF1 = al.CreateCurve(Curve_F40_F1())
            Set SF2 = Nothing
        Case 56, 57, 58:
            Set SK = al.CreateCurve(Curve_F56_K())
            Set SF1 = al.CreateCurve(Curve_F56_F1())
            Set SF2 = Nothing
        Case 41:
            Set SK = al.CreateCurve(Curve_F41_K())
            Set SF1 = al.CreateCurve(Curve_F41_F1())
            Set SF2 = Nothing
        Case 50:
            Set SK = al.CreateCurve(Curve_F50_K())
            Set SF1 = al.CreateCurve(Curve_F50_F1())
            Set SF2 = Nothing
        Case 53:
            Set SK = al.CreateCurve(Curve_F50_K())
            Set SF1 = al.CreateCurve(Curve_F50_F1())
            Set SF2 = Nothing
        Case 51, 54:
            Set SK = al.CreateCurve(Curve_F51_K())
            Set SF1 = al.CreateCurve(Curve_F51_F1())
            Set SF2 = Nothing
        Case 52:
            Set SK = al.CreateCurve(Curve_F52_K())
            Set SF1 = al.CreateCurve(Curve_F52_F1())
            Set SF2 = Nothing
        Case 60:
            Set SK = al.CreateCurve(Curve_F60_K())
            Set SF1 = al.CreateCurve(Curve_F60_F1())
            Set SF2 = Nothing
        Case 61:
            Set SK = al.CreateCurve(Curve_F61_K())
            Set SF1 = al.CreateCurve(Curve_F61_F1())
            Set SF2 = Nothing
        Case 62:
            Set SK = al.CreateCurve(Curve_F62_K())
            Set SF1 = al.CreateCurve(Curve_F62_F1())
            Set SF2 = Nothing
        Case 63:
            Set SK = al.CreateCurve(Curve_F63_K())
            Set SF1 = al.CreateCurve(Curve_F63_F1())
            Set SF2 = Nothing
        Case 64:
            Set SK = al.CreateCurve(Curve_F64_K())
            Set SF1 = al.CreateCurve(Curve_F64_F1())
            Set SF2 = Nothing
        Case 65: ' Ривьера ящик
            Set SK = al.CreateCurve(Curve_F65_K())
            Set SF1 = al.CreateCurve(Curve_F65_F1())
            Set SF2 = Nothing
        Case 66: ' Ривьера
            Set SK = al.CreateCurve(Curve_F66_K())
            Set SF1 = al.CreateCurve(Curve_F66_F1())
            Set SF2 = Nothing
        Case 67: ' Луна италия ящик
            Set SK = al.CreateCurve(Curve_F67_K())
            Set SF1 = al.CreateCurve(Curve_F67_F1())
            Set SF2 = Nothing
        Case 68: ' Луна италия
            Set SK = al.CreateCurve(Curve_F68_K())
            Set SF1 = al.CreateCurve(Curve_F68_F1())
            Set SF2 = Nothing
        Case 69: ' Визаж
            Set SK = al.CreateCurve(Curve_F69_K())
            Set SF1 = al.CreateCurve(Curve_F69_F1())
            Set SF2 = Nothing
        Case 69: ' Визаж
            Set SK = al.CreateCurve(Curve_F69_K())
            Set SF1 = al.CreateCurve(Curve_F69_F1())
            Set SF2 = Nothing
        Case 78: ' Визаж витрина
            Set SK = al.CreateCurve(Curve_F78_K())
            Set SF1 = al.CreateCurve(Curve_F78_F1())
            Set SFZ = al.CreateCurve(Curve_F78_FZ())
            Set SF2 = Nothing
        Case 27:
            Set SK = al.CreateCurve(Curve_F27_K())
            Set SF1 = al.CreateCurve(Curve_F27_F1())
            Set SF2 = al.CreateCurve(Curve_F27_F2())
        Case 28:
            Set SK = al.CreateCurve(Curve_F28_K())
            Set SF1 = al.CreateCurve(Curve_F28_F1())
            Set SF2 = Nothing
        Case 70:
            Set SK = al.CreateCurve(Curve_F70_K())
            Set SF1 = al.CreateCurve(Curve_F70_F1())
            Set SF2 = Nothing
        Case 71:
            Set SK = al.CreateCurve(Curve_F71_K())
            Set SF1 = al.CreateCurve(Curve_F71_F1())
            Set SF2 = Nothing
        Case 72:
            Set SK = al.CreateCurve(Curve_F72_K())
            Set SF1 = al.CreateCurve(Curve_F72_F1())
            Set SF2 = Nothing
        Case 73:
            Set SK = al.CreateCurve(Curve_F73_K())
            Set SF1 = al.CreateCurve(Curve_F73_F1())
            Set SF2 = Nothing
        Case 74:
            Set SK = al.CreateCurve(Curve_F74_K())
            Set SF1 = al.CreateCurve(Curve_F74_F1())
            Set SF2 = Nothing
        Case 75, 76, 77:
            Set SK = al.CreateCurve(Curve_F75_K())
            Set SF1 = al.CreateCurve(Curve_F75_F1())
            Set SF2 = Nothing
        Case 80:
            Set SK = al.CreateCurve(Curve_F80_K())
            Set SF1 = al.CreateCurve(Curve_F80_F1())
            Set SF2 = Nothing
        Case 81:
            Set SK = al.CreateCurve(Curve_F80_K())
            Set SF1 = al.CreateCurve(Curve_F80_F1())
            Set SF2 = Nothing
        Case 90:
            Set SK = al.CreateCurve(Curve_F90_K())
            Set SF1 = al.CreateCurve(Curve_F90_F1())
            Set SF2 = Nothing
        Case 91:
            Set SK = al.CreateCurve(Curve_F90_K())
            Set SF1 = al.CreateCurve(Curve_F90_F1())
            Set SF2 = Nothing
        Case 92:
            Set SK = al.CreateCurve(Curve_F92_K())
            Set SF1 = al.CreateCurve(Curve_F92_F1())
            Set SF2 = Nothing
        Case 95:
            Set SK = al.CreateCurve(Curve_F95_K())
            Set SF1 = al.CreateCurve(Curve_F95_F1())
            Set SF2 = Nothing
        Case 29:
            Set SK = al.CreateCurve(Curve_F29_K())
            Set SF1 = al.CreateCurve(Curve_F29_F1())
            Set SF2 = Nothing
        Case 31:
            Set SK = al.CreateCurve(Curve_F31_K())
            Set SF1 = al.CreateCurve(Curve_F31_F1())
            Set SF2 = Nothing
        Case 38:
            Set SK = al.CreateCurve(Curve_F38_K())
            Set SF1 = al.CreateCurve(Curve_F38_F1())
            Set SF2 = Nothing
        Case 39:
            Set SK = al.CreateCurve(Curve_F39_K())
            Set SF1 = al.CreateCurve(Curve_F39_F1())
            Set SF2 = Nothing
        Case 55:
            Set SK = al.CreateCurve(Curve_F55_K())
            Set SF1 = al.CreateCurve(Curve_F55_F1())
            Set SF2 = Nothing
        Case 44:
            Set SK = al.CreateCurve(Curve_F44_K())
            Set SF1 = al.CreateCurve(Curve_F44_F1())
            Set SF2 = Nothing
        Case 45, 46, 97:
            Set SK = al.CreateCurve(Curve_F45_K())
            Set SF1 = al.CreateCurve(Curve_F45_F1())
            Set SF2 = Nothing
        Case 82:
            Set SK = al.CreateCurve(Curve_F82_K())
            Set SF1 = al.CreateCurve(Curve_F82_F1())
            Set SF2 = Nothing
        Case 83, 84:
            Set SK = al.CreateCurve(Curve_F83_K())
            Set SF1 = al.CreateCurve(Curve_F83_F1())
           Set SF2 = Nothing
        Case 85, 86, 87:
            Set SK = al.CreateCurve(Curve_F87_K())
            Set SF1 = al.CreateCurve(Curve_F87_F1())
            Set SF2 = Nothing
        Case 88, 89:
            Set SK = al.CreateCurve(Curve_F88_K())
            Set SF1 = al.CreateCurve(Curve_F88_F1())
            Set SF2 = Nothing
        Case 96:
            Set SK = al.CreateCurve(Curve_F96_K())
            Set SF1 = al.CreateCurve(Curve_F96_F1())
            Set SF2 = Nothing
        Case 98, 99, 117, 118, 122:
            Set SK = sDupShape.Duplicate  'al.CreateCurve(Curve_F98_K())
            Set SF1 = Nothing
            Set SF2 = Nothing
        Case 100:
            Set SK = al.CreateCurve(Curve_F100_K())
            Set SF1 = al.CreateCurve(Curve_F100_F1())
            Set SF2 = Nothing
        Case 101, 102:
            Set SK = al.CreateCurve(Curve_F101_K())
            Set SF1 = al.CreateCurve(Curve_F101_F1())
            Set SF2 = Nothing
        Case 103:
            Set SK = al.CreateCurve(Curve_F103_K())
            Set SF1 = Nothing
            Set SF2 = Nothing
        Case 104:
            Set SK = al.CreateCurve(Curve_F104_K())
            Set SF1 = al.CreateCurve(Curve_F104_F1())
            Set SF2 = Nothing
        Case 105, 106, 119, 120, 121, 122, 123, 125:
            Set SK = sDupShape.Duplicate 'al.CreateCurve(Curve_F105_K())
            Set SF1 = Nothing
            Set SF2 = Nothing
        Case 108:
            Set SK = al.CreateCurve(Curve_F105_K())
            Set SF1 = Nothing
            Set SF2 = Nothing
        Case 107, 115, 116:
            Set SK = al.CreateCurve(Curve_F107_K())
            Set SF1 = Nothing
            Set SF2 = Nothing
        Case 110:
            Set SK = al.CreateCurve(Curve_F105_K())
            Set SF1 = Nothing
            Set SF2 = Nothing
        Case 112, 113:
            Set SK = al.CreateCurve(Curve_F112_K())
            Set SF1 = al.CreateCurve(Curve_F112_F1())
            Set SF2 = al.CreateCurve(Curve_F112_F2())
        Case 114:
            Set SK = al.CreateCurve(Curve_F105_K())
            Set SF1 = Nothing
            Set SF2 = Nothing
            
    Case Else:
        Set SK = sDupShape.Duplicate
        GoTo 3
            'MsgBox "Нет модели для варианта?"
    End Select

        'очистка выделения
        ActiveDocument.ClearSelection
        
        DeltaX = tbOfSet.Value / 25.4 * 2
        DeltaY = tbOfSet.Value / 25.4 * 2
        
        'установить изменения от левого нижнего угла
        ActiveDocument.ReferencePoint = cdrBottomLeft
        
        'установить образец в заданные размеры по горизонтали и вертикали
        SK.Outline.SetProperties Color:=CreateCMYKColor(0, 0, 0, 100)
        SK.SetSize CDbl(tbWidth / 25.4), CDbl(tbHeight / 25.4)
        SK.Name = "F" & tbNum.Text & "-" & tbND.Text

        '   формируем подпись фасада
        'ActiveDocument.ReferencePoint = cdrTopLeft
        Set s = ActiveDocument.ActiveLayer.CreateArtisticText(0, 0, "F" & tbNum.Text & "-" & tbND.Text, , , , 130, , , , cdrCenterAlignment)
        s.Move CDbl(tbWidth / 25.4 / 2), CDbl((tbHeight) / 25.4 / 2)
        s.MoveToLayer ActivePage.Layers(PODPISI)
        
        'выравнивание подписи
        If vRotate Then vW = CDbl(tbHeight / 25.4) Else vW = CDbl(tbWidth / 25.4)
        If s.SizeWidth > vW Then s.Rotate 90
        s.AddToSelection
        SK.AddToSelection
        ActiveSelection.AlignToShape cdrAlignLeft + cdrAlignRight + cdrAlignTop + cdrAlignBottom, SK, cdrTextAlignBoundingBox
        
        
        If Not cbJazchik Then
            Select Case cbTipFrez.ListIndex
            Case 0:
                If Not SF1 Is Nothing Then
                    ReziseShapesLine SF1, CDbl(tbWidth / 25.4) - DeltaX, CDbl(tbHeight / 25.4) - DeltaY, FTypeArray(cbRisunok.ListIndex + 1).FProp
                End If
                If Not SF2 Is Nothing Then
                    ReziseShapesLine SF2, CDbl(tbWidth / 25.4) - DeltaX, CDbl(tbHeight / 25.4) - DeltaY, FTypeArray(cbRisunok.ListIndex + 1).FProp
                End If
            Case 1:
                If Not SF1 Is Nothing Then
                    ReziseShapesLine SF1, CDbl(tbWidth / 25.4) - DeltaX - (CDbl(wFr / 25.4)), CDbl(tbHeight) / 25.4 - DeltaY - (CDbl(wFr / 25.4)), FTypeArray(cbRisunok.ListIndex + 1).FProp
                End If
                If Not SF2 Is Nothing Then
                    ReziseShapesLine SF2, CDbl(tbWidth / 25.4) - DeltaX - (CDbl(wFr / 25.4)), CDbl(tbHeight) / 25.4 - DeltaY - (CDbl(wFr / 25.4)), FTypeArray(cbRisunok.ListIndex + 1).FProp
                End If
            End Select
        Else
            If Not SF1 Is Nothing Then
                ReziseShapesLine SF1, CDbl(tbWidth / 25.4) - DeltaX, CDbl(tbHeight) / 25.4 - DeltaY + (CDbl((tbOfSet * 2 - tbJz * 2) / 25.4)), FTypeArray(cbRisunok.ListIndex + 1).FProp
            End If
            If Not SF2 Is Nothing Then
                ReziseShapesLine SF2, CDbl(tbWidth / 25.4) - DeltaX, CDbl(tbHeight) / 25.4 - DeltaY + (CDbl((tbOfSet * 2 - tbJz * 2) / 25.4)), FTypeArray(cbRisunok.ListIndex + 1).FProp
            End If
        End If
           
        'если в процессе нестинга деталь поворачивалась на 90 градусов, то поворачиваеи и модель
        If vRotate Then
            ActiveDocument.ClearSelection
            SK.AddToSelection
            If Not SF1 Is Nothing Then SF1.AddToSelection
            If Not SF2 Is Nothing Then SF2.AddToSelection
            ActiveSelection.Rotate 90
            vR = tbHeight.Text
            tbHeight.Text = tbWidth.Text
            tbWidth.Text = vR
            
            d.DrawingOriginX = d.DrawingOriginX - (((tbWidth - tbHeight) / 2) / 25.4)
            d.DrawingOriginY = d.DrawingOriginY - (((tbHeight - tbWidth) / 2) / 25.4)
            
        End If
        
        ActiveDocument.ClearSelection
        
    'создание векторов для фрез

            'Создание векторов широкой фрезеровки фрезой F040.... рисунков типа классика и т.п.
        Select Case FTypeArray(cbRisunok.ListIndex + 1).FModel
            Case 1, 2, 4, 5, 10, 20, 23, 25, 28, 40, 41, 44, 45, 50, 51, 80, 90, 56, 75, 82, 83, 86, 88:
                If SK.SizeHeight < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Or SK.SizeWidth < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Then GoTo 3
                Set ch1 = CopyContourLayer(SF1, "F040", "_Z-9_C600_S3600_H5_T1_M10", 18, cdrContourInside)
                ActiveSelection.Outline.SetProperties 34 / 25.4
                ActiveSelection.Outline.SetProperties Color:=CreateCMYKColor(0, 0, 0, 30)
                ActiveSelection.Outline.SetProperties LineCaps:=cdrOutlineRoundLineCaps, LineJoin:=cdrOutlineRoundLineJoin

               If cbTipFrez.ListIndex = 1 Then
                Set ch2 = CopyContourLayer(ch1, "V090", "_Z-3_C600_S8000_H5_T1_M10", 26, cdrContourOutside)
                    ActiveSelection.Outline.SetProperties 6 / 25.4
                    ActiveSelection.Outline.SetProperties Color:=CreateCMYKColor(0, 0, 0, 30)
                    ActiveSelection.Outline.SetProperties LineCaps:=cdrOutlineRoundLineCaps, LineJoin:=cdrOutlineRoundLineJoin
                Set OrigSelection = ActiveSelectionRange
                OrigSelection(1).Curve.Nodes.All.Fillet 24 / 25.4, True
                End If
              
            'Создание векторов витрин
            Case 3, 6, 11, 21, 42, 24, 26, 81, 91, 53, 31, 54, 46, 57, 76, 84, 87, 89:
                If SK.SizeHeight < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Or SK.SizeWidth < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Then GoTo 3
                
                SF1.Fillet 20 / 24.5, True 'скругление R20
                Set ch1 = CopyContourLayer(SF1, "E006", "_Z-16,2_C600_S7000_H5_T1_M7,9", 3, cdrContourInside)
                    ActiveSelection.Outline.SetProperties 12 / 25.4
                    ActiveSelection.Outline.SetProperties Color:=CreateCMYKColor(0, 0, 0, 30)
                    ActiveSelection.Outline.SetProperties LineCaps:=cdrOutlineRoundLineCaps, LineJoin:=cdrOutlineRoundLineJoin
                Set ch3 = CopyContourLayer(SF1, "V007", "_Z-5_C600_S6000_H5_T1_M16", 0.9, cdrContourInside)
                
                If cbTipFrez.ListIndex = 1 Then
                Set ch2 = CopyContourLayer(ch1, "V090", "_Z-3_C600_S8000_H5_T1_M10", 26, cdrContourOutside)
                    ActiveSelection.Outline.SetProperties 6 / 25.4
                    ActiveSelection.Outline.SetProperties Color:=CreateCMYKColor(0, 0, 0, 30)
                    ActiveSelection.Outline.SetProperties LineCaps:=cdrOutlineRoundLineCaps, LineJoin:=cdrOutlineRoundLineJoin
                Set OrigSelection = ActiveSelectionRange
                OrigSelection(1).Curve.Nodes.All.Fillet 24 / 25.4, True
                End If
                
            'Создание векторов квадратной витрины с пазом под стекло
            Case 111:
                If SK.SizeHeight < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Or SK.SizeWidth < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Then GoTo 3
                SF1.Fillet 20 / 24.5, True 'скругление R20
                Set ch1 = CopyContourLayer(SF1, "E006", "_Z-16,2_C600_S7000_H5_T1_M7,9", 3, cdrContourInside)
                Set ch2 = CopyContourLayer(SF1, "V007", "_Z-5_C600_S6000_H5_T1_M16", 0.9, cdrContourInside)
                Set ch3 = CopyContourLayer(SK, "P012", "_Z-4,3_C600_S6000_H5_T1_M5", tbOfSet + 7, cdrContourInside)
                Set ch4 = CopyContourLayer(SK, "P012", "_Z-4,3_C600_S6000_H5_T1_M5", tbOfSet + 12, cdrContourInside)
              
              
            'Витрины для фрезеровок типа СИСТЕМА
            Case 277:
                If SK.SizeHeight < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Or SK.SizeWidth < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Then GoTo 3
                SF1.Fillet 20 / 24.5, True 'скругление R20
                Set ch1 = CopyContourLayer(SF1, "E006", "_Z-16,2_C600_S7000_H5_T1_M7,9", 3, cdrContourInside)
                Set ch2 = CopyContourLayer(SF1, "V007", "_Z-5_C600_S6000_H5_T1_M16", 0.9, cdrContourInside)
                ch2.Outline.SetProperties Color:=CreateCMYKColor(0, 0, 0, 30)
                    ActiveSelection.Outline.SetProperties 12 / 25.4
                    ActiveSelection.Outline.SetProperties Color:=CreateCMYKColor(0, 0, 0, 30)
                    ActiveSelection.Outline.SetProperties LineCaps:=cdrOutlineRoundLineCaps, LineJoin:=cdrOutlineRoundLineJoin
                
            'Витрины для фрезеровок типа ВИЗАЖ
            Case 78:
                If SK.SizeHeight < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Or SK.SizeWidth < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Then GoTo 3
                SF1.Fillet 20 / 24.5, True 'скругление R20
                Set ch1 = CopyContourLayer(SF1, "E012", "_Z-16,4_C600_S5000_H5_T1_M7,9", 33, cdrContourInside)
                Set ch2 = CopyContourLayer(SF1, "F615", "_Z-15,2_C600_S4200_H5_T1_M16", 33, cdrContourInside)
                    ActiveSelection.Outline.SetProperties 12 / 25.4
                    ActiveSelection.Outline.SetProperties Color:=CreateCMYKColor(0, 0, 0, 30)
                    ActiveSelection.Outline.SetProperties LineCaps:=cdrOutlineRoundLineCaps, LineJoin:=cdrOutlineRoundLineJoin
                Set ch3 = CopyLayer(SF1, "Q090", "_Z-2_C600_S5000_H5_T1_M10")
                
            'Создание векторов узкой фрезеровки фрезой тип 90 .... рисунков типа зиг-заг, система и т.п.
            Case 30, 60, 70, 71, 95, 43, 7, 22, 39, 55, 61, 62, 63, 64, 65, 66, 67, 68, 69, 72, 73, 79, 96, 97:
                If SK.SizeHeight < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Or SK.SizeWidth < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Then GoTo 3
                Set ch1 = CopyLayer(SF1, "Q090", "_Z-2_C600_S8000_H5_T1_M10")
                    ActiveSelection.Outline.SetProperties 8 / 25.4
                    ActiveSelection.Outline.SetProperties Color:=CreateCMYKColor(0, 0, 0, 30)
                    ActiveSelection.Outline.SetProperties LineCaps:=cdrOutlineRoundLineCaps, LineJoin:=cdrOutlineRoundLineJoin
            
            'Создание векторов узкой фрезеровки фрезой типа Q090.... рисунков типа классика и т.п.
            Case 10, 20, 23, 25, 28, 38, 40, 41, 50, 51, 80, 90, 58, 74, 77, 85:
                
                If SK.SizeHeight < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Or SK.SizeWidth < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Then GoTo 3
                Set ch1 = CopyContourLayer(SF1, "Q090", "_Z-2_C600_S5000_H5_T1_M10", 6, cdrContourInside)
                    ActiveSelection.Outline.SetProperties 8 / 25.4
                    ActiveSelection.Outline.SetProperties Color:=CreateCMYKColor(0, 0, 0, 30)
                    ActiveSelection.Outline.SetProperties LineCaps:=cdrOutlineRoundLineCaps, LineJoin:=cdrOutlineRoundLineJoin
                
            Case 104:
                If SK.SizeHeight < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Or SK.SizeWidth < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Then GoTo 3
                Set ch1 = CopyLayer(SF1, "V090", "_Z-3_C600_S8000_H5_T1_M10")
                    ActiveSelection.Outline.SetProperties 6 / 25.4
                    ActiveSelection.Outline.SetProperties Color:=CreateCMYKColor(0, 0, 0, 30)
                    ActiveSelection.Outline.SetProperties LineCaps:=cdrOutlineRoundLineCaps, LineJoin:=cdrOutlineRoundLineJoin
                
            'Создание векторов узкой фрезеровки фрезой 90 рисунка Роял С ВЫХОДОМ НА НОЛЬ !!!
            Case 29:
                If SK.SizeHeight < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Or SK.SizeWidth < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Then GoTo 3
                Set ch1 = CopyLayer(SF1, "Q090", "_Z-2_E0_F1_C600_S6000_H5_T1_M10")
                    ActiveSelection.Outline.SetProperties 8 / 25.4
                    ActiveSelection.Outline.SetProperties Color:=CreateCMYKColor(0, 0, 0, 30)
                    ActiveSelection.Outline.SetProperties LineCaps:=cdrOutlineRoundLineCaps, LineJoin:=cdrOutlineRoundLineJoin
                    
            'Создание векторов узкой Флоренция
            Case 112:
                If SK.SizeHeight < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Or SK.SizeWidth < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Then GoTo 3
                Set ch1 = CopyLayer(SF1, "Q090", "_Z-2_C600_S6000_H5_T1_M10")
                Set ch2 = CopyLayer(SF2, "Q090", "_Z-2_C600_S6000_H5_T1_M10")
                
            'Создание векторов витрин типа СИСТЕМА ФЛОРЕНЦИЯ
            Case 113, 27:
                If SK.SizeHeight < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Or SK.SizeWidth < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Then GoTo 3
                Set ch1 = CopyLayer(SF1, "Q090", "_Z-2_C600_S6000_H5_T1_M10")
                Set ch2 = CopyLayer(SF2, "Q090", "_Z-2_C600_S6000_H5_T1_M10")
                Set ch3 = CopyContourLayer(SF2, "E012", "_Z-16,2_C600_S5000_H5_T1_M7,9", 20, cdrContourInside)
                    ActiveSelection.Outline.SetProperties 12 / 25.4
                    ActiveSelection.Outline.SetProperties Color:=CreateCMYKColor(0, 0, 0, 30)
                    ActiveSelection.Outline.SetProperties LineCaps:=cdrOutlineRoundLineCaps, LineJoin:=cdrOutlineRoundLineJoin
                Set ch4 = CopyContourLayer(SF2, "F615", "_Z-15,3_C600_S4200_H5_T1_M16", 20, cdrContourInside)
                ch3.Fillet 20 / 24.5, True
                ch4.Fillet 20 / 24.5, True
                    
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            'Создание векторов "Прямого угла 90гр"
            Case 98:
                MimSize = 242
                If SK.SizeHeight < 150 / 25.4 Or SK.SizeWidth < 150 / 25.4 Then GoTo 3
                cbFreza = "F040"
                If SK.SizeHeight <= MimSize / 25.4 Or SK.SizeWidth <= MimSize / 25.4 Then
                    'Set ch1 = SK.Duplicate
                    If SK.SizeHeight <= MimSize / 25.4 Then tbHeight = MimSize
                    If SK.SizeWidth <= MimSize / 25.4 Then tbWidth = MimSize
                    shi = SK.SizeHeight
                    swi = SK.SizeWidth
                    ActiveDocument.ReferencePoint = cdrCenter
                    SK.SizeHeight = tbHeight / 25.4
                    SK.SizeWidth = tbWidth / 25.4
                    ActiveDocument.ReferencePoint = cdrBottomLeft
                    xGlob = ActiveDocument.DrawingOriginX
                    yGlob = ActiveDocument.DrawingOriginY
                    ActiveDocument.ClearSelection
                    ActiveDocument.DrawingOriginX = xGlob + SK.PositionX
                    ActiveDocument.DrawingOriginY = yGlob + SK.PositionY

                    Call Create_Direct_Conor(0, CDbl(tbHeight) / 25.4, CDbl(tbWidth) / 25.4, 0, CDbl(tbOfSet), 12, 36, _
                                       False, 3, True, True, 4, False, False, False, 0)
                    ActiveDocument.ReferencePoint = cdrCenter
                    SK.SizeHeight = shi
                    SK.SizeWidth = swi
                    ActiveDocument.ReferencePoint = cdrBottomLeft
                    ActiveDocument.DrawingOriginX = xGlob
                    ActiveDocument.DrawingOriginY = yGlob
                    
                Else
                    Call Create_Direct_Conor(0, CDbl(tbHeight) / 25.4, CDbl(tbWidth) / 25.4, 0, CDbl(tbOfSet), 12, 36, _
                                       False, 3, True, True, 4, False, False, False, 0)
            
                End If
            
                
            'Создание векторов фрезеровки "Прямого угла 90гр" витрина
            Case 99:
                Call Create_Direct_Conor(0, CDbl(tbHeight) / 25.4, CDbl(tbWidth) / 25.4, 0, CDbl(tbOfSet), 12, 36, _
                                    False, 3, True, True, 4, True, False, False, 0)

            'Создание векторов "Прямого угла выборка"
            Case 117:
                MimSize = 180
                If SK.SizeHeight < 116 / 25.4 Or SK.SizeWidth < 116 / 25.4 Then GoTo 3
                If SK.SizeHeight <= MimSize / 25.4 Or SK.SizeWidth <= MimSize / 25.4 Then
                    If SK.SizeHeight <= MimSize / 25.4 Then tbHeight = MimSize
                    If SK.SizeWidth <= MimSize / 25.4 Then tbWidth = MimSize
                    shi = SK.SizeHeight
                    swi = SK.SizeWidth
                    ActiveDocument.ReferencePoint = cdrCenter
                    SK.SizeHeight = tbHeight / 25.4
                    SK.SizeWidth = tbWidth / 25.4
                    ActiveDocument.ReferencePoint = cdrBottomLeft
                    xGlob = ActiveDocument.DrawingOriginX
                    yGlob = ActiveDocument.DrawingOriginY
                    ActiveDocument.ClearSelection
                    ActiveDocument.DrawingOriginX = xGlob + SK.PositionX
                    ActiveDocument.DrawingOriginY = yGlob + SK.PositionY
                    Call Create_Direct_Conor(0, CDbl(tbHeight) / 25.4, CDbl(tbWidth) / 25.4, 0, CDbl(tbOfSet), 10, 36, _
                                    False, 3, False, False, 4, False, True, False, 0)
                    ActiveDocument.ReferencePoint = cdrCenter
                    SK.SizeHeight = shi
                    SK.SizeWidth = swi
                    ActiveDocument.ReferencePoint = cdrBottomLeft
                    ActiveDocument.DrawingOriginX = xGlob
                    ActiveDocument.DrawingOriginY = yGlob
                Else
                    Call Create_Direct_Conor(0, CDbl(tbHeight) / 25.4, CDbl(tbWidth) / 25.4, 0, CDbl(tbOfSet), 10, 36, _
                                    False, 3, False, False, 4, False, True, False, 0)
                End If
            
            'Создание векторов "Прямого угла выборка витрина"
            Case 125:
                    Call Create_Direct_Conor(0, CDbl(tbHeight) / 25.4, CDbl(tbWidth) / 25.4, 0, CDbl(tbOfSet), 12, 36, _
                                    False, 3, False, False, 4, True, False, False, 0)
                
            'Создание векторов "Прямого угла двойной прямой"
            Case 118:
                cbFreza = "V090"
                MimSize = 200
                If SK.SizeHeight < 129 / 25.4 Or SK.SizeWidth < 129 / 25.4 Then GoTo 3
                If SK.SizeHeight <= MimSize / 25.4 Or SK.SizeWidth <= MimSize / 25.4 Then
                    If SK.SizeHeight <= MimSize / 25.4 Then tbHeight = MimSize
                    If SK.SizeWidth <= MimSize / 25.4 Then tbWidth = MimSize
                    shi = SK.SizeHeight
                    swi = SK.SizeWidth
                    ActiveDocument.ReferencePoint = cdrCenter
                    SK.SizeHeight = tbHeight / 25.4
                    SK.SizeWidth = tbWidth / 25.4
                    ActiveDocument.ReferencePoint = cdrBottomLeft
                    xGlob = ActiveDocument.DrawingOriginX
                    yGlob = ActiveDocument.DrawingOriginY
                    ActiveDocument.ClearSelection
                    ActiveDocument.DrawingOriginX = xGlob + SK.PositionX
                    ActiveDocument.DrawingOriginY = yGlob + SK.PositionY
                    Call Create_Direct_Conor(0, CDbl(tbHeight) / 25.4, CDbl(tbWidth) / 25.4, 0, CDbl(tbOfSet), 10, 32, _
                                    False, 3, False, False, 4, False, False, False, 0)
                    ActiveDocument.ReferencePoint = cdrCenter
                    SK.SizeHeight = shi
                    SK.SizeWidth = swi
                    ActiveDocument.ReferencePoint = cdrBottomLeft
                    ActiveDocument.DrawingOriginX = xGlob
                    ActiveDocument.DrawingOriginY = yGlob
                    
                Else

                Call Create_Direct_Conor(0, CDbl(tbHeight) / 25.4, CDbl(tbWidth) / 25.4, 0, CDbl(tbOfSet), 10, 32, _
                                    False, 3, False, False, 4, False, False, False, 0)
                End If
                
            'Кнат
            Case 123:
                If SK.SizeHeight < 70 / 25.4 Or SK.SizeWidth < 70 / 25.4 Then GoTo 3
                cbFreza = "V090"
                tbOfSet = 20
                Call Create_Direct_Conor(0, CDbl(tbHeight) / 25.4, CDbl(tbWidth) / 25.4, 0, CDbl(tbOfSet), 6, 36, _
                                    False, 3, False, False, 0, False, True, False, 0)
                cbFreza = "F040"
                tbOfSet = 60
                        
            'Создание векторов "Прямого угла 120гр"
            Case 101:
                If SK.SizeHeight < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Or SK.SizeWidth < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Then GoTo 3
                Set ch1 = CopyLayer(SF1, "V120", "_Z-9_E0_F1_C600_S5000_H5_T1_M20")
                Set ch2 = CopyContourLayer(SK, "V120", "_Z-9_C600_S4000_H5_T1_M20", tbOfSet.Value + 15.5884572681199, cdrContourInside)
                Set ch3 = CopyContourLayer(SK, "V120", "_Z-0,8_C600_S5000_H5_T1_M20", tbOfSet.Value - 7.5884572681199, cdrContourInside)
                Set ch3 = CopyContourLayer(SK, "E012", "_Z-2_C600_S3600_H5_T1_M20", tbOfSet.Value + 39.5884572681199, cdrContourInside)
                Set ch4 = CopyContourLayer(SK, "E012", "_Z-9_C600_S3600_H5_T1_M20", tbOfSet.Value + 21.5884572681199, cdrContourInside)
                Set ch5 = CopyContourLayer(SK, "F040", "_Z-9_C600_S3600_H5_T1_M20", tbOfSet.Value + 27.5884572681199, cdrContourInside)
                Set ch6 = CopyContourLayer(SK, "V120", "_Z-0,8_C600_S5000_H5_T1_M20", tbOfSet.Value + 50.5884572681199, cdrContourInside)

            'Создание векторов фрезеровки "Прямого угла 120гр" витрина
            Case 102:
                If SK.SizeHeight < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Or SK.SizeWidth < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Then GoTo 3
                Set ch1 = CopyLayer(SF1, "V120", "_Z-9_E0_F1_C600_S5000_H5_T1_M20")
                Set ch2 = CopyContourLayer(SK, "V120", "_Z-9_C600_S4000_H5_T1_M20", tbOfSet.Value + 15.5884572681199, cdrContourInside)
                Set ch3 = CopyContourLayer(SK, "V120", "_Z-0,8_C600_S5000_H5_T1_M20", tbOfSet.Value - 7.5884572681199, cdrContourInside)
                Set ch4 = CopyContourLayer(SK, "P012", "_Z-4,7_C600_S5000_H5_T1_M20", tbOfSet.Value + 11.5884572681199, cdrContourInside)
                Set ch5 = CopyContourLayer(SK, "P012", "_Z-4,7_C600_S5000_H5_T1_M20", tbOfSet.Value + 7.5884572681199, cdrContourInside)
                Set ch6 = CopyContourLayer(SK, "E012", "_Z-9_C600_S3600_H5_T1_M20", tbOfSet.Value + 21.5884572681199, cdrContourInside)
                                
            'Создание векторов "Италия 2"
            Case 100:
                If SK.SizeHeight < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Or SK.SizeWidth < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Then GoTo 3
                Set ch1 = CopyLayer(SF1, "V090", "_Z-1,5_C600_S8000_H5_T1_M20")
                Set ch2 = CopyContourLayer(SK, "E003", "_Z-5_C600_S3600_H5_T1_M20", tbOfSet.Value + 0, cdrContourInside)
                Set ch4 = CopyContourLayer(SK, "P012", "_Z-12,2_C600_S5000_H5_T1_M7", tbOfSet.Value - 4, cdrContourInside)
                Set ch5 = CopyContourLayer(SK, "P012", "_Z-12,2_C600_S5000_H5_T1_M7", tbOfSet.Value - 8, cdrContourInside)
                Set ch6 = CopyContourLayer(SK, "MDF12", "_Z-12,2_C600_S5000_H5_T1_M7", tbOfSet.Value - 13, cdrContourInside)
            
            ' тройной проход фрезы для ящиков
            Case 52, 92:
                If SK.SizeHeight < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Or SK.SizeWidth < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Then GoTo 3
                Set ch2 = CopyContourLayer(SF1, "Q090", "_Z-3_C600_S5000_H5_T1_M6", 5, cdrContourInside)
                Set ch3 = CopyContourLayer(SF1, "Q090", "_Z-3_C600_S5000_H5_T1_M6", 5, cdrContourOutside)
                Set ch1 = CopyLayer(SF1, "Q090", "_Z-5_C600_S4200_H5_T1_M6")
                ch1.Outline.SetProperties Color:=CreateCMYKColor(0, 0, 0, 30)
                ch1.Outline.SetProperties 12 / 25.4
                ch1.Outline.SetProperties LineCaps:=cdrOutlineRoundLineCaps, LineJoin:=cdrOutlineRoundLineJoin
                ch2.Outline.SetProperties Color:=CreateCMYKColor(0, 0, 0, 50)
                ch2.Outline.SetProperties 12 / 25.4
                ch2.Outline.SetProperties LineCaps:=cdrOutlineRoundLineCaps, LineJoin:=cdrOutlineRoundLineJoin
                ch3.Outline.SetProperties Color:=CreateCMYKColor(0, 0, 0, 50)
                ch3.Outline.SetProperties 12 / 25.4
                ch3.Outline.SetProperties LineCaps:=cdrOutlineRoundLineCaps, LineJoin:=cdrOutlineRoundLineJoin
                
            'Милена"
            Case 108:
                If SK.SizeHeight < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Or SK.SizeWidth < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Then GoTo 3
                vOtstup = 0
                Set ch1 = CopyContourLayer(SK, MODEL, KRIV, tbOfSet.Value, cdrContourInside)
                
                vLeft = (CDbl(tbOfSet) + vOtstup) / 25.4
                vBottom = (CDbl(tbOfSet) + (CDbl(tbHeight) - CDbl(tbOfSet) * 2) / 2 - (CDbl(tbWidth) - CDbl(tbOfSet) * 2) / 2 + vOtstup) / 25.4
                vTop = vBottom + ((CDbl(tbWidth) - CDbl(tbOfSet) * 2) - vOtstup * 2) / 25.4
                vRight = (CDbl(tbWidth) - CDbl(tbOfSet) - vOtstup) / 25.4
                
                Set ch2 = ActiveLayer.CreateEllipse(vLeft, vTop, vRight, vBottom)
                Set ch3 = CopyContourLayer(ch2, MODEL, KRIV, tbOfSet.Value, cdrContourOutside)
                
                Set ch4 = ch3.Trim(ch1, False, False)

                ActiveDocument.ClearSelection
                ch2.AddToSelection
                ch4.AddToSelection
                Set OrigSelection = ActiveSelectionRange
                OrigSelection.CreateSelection

                Set ch3 = ActiveSelection.Combine
                
                Set ch5 = CopyContourLayer(ch3, "V090", "_Z-10_C600_S6000_H5_T1_M20", 10, cdrContourInside)
                Set ch6 = CopyContourLayer(ch3, "E012", "_Z-10_C600_S8000_H5_T1_M5,5", 16, cdrContourInside)
                Set ch7 = CopyContourLayer(ch3, "E012", "_Z-10_C600_S8000_H5_T1_M5,5", 26, cdrContourInside)
                Set ch7 = CopyContourLayer(ch3, "E012", "_Z-10_C600_S8000_H5_T1_M5,5", 36, cdrContourInside)
                
                Set ch10 = CopyContourLayer(ch3, "F040", "_Z-10,1_C600_S6000_H5_T1_M20", 42, cdrContourInside)
                Set ch11 = CopyContourLayer(ch3, "V004", "_Z-3,3_C600_S6000_H5_T1_M20", 59, cdrContourInside)
                Set ch12 = CopyContourLayer(ch3, "V004", "_Z-3,3_C600_S6000_H5_T1_M20", 69, cdrContourInside)
                Set ch13 = CopyContourLayer(ch3, "E012", "_Z-2,5_C600_S7000_H5_T1_M5,5", 75, cdrContourInside)
                Set ch14 = CopyContourLayer(ch3, "E012", "_Z-2,5_C600_S7000_H5_T1_M5,5", 85, cdrContourInside)
                Set ch15 = CopyContourLayer(ch3, "E012", "_Z-2,5_C600_S7000_H5_T1_M5,5", 95, cdrContourInside)
                
            'Создание НЕСТИНГА"
            Case 107:
                ActiveDocument.ClearSelection
                s.AddToSelection
                SK.AddToSelection
                Set OrigSelection = ActiveSelectionRange
                OrigSelection.CreateSelection
                Dim s1 As Shape
                Set s1 = ActiveSelection.Combine
            
            'каскад
            Case 105:
                If SK.SizeHeight < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Or SK.SizeWidth < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Then GoTo 3

                cbFreza = "V090"
                cbKaskad = "Стандарт"
        
                vOtsDoOsnFr = CDbl(tbOfSet) + CDbl(edOtstObv) * Abs(cbObvNar) + CDbl(edShirFilenki) * Abs(cbObvNar) + edKaskWidth
                
                Set d = ActiveDocument
                Set ch6 = CopyContourLayer(SK, MODEL, "временный вектор", vOtsDoOsnFr, cdrContourInside)
                xGlob = ActiveDocument.DrawingOriginX
                yGlob = ActiveDocument.DrawingOriginY
                d.DrawingOriginX = xGlob + CDbl(vOtsDoOsnFr) / 25.4
                d.DrawingOriginY = yGlob + CDbl(vOtsDoOsnFr) / 25.4
                
                Call Create_Direct_Conor(0, CDbl(tbHeight - vOtsDoOsnFr * 2) / 25.4, CDbl(tbWidth - vOtsDoOsnFr * 2) / 25.4, 0, 0, CDbl(edDeepFr), CDbl(edShirinFr), _
                                        0, 0, 0, 0, 0, 0, 0, 0, 0)
                d.DrawingOriginX = xGlob
                d.DrawingOriginY = yGlob
                ch6.Delete
            
                Call Create_Direct_Conor(0, CDbl(tbHeight) / 25.4, CDbl(tbWidth) / 25.4, 0, CDbl(tbOfSet), CDbl(edKaskDeep), CDbl(edShirinFr + edKaskWidth * 2), _
                                        False, CDbl(edShirFilenki), 0, 0, 0, 0, 0, 0, 1)
             
            Case 119: 'каскад витрина
                If SK.SizeHeight < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Or SK.SizeWidth < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Then GoTo 3
                cbFreza = "V090"
                cbKaskad = "Стандарт"
                chFilenka = False
                cbObvNar = False
                cbObvVn = False
        
                vOtsDoOsnFr = CDbl(tbOfSet) + CDbl(edOtstObv) * Abs(cbObvNar) + CDbl(edShirFilenki) * Abs(cbObvNar) + edKaskWidth
                
                Set d = ActiveDocument
                Set ch6 = CopyContourLayer(SK, MODEL, "временный вектор", vOtsDoOsnFr, cdrContourInside)
                xGlob = ActiveDocument.DrawingOriginX
                yGlob = ActiveDocument.DrawingOriginY
                d.DrawingOriginX = xGlob + CDbl(vOtsDoOsnFr) / 25.4
                d.DrawingOriginY = yGlob + CDbl(vOtsDoOsnFr) / 25.4
                
                Call Create_Direct_Conor(0, CDbl(tbHeight - vOtsDoOsnFr * 2) / 25.4, CDbl(tbWidth - vOtsDoOsnFr * 2) / 25.4, 0, 0, CDbl(edDeepFr), CDbl(edShirinFr), _
                                        0, 0, 0, 0, 0, True, 0, 0, 0)
                d.DrawingOriginX = xGlob
                d.DrawingOriginY = yGlob
                ch6.Delete
            
                Call Create_Direct_Conor(0, CDbl(tbHeight) / 25.4, CDbl(tbWidth) / 25.4, 0, CDbl(tbOfSet), CDbl(edKaskDeep), CDbl(edShirinFr + edKaskWidth * 2), _
                                        False, CDbl(edShirFilenki), 0, 0, 0, 0, 0, 0, 1)
                ActivePage.Layers("V090").Activate
                ActiveLayer.Shapes.Item(13).Delete
                ActivePage.Layers("E012").Activate
                ActiveLayer.Shapes.Item(1).Delete

            'каскад выборка
            Case 120: 'каскад выборка
                If SK.SizeHeight < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Or SK.SizeWidth < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Then GoTo 3

                cbFreza = "V090"
                cbKaskad = "Стандарт"
                chFilenka = False
                cbObvNar = False
                cbObvVn = False
        
                vOtsDoOsnFr = CDbl(tbOfSet) + CDbl(edOtstObv) * Abs(cbObvNar) + CDbl(edShirFilenki) * Abs(cbObvNar) + edKaskWidth
                
                Set d = ActiveDocument
                Set ch6 = CopyContourLayer(SK, MODEL, "временный вектор", vOtsDoOsnFr, cdrContourInside)
                xGlob = ActiveDocument.DrawingOriginX
                yGlob = ActiveDocument.DrawingOriginY
                d.DrawingOriginX = xGlob + CDbl(vOtsDoOsnFr) / 25.4
                d.DrawingOriginY = yGlob + CDbl(vOtsDoOsnFr) / 25.4
                
                Call Create_Direct_Conor(0, CDbl(tbHeight - vOtsDoOsnFr * 2) / 25.4, CDbl(tbWidth - vOtsDoOsnFr * 2) / 25.4, 0, 0, CDbl(edDeepFr), CDbl(edShirinFr), _
                                        0, 0, 0, 0, 0, 0, True, 0, 0)
                d.DrawingOriginX = xGlob
                d.DrawingOriginY = yGlob
                ch6.Delete
            
                Call Create_Direct_Conor(0, CDbl(tbHeight) / 25.4, CDbl(tbWidth) / 25.4, 0, CDbl(tbOfSet), CDbl(edKaskDeep), CDbl(edShirinFr + edKaskWidth * 2), _
                                        False, CDbl(edShirFilenki), 0, 0, 0, 0, 0, 0, 1)
                ActivePage.Layers("V090").Activate
                ActiveLayer.Shapes.Item(13).Delete
                ActivePage.Layers("E012").Activate
                ActiveLayer.Shapes.Item(1).Delete

        Case 106: 'стиральная доска
        Set al = MPage.Layers.Find("Q090")
        If al Is Nothing Then
            Set al = MPage.CreateLayer("Q090")
        End If
        If vRotate Then
               DeltaY = (tbHeight - 26) / Int((tbHeight - 26) / 16)
        For x = 0 To Int((tbHeight - 26) / 16)
            Set ch = al.CreateLineSegment(SK.PositionX, SK.PositionY + 13 / 25.4 + (DeltaY * x) / 25.4, tbWidth / 25.4, SK.PositionY + 13 / 25.4 + (DeltaY * x) / 25.4)
            If x Mod 2 = 0 Then ch.Curve.ReverseDirection
            ch.Name = "_Z-3_C600_S8000_H5_T1_M13"
            ch.Outline.SetProperties Color:=CreateCMYKColor(100, 0, 0, 0)
        Next x
        Else
        DeltaX = (tbWidth - 26) / Int((tbWidth - 26) / 16)
        For x = 0 To Int((tbWidth - 26) / 16)
            Set ch = al.CreateLineSegment(SK.PositionX + 13 / 25.4 + (DeltaX * x) / 25.4, SK.PositionY, SK.PositionX + 13 / 25.4 + (DeltaX * x) / 25.4, tbHeight / 25.4)
            If x Mod 2 = 0 Then ch.Curve.ReverseDirection
            ch.Name = "_Z-3_C600_S8000_H5_T1_M13"
            ch.Outline.SetProperties Color:=CreateCMYKColor(100, 0, 0, 0)
        Next x

        End If
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            'Создание векторов "Филенка настраиваемая"
          Case 103:
            If SK.SizeHeight < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Or SK.SizeWidth < (tbOfSet.Value / 25.4 * 2) + (40 / 25.4) Then GoTo 3
                If cbBezOtst Then   'построение фрезеровки прямой угол без отступа
                Call Create_Direct_Conor(0, CDbl(tbHeight) / 25.4, CDbl(tbWidth) / 25.4, 0, 0, CDbl(edDeepFr), CDbl(edShirinFr), _
                                        0, 0, 0, 0, 0, Abs(cbVitrina), Abs(cbViborka), 0, 0)
                End If
                
                If OptionButton3.Value = True And Not cbBezOtst Then ' построение фрезеровки прямой угол с вариациями
                Call Create_Direct_Conor(0, CDbl(tbHeight) / 25.4, CDbl(tbWidth) / 25.4, 0, CDbl(tbOfSet), CDbl(edDeepFr), CDbl(edShirinFr), _
                                        CDbl(chFilenka), CDbl(edShirFilenki), Abs(cbObvNar), Abs(cbObvVn), edOtstObv, Abs(cbVitrina), Abs(cbViborka), Abs(cbFilUgol), 0)
                End If
                
                If OptionButton5.Value = True And Not cbBezOtst Then ' построение фрезеровки прямой угол решетка с вариациям
                    
                    If cbObvNar Then t = CDbl(edShirFilenki) + CDbl(edOtstObv) Else t = 0

                    vSizeW = (CDbl(tbWidth) - CDbl(tbOfSet) * 2 - (CDbl(edKGoriz) - 1) * CDbl(edTPerem) - t * 2) / CDbl(edKGoriz)
                    vSizeH = (CDbl(tbHeight) - CDbl(tbOfSet) * 2 - (CDbl(edKVert) - 1) * CDbl(edTPerem) - t * 2) / CDbl(edKVert)
                    
                    'построение векторов среза задних перемычек
                        If cbVitrina And cbUbrRazdStekol Then
                        
                        Set MPage = ActivePage
                        Set al = MPage.Layers.Find("P012")
                        If al Is Nothing Then
                            Set al = MPage.CreateLayer("P012")
                        End If
                        
                        ActivePage.Layers("P012").Activate
                        vOtstup = CDbl(tbOfSet) - CDbl(edShirFilenki * cbObvNar) - CDbl(edOtstObv * cbObvNar)
                        
                        For i = 1 To edKGoriz - 1 'отрисовка вертикальных векторов
                            Set ch = ActiveLayer.CreateLineSegment((vOtstup + CDbl(edTPerem) * (i - 1) + vSizeW * i + CDbl(edTPerem) / 2) / 25.4, _
                                                                   (vOtstup + CDbl(edDeepFr) - 6) / 25.4, _
                                                                   (vOtstup + CDbl(edTPerem) * (i - 1) + vSizeW * i + CDbl(edTPerem) / 2) / 25.4, _
                                                                   (CDbl(tbHeight) - vOtstup - (CDbl(edDeepFr) - 6)) / 25.4)
                            ch.Name = "_Z-4,5_C600_S8000_H5_T1_M6"
                        Next i
                        For i = 1 To edKVert - 1 'отрисовка горизонтальных векторов
                            Set ch = ActiveLayer.CreateLineSegment((vOtstup + CDbl(edDeepFr) - 6) / 25.4, _
                                                                (vOtstup + CDbl(edTPerem) * (i - 1) + vSizeH * i + CDbl(edTPerem) / 2) / 25.4, _
                                                                (CDbl(tbWidth) - vOtstup - (CDbl(edDeepFr) - 6)) / 25.4, _
                                                                (vOtstup + CDbl(edTPerem) * (i - 1) + vSizeH * i + CDbl(edTPerem) / 2) / 25.4)
                            ch.Name = "_Z-4,5_C600_S8000_H5_T1_M6"
                        Next i
                        Set ch6 = CopyContourLayer(SK, "P012", "_Z-4,5_C600_S8000_H5_T1_M6", vOtstup + (CDbl(edDeepFr) - 6), cdrContourInside)
                    End If
                    
                    'построение основных векторов
                    
                    Set d = ActiveDocument
                    xGlob = ActiveDocument.DrawingOriginX
                    yGlob = ActiveDocument.DrawingOriginY
                    For i = 0 To edKVert - 1
                        For k = 0 To edKGoriz - 1
                        d.DrawingOriginX = xGlob + CDbl(tbOfSet) / 25.4 + CDbl(vSizeW) / 25.4 * k + CDbl(edTPerem) / 25.4 * k + t / 25.4
                        d.DrawingOriginY = yGlob + CDbl(tbOfSet) / 25.4 + CDbl(vSizeH) / 25.4 * i + CDbl(edTPerem) / 25.4 * i + t / 25.4
                        Call Create_Direct_Conor(0, vSizeH / 25.4, vSizeW / 25.4, 0, 0, CDbl(edDeepFr), CDbl(edShirinFr), _
                                            0, 0, 0, 0, 0, cbVitrina, cbViborka, 0, 0)
                            
                        'Set ch = ActiveLayer.CreateRectangle(0, vSizeH / 25.4, vSizeW / 25.4, 0)
                        Next k
                    Next i
                    d.DrawingOriginX = xGlob ' возврат начала координат
                    d.DrawingOriginY = yGlob
                    
                    'Создание вектов обводки
                    ActivePage.Layers("V090").Activate
                        If cbObvNar Then
                        Set ch6 = CopyContourLayer(SK, "V090", "_Z-" & edShirFilenki / 2 & "_C600_S8000_H5_T1_M13", tbOfSet + _
                                                        edShirFilenki / 2, cdrContourInside)
                    End If
                    
                    x = 0
                    y = 0
                    'Создание вектов иммитации сборного фасада
                    ActivePage.Layers("V090").Activate
                    If chFilenka And cbObvNar Then
                        For i = 1 To ch6.Curve.Nodes.Count
                            Set SPs = ch6.Curve.Nodes(i)
                            If SPs.PositionX > (tbWidth / 2) / 25.4 Then x = 1 Else x = -1
                            If SPs.PositionY > (tbHeight / 2) / 25.4 Then y = 1 Else y = -1
                            Set ch3 = ActiveLayer.CreateLineSegment(SPs.PositionX, SPs.PositionY, _
                                                                    SPs.PositionX - (CDbl(tbOfSet) + CDbl(edShirFilenki) / 2) * cbFilUgol * x / 25.4, _
                                                                    SPs.PositionY + y * (CDbl(tbOfSet) + CDbl(edShirFilenki) / 2) / 25.4)
                            ch3.Name = "_Z-" & edShirFilenki / 2 & "_C600_S8000_H5_T1_M5"
                            If i > 1 Then
                                ch9.Selected = True
                                Set OrigSelection = ActiveSelectionRange
                                OrigSelection.CreateSelection

                                Set ch9 = ActiveSelection.Combine
                            Else: Set ch9 = ch3
                            End If
                        Next i
                    End If
                    If chFilenka And Not cbObvNar Then
                        Set ch8 = CopyContourLayer(SK, "V090", "_Z-" & edDeepFr & "_C600_S6000_H5_T1_M13", (CDbl(tbOfSet) + CDbl(edShirFilenki) / 2), cdrContourInside)
                        ActivePage.Layers("V090").Activate
                        For i = 1 To ch8.Curve.Nodes.Count
                            Set SPs = ch8.Curve.Nodes(i)
                            If SPs.PositionX > (tbWidth / 2) / 25.4 Then x = 1 Else x = -1
                            If SPs.PositionY > (tbHeight / 2) / 25.4 Then y = 1 Else y = -1
                            Set ch3 = ActiveLayer.CreateLineSegment(SPs.PositionX, SPs.PositionY, _
                                                                    SPs.PositionX - (CDbl(tbOfSet) + CDbl(edShirFilenki) / 2) * cbFilUgol * x / 25.4, _
                                                                    SPs.PositionY + y * (CDbl(tbOfSet) + CDbl(edShirFilenki) / 2) / 25.4)
                            ch3.Name = "_Z-" & edShirFilenki / 2 & "_C600_S8000_H5_T1_M5"
                            If i > 1 Then
                                ch9.Selected = True
                                Set OrigSelection = ActiveSelectionRange
                                OrigSelection.CreateSelection

                                Set ch9 = ActiveSelection.Combine
                            Else: Set ch9 = ch3
                            End If
                        Next i
                        ch8.Delete
                    End If
                End If
            
            Case 110: 'произвольная фигура
                    ActivePage.Layers(MODEL).Activate
                    
                    Set ch1 = ActiveLayer.CreateEllipse2(((tbWidth.Value) / 2) / 25.4, ((tbHeight.Value) / 2) / 25.4, (tbWidth) / 2 / 25.4, (tbHeight) / 2 / 25.4)
                    Set ch3 = ActiveLayer.CreateEllipse2(((tbWidth.Value) / 2) / 25.4, ((tbHeight.Value) / 2) / 25.4, ((tbWidth) - 160) / 2 / 25.4, (tbHeight - 160) / 2 / 25.4)
                
                    Set ch2 = CopyContourLayer(ch1, "E006", "_Z-16,2_C600_S6000_H5_T1_M5,5", 3, cdrContourOutside)
                    Set ch4 = CopyContourLayer(ch3, "E006", "_Z-16,2_C600_S6000_H5_T1_M5,5", 3, cdrContourInside)
                    ActiveDocument.ClearSelection
                    ch2.AddToSelection
                    ch4.AddToSelection
                    Set OrigSelection = ActiveSelectionRange
                    OrigSelection.CreateSelection

                    Set ch5 = ActiveSelection.Combine
                    
            Case 114: 'подписи вставок для выборки
                ActiveDocument.ClearSelection

                s.AddToSelection
                Set OrigSelection = ActiveSelectionRange
                OrigSelection.ConvertToCurves
                If s.SizeHeight > SK.SizeHeight - (20 / 25.4) Then
                 'ActiveDocument.ReferencePoint = cdrCenter
                    s.Stretch (SK.SizeHeight - (20 / 25.4))
                End If
                If s.SizeWidth > SK.SizeWidth - (20 / 25.4) Then
                'ActiveDocument.ReferencePoint = cdrCenter
                    s.Stretch (SK.SizeWidth - (20 / 25.4))
                End If
                SK.AddToSelection
                s.AddToSelection
                ActiveSelection.AlignToShape cdrAlignLeft + cdrAlignRight + cdrAlignTop + cdrAlignBottom, SK, cdrTextAlignBoundingBox
                ActiveDocument.ClearSelection
            
                Set al = MPage.Layers.Find("V091")
                If al Is Nothing Then
                    Set al = MPage.CreateLayer("V091")
                End If
            
                s.MoveToLayer ActivePage.Layers("V091")
                s.Name = "_Z-0,2_C600_S6000_H5_T1_M13"
            
                SK.MoveToLayer ActivePage.Layers("V091")
                SK.Name = "_Z-3,2_C600_S6000_H5_T1_M13"
                If SK.Curve.IsClockwise = True Then SK.Curve.ReverseDirection
            
            'Создание Контур"
            Case 115:
                SK.AddToSelection
                Set OrigSelection = ActiveSelectionRange
                OrigSelection.CreateSelection
            
            Case 116:
                SK.AddToSelection
                Set OrigSelection = ActiveSelectionRange
                OrigSelection.CreateSelection
                Call Direct_Conor_Cross
                
           'чертеж
            Case 121:
3:
                SK.Fill.UniformColor.CMYKAssign 0, 100, 100, 0
           
            'Раскрой с припуском на завал
            Case 122:
                vAddSp = 0.5 / 25.4
                SK.SetSize SK.SizeWidth + vFrzRaskr + vAddSp, SK.SizeHeight + vFrzRaskr + vAddSp
                If IsNull(tbChamfer) Then SK.SetSize SK.SizeWidth + vFrzRaskr + vAddSp, SK.SizeHeight + vFrzRaskr + vAddSp
                If tbChamfer = "" Then SK.SetSize SK.SizeWidth + vFrzRaskr + vAddSp, SK.SizeHeight + vFrzRaskr + vAddSp
                If Left(tbChamfer, 2) = "R0" Then SK.SetSize SK.SizeWidth + vFrzRaskr + vAddSp, SK.SizeHeight + vFrzRaskr + vAddSp
                If tbChamfer = "R2" Then SK.SetSize SK.SizeWidth + vFrzRaskr + vAddSp, SK.SizeHeight + vFrzRaskr + vAddSp
                If tbChamfer = "R4" Then SK.SetSize SK.SizeWidth + vFrzRaskr + vAddSp, SK.SizeHeight + vFrzRaskr + vAddSp
                If Left(tbChamfer, 2) = "R7" Then SK.SetSize SK.SizeWidth + vFrzRaskr + vAddSp + (3 / 25.4), SK.SizeHeight + vFrzRaskr + vAddSp + (3 / 25.4)
                SK.Outline.SetProperties Color:=CreateCMYKColor(0, 100, 100, 0)
                SK.AddToSelection
                'Outline.SetProperties Color:=CreateCMYKColor(0, 100, 0, 0)    'Outline.SetProperties
                 '   OrigSelection.ApplyUniformFill CreateCMYKColor(0, 100, 100, 0)
                
            Case Else:
                'MsgBox "Нет модели для фрезеровки?"
                
            End Select
            
            If Not sDupShape Is Nothing Then sDupShape.Delete
            ActiveDocument.ClearSelection
            If Not SK Is Nothing Then SK.AddToSelection
'errOk_Click:
    'ActiveSelection.Fill.UniformColor.CMYKAssign 40, 0, 0, 0
    'MsgBox "Ошибка " & Err.Description, vbCritical + vbOKOnly, "Ошибка"


End Sub