在好例子网,分享、交流、成长!
您当前所在位置:首页ASP 开发实例ASP/Basic基础 → 雕铣机数控系统源码(vb运用)

雕铣机数控系统源码(vb运用)

ASP/Basic基础

下载此实例
  • 开发语言:ASP
  • 实例大小:0.39M
  • 下载次数:82
  • 浏览次数:859
  • 发布时间:2018-08-23
  • 实例类别:ASP/Basic基础
  • 发 布 人:GHOST123456
  • 文件格式:.zip
  • 所需积分:5
 相关标签: vb 数控

实例介绍

【实例简介】

【实例截图】

from clipboard

【核心代码】

VERSION 5.00
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Begin VB.Form Form1 
   Caption         =   "雕铣机数控系统"
   ClientHeight    =   10725
   ClientLeft      =   60
   ClientTop       =   465
   ClientWidth     =   15240
   LinkTopic       =   "Form1"
   ScaleHeight     =   10725
   ScaleWidth      =   15240
   WindowState     =   2  'Maximized
   Begin VB.CommandButton cmdEdit 
      Caption         =   "编辑"
      Height          =   375
      Left            =   14160
      TabIndex        =   87
      Top             =   1440
      Width           =   855
   End
   Begin VB.CommandButton Command3 
      Caption         =   "开冷却"
      Height          =   495
      Left            =   12960
      TabIndex        =   83
      Top             =   5520
      Width           =   855
   End
   Begin VB.Frame Frame1 
      Caption         =   "状态"
      Height          =   1815
      Left            =   12840
      TabIndex        =   78
      Top             =   3480
      Width           =   2295
      Begin VB.Label lblQiexueye 
         Caption         =   "关"
         Height          =   255
         Left            =   1080
         TabIndex        =   82
         Top             =   720
         Width           =   1095
      End
      Begin VB.Label lblZhuzhou 
         Caption         =   "关"
         Height          =   255
         Left            =   1080
         TabIndex        =   81
         Top             =   360
         Width           =   1095
      End
      Begin VB.Label Label24 
         Caption         =   "切削液"
         Height          =   255
         Left            =   240
         TabIndex        =   80
         Top             =   720
         Width           =   615
      End
      Begin VB.Label Label23 
         Caption         =   "主轴"
         Height          =   255
         Left            =   240
         TabIndex        =   79
         Top             =   360
         Width           =   375
      End
   End
   Begin VB.PictureBox picYZ 
      AutoRedraw      =   -1  'True
      BackColor       =   &H00C00000&
      Height          =   5095
      Left            =   120
      ScaleHeight     =   5040
      ScaleWidth      =   5040
      TabIndex        =   66
      Top             =   5225
      Width           =   5095
   End
   Begin VB.PictureBox picZX 
      AutoRedraw      =   -1  'True
      BackColor       =   &H00C00000&
      Height          =   5095
      Left            =   5225
      ScaleHeight     =   5040
      ScaleWidth      =   5040
      TabIndex        =   65
      Top             =   120
      Width           =   5095
   End
   Begin VB.PictureBox picXY 
      AutoRedraw      =   -1  'True
      BackColor       =   &H00C00000&
      Height          =   5095
      Left            =   120
      ScaleHeight     =   5040
      ScaleWidth      =   5040
      TabIndex        =   64
      Top             =   120
      Width           =   5095
   End
   Begin MSComctlLib.StatusBar StatusBar1 
      Height          =   375
      Left            =   0
      TabIndex        =   51
      Top             =   10320
      Width           =   7680
      _ExtentX        =   13547
      _ExtentY        =   661
      _Version        =   393216
      BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
         NumPanels       =   3
         BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   7056
            MinWidth        =   7056
         EndProperty
         BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3704
            MinWidth        =   3704
            Text            =   "程序行数:"
            TextSave        =   "程序行数:"
         EndProperty
         BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   2558
            MinWidth        =   2558
            Text            =   "加工进度:0%"
            TextSave        =   "加工进度:0%"
         EndProperty
      EndProperty
   End
   Begin TabDlg.SSTab SSTab1 
      Height          =   2895
      Left            =   10440
      TabIndex        =   26
      Top             =   7320
      Width           =   4695
      _ExtentX        =   8281
      _ExtentY        =   5106
      _Version        =   393216
      Style           =   1
      Tabs            =   6
      Tab             =   2
      TabsPerRow      =   6
      TabHeight       =   520
      TabCaption(0)   =   "显示"
      TabPicture(0)   =   "Form1.frx":0000
      Tab(0).ControlEnabled=   0   'False
      Tab(0).Control(0)=   "cmdClear"
      Tab(0).Control(1)=   "chkFour"
      Tab(0).Control(2)=   "Check3"
      Tab(0).Control(3)=   "Text3"
      Tab(0).Control(4)=   "Text2"
      Tab(0).Control(5)=   "Text1"
      Tab(0).Control(6)=   "Check1"
      Tab(0).Control(7)=   "Check2"
      Tab(0).Control(8)=   "Text4"
      Tab(0).Control(9)=   "Check4"
      Tab(0).Control(10)=   "Label6"
      Tab(0).Control(11)=   "Label3"
      Tab(0).Control(12)=   "Label2"
      Tab(0).Control(13)=   "Label7"
      Tab(0).ControlCount=   14
      TabCaption(1)   =   "前瞻"
      TabPicture(1)   =   "Form1.frx":001C
      Tab(1).ControlEnabled=   0   'False
      Tab(1).Control(0)=   "Command1"
      Tab(1).Control(1)=   "txtN"
      Tab(1).Control(2)=   "txtVel"
      Tab(1).Control(3)=   "txtAcc"
      Tab(1).Control(4)=   "txtAcc_max"
      Tab(1).Control(5)=   "txtT"
      Tab(1).Control(6)=   "Label17"
      Tab(1).Control(7)=   "Label16"
      Tab(1).Control(8)=   "Label15"
      Tab(1).Control(9)=   "Label14"
      Tab(1).Control(10)=   "Label13"
      Tab(1).ControlCount=   11
      TabCaption(2)   =   "手动"
      TabPicture(2)   =   "Form1.frx":0038
      Tab(2).ControlEnabled=   -1  'True
      Tab(2).Control(0)=   "Label18"
      Tab(2).Control(0).Enabled=   0   'False
      Tab(2).Control(1)=   "Label19"
      Tab(2).Control(1).Enabled=   0   'False
      Tab(2).Control(2)=   "Label20"
      Tab(2).Control(2).Enabled=   0   'False
      Tab(2).Control(3)=   "Label21"
      Tab(2).Control(3).Enabled=   0   'False
      Tab(2).Control(4)=   "chkDiandong"
      Tab(2).Control(4).Enabled=   0   'False
      Tab(2).Control(5)=   "Slider1"
      Tab(2).Control(5).Enabled=   0   'False
      Tab(2).Control(6)=   "Combo1"
      Tab(2).Control(6).Enabled=   0   'False
      Tab(2).Control(7)=   "Slider2"
      Tab(2).Control(7).Enabled=   0   'False
      Tab(2).ControlCount=   8
      TabCaption(3)   =   "执行"
      TabPicture(3)   =   "Form1.frx":0054
      Tab(3).ControlEnabled=   0   'False
      Tab(3).Control(0)=   "Label5"
      Tab(3).Control(1)=   "txtDantiao"
      Tab(3).Control(2)=   "cmdDantiao"
      Tab(3).ControlCount=   3
      TabCaption(4)   =   "对刀"
      TabPicture(4)   =   "Form1.frx":0070
      Tab(4).ControlEnabled=   0   'False
      Tab(4).Control(0)=   "cmdZ"
      Tab(4).Control(1)=   "Command4"
      Tab(4).Control(2)=   "cmdQingchu"
      Tab(4).Control(3)=   "cmdY2"
      Tab(4).Control(4)=   "cmdY1"
      Tab(4).Control(5)=   "cmdX2"
      Tab(4).Control(6)=   "cmdX1"
      Tab(4).Control(7)=   "lblz"
      Tab(4).Control(8)=   "lblY2"
      Tab(4).Control(9)=   "lblY1"
      Tab(4).Control(10)=   "lblX2"
      Tab(4).Control(11)=   "lblX1"
      Tab(4).ControlCount=   12
      TabCaption(5)   =   "刀补"
      TabPicture(5)   =   "Form1.frx":008C
      Tab(5).ControlEnabled=   0   'False
      Tab(5).Control(0)=   "Label22"
      Tab(5).Control(1)=   "Label25"
      Tab(5).Control(2)=   "txtRdao"
      Tab(5).Control(3)=   "txtZpz"
      Tab(5).ControlCount=   4
      Begin VB.CommandButton cmdZ 
         Caption         =   "Z"
         Height          =   375
         Left            =   -74520
         TabIndex        =   89
         Top             =   2400
         Width           =   855
      End
      Begin VB.CommandButton Command4 
         Caption         =   "目标点"
         Height          =   375
         Left            =   -72000
         TabIndex        =   88
         Top             =   1200
         Width           =   855
      End
      Begin VB.TextBox txtZpz 
         Height          =   270
         Left            =   -73920
         TabIndex        =   85
         Top             =   600
         Width           =   735
      End
      Begin VB.TextBox txtRdao 
         Height          =   270
         Left            =   -73920
         TabIndex        =   84
         Top             =   1200
         Width           =   735
      End
      Begin VB.CommandButton cmdQingchu 
         Caption         =   "清除"
         Height          =   375
         Left            =   -72000
         TabIndex        =   77
         Top             =   1680
         Width           =   855
      End
      Begin VB.CommandButton cmdY2 
         Caption         =   "Y2"
         Height          =   375
         Left            =   -74520
         TabIndex        =   72
         Top             =   1920
         Width           =   855
      End
      Begin VB.CommandButton cmdY1 
         Caption         =   "Y1"
         Height          =   375
         Left            =   -74520
         TabIndex        =   71
         Top             =   1440
         Width           =   855
      End
      Begin VB.CommandButton cmdX2 
         Caption         =   "X2"
         Height          =   375
         Left            =   -74520
         TabIndex        =   70
         Top             =   960
         Width           =   855
      End
      Begin VB.CommandButton cmdX1 
         Caption         =   "X1"
         Height          =   375
         Left            =   -74520
         TabIndex        =   69
         Top             =   480
         Width           =   855
      End
      Begin VB.CommandButton cmdClear 
         Caption         =   "清屏"
         Height          =   375
         Left            =   -72210
         TabIndex        =   68
         Top             =   2160
         Width           =   735
      End
      Begin VB.CheckBox chkFour 
         Caption         =   "四窗口显示"
         Height          =   255
         Left            =   -74400
         TabIndex        =   67
         Top             =   2280
         Width           =   1335
      End
      Begin VB.CommandButton cmdDantiao 
         Caption         =   "执行"
         Height          =   375
         Left            =   -73200
         TabIndex        =   63
         Top             =   1680
         Width           =   975
      End
      Begin VB.TextBox txtDantiao 
         Height          =   270
         Left            =   -74640
         TabIndex        =   62
         Top             =   1200
         Width           =   3855
      End
      Begin VB.CheckBox Check3 
         Caption         =   "适应屏幕"
         Height          =   255
         Left            =   -72360
         TabIndex        =   55
         Top             =   1800
         Value           =   1  'Checked
         Width           =   1335
      End
      Begin VB.TextBox Text3 
         Height          =   270
         Left            =   -71880
         TabIndex        =   54
         Text            =   "0"
         Top             =   1440
         Width           =   735
      End
      Begin VB.TextBox Text2 
         Height          =   270
         Left            =   -71880
         TabIndex        =   53
         Text            =   "0"
         Top             =   1080
         Width           =   735
      End
      Begin VB.TextBox Text1 
         Height          =   270
         Left            =   -71880
         TabIndex        =   52
         Text            =   "500"
         Top             =   720
         Width           =   735
      End
      Begin MSComctlLib.Slider Slider2 
         Height          =   375
         Left            =   360
         TabIndex        =   49
         Top             =   2100
         Width           =   3975
         _ExtentX        =   7011
         _ExtentY        =   661
         _Version        =   393216
         LargeChange     =   500
         SmallChange     =   100
         Max             =   5000
         SelStart        =   1000
         Value           =   1000
         TextPosition    =   1
      End
      Begin VB.ComboBox Combo1 
         Height          =   300
         ItemData        =   "Form1.frx":00A8
         Left            =   1830
         List            =   "Form1.frx":00B8
         Style           =   2  'Dropdown List
         TabIndex        =   45
         Top             =   540
         Width           =   1335
      End
      Begin MSComctlLib.Slider Slider1 
         Height          =   555
         Left            =   360
         TabIndex        =   44
         Top             =   900
         Width           =   3975
         _ExtentX        =   7011
         _ExtentY        =   979
         _Version        =   393216
         LargeChange     =   1
         SelStart        =   1
         Value           =   1
         TextPosition    =   1
      End
      Begin VB.CheckBox chkDiandong 
         Caption         =   "点动"
         Height          =   255
         Left            =   3330
         TabIndex        =   43
         Top             =   555
         Width           =   855
      End
      Begin VB.CommandButton Command1 
         Caption         =   "缺省"
         Height          =   375
         Left            =   -72240
         TabIndex        =   42
         Top             =   2160
         Width           =   855
      End
      Begin VB.TextBox txtN 
         Height          =   270
         Left            =   -72360
         TabIndex        =   36
         Text            =   "45"
         Top             =   1560
         Width           =   1095
      End
      Begin VB.TextBox txtVel 
         Height          =   270
         Left            =   -72360
         TabIndex        =   35
         Text            =   "1000"
         Top             =   840
         Width           =   1095
      End
      Begin VB.TextBox txtAcc 
         Height          =   270
         Left            =   -74280
         TabIndex        =   34
         Text            =   "1440000"
         Top             =   2280
         Width           =   1095
      End
      Begin VB.TextBox txtAcc_max 
         Height          =   270
         Left            =   -74280
         TabIndex        =   33
         Text            =   "10800000"
         Top             =   1560
         Width           =   1095
      End
      Begin VB.TextBox txtT 
         Height          =   270
         Left            =   -74280
         TabIndex        =   32
         Text            =   "0.000016"
         Top             =   840
         Width           =   1095
      End
      Begin VB.CheckBox Check1 
         Caption         =   "显示G00"
         Height          =   255
         Left            =   -74415
         TabIndex        =   30
         Top             =   720
         Value           =   1  'Checked
         Width           =   975
      End
      Begin VB.CheckBox Check2 
         Caption         =   "动态显示"
         Height          =   255
         Left            =   -74415
         TabIndex        =   29
         Top             =   1320
         Width           =   1095
      End
      Begin VB.TextBox Text4 
         Height          =   270
         Left            =   -74400
         TabIndex        =   28
         Text            =   "0.01"
         Top             =   1920
         Width           =   855
      End
      Begin VB.CheckBox Check4 
         Caption         =   "三维显示"
         Height          =   180
         Left            =   -74415
         TabIndex        =   27
         Top             =   1080
         Value           =   1  'Checked
         Width           =   1095
      End
      Begin VB.Label Label25 
         Caption         =   "刀具半径         mm"
         Height          =   255
         Left            =   -74640
         TabIndex        =   91
         Top             =   1245
         Width           =   1815
      End
      Begin VB.Label lblz 
         Alignment       =   1  'Right Justify
         Caption         =   "0.000"
         Height          =   255
         Left            =   -73560
         TabIndex        =   90
         Top             =   2520
         Width           =   975
      End
      Begin VB.Label Label22 
         Caption         =   "Z轴偏置          mm"
         Height          =   195
         Left            =   -74640
         TabIndex        =   86
         Top             =   660
         Width           =   1755
      End
      Begin VB.Label lblY2 
         Alignment       =   1  'Right Justify
         Caption         =   "0.000"
         Height          =   255
         Left            =   -73560
         TabIndex        =   76
         Top             =   2040
         Width           =   975
      End
      Begin VB.Label lblY1 
         Alignment       =   1  'Right Justify
         Caption         =   "0.000"
         Height          =   255
         Left            =   -73560
         TabIndex        =   75
         Top             =   1560
         Width           =   975
      End
      Begin VB.Label lblX2 
         Alignment       =   1  'Right Justify
         Caption         =   "0.000"
         Height          =   255
         Left            =   -73560
         TabIndex        =   74
         Top             =   1080
         Width           =   975
      End
      Begin VB.Label lblX1 
         Alignment       =   1  'Right Justify
         Caption         =   "0.000"
         Height          =   255
         Left            =   -73560
         TabIndex        =   73
         Top             =   600
         Width           =   975
      End
      Begin VB.Label Label5 
         Caption         =   "单条代码执行"
         Height          =   255
         Left            =   -74640
         TabIndex        =   61
         Top             =   960
         Width           =   1455
      End
      Begin VB.Label Label6 
         Caption         =   "Y方向偏移:         mm"
         Height          =   255
         Left            =   -72810
         TabIndex        =   58
         Top             =   1455
         Width           =   2055
      End
      Begin VB.Label Label3 
         Caption         =   "X方向偏移:         mm"
         Height          =   255
         Left            =   -72810
         TabIndex        =   57
         Top             =   1125
         Width           =   2055
      End
      Begin VB.Label Label2 
         Caption         =   "显示尺寸:         mm"
         Height          =   255
         Left            =   -72720
         TabIndex        =   56
         Top             =   750
         Width           =   1935
      End
      Begin VB.Label Label21 
         Caption         =   " 0      1000    2000    3000    4000    5000"
         Height          =   255
         Left            =   360
         TabIndex        =   50
         Top             =   2460
         Width           =   3975
      End
      Begin VB.Label Label20 
         Caption         =   "速度(mm/min):"
         Height          =   255
         Left            =   480
         TabIndex        =   48
         Top             =   1860
         Width           =   1185
      End
      Begin VB.Label Label19 
         Caption         =   "0   1   2   3   4   5   6   7   8   9   10"
         Height          =   255
         Left            =   480
         TabIndex        =   47
         Top             =   1500
         Width           =   3855
      End
      Begin VB.Label Label18 
         Caption         =   "长度:     单位:"
         Height          =   255
         Left            =   480
         TabIndex        =   46
         Top             =   615
         Width           =   1455
      End
      Begin VB.Label Label17 
         Caption         =   "目标速度mm/min"
         Height          =   255
         Left            =   -72360
         TabIndex        =   41
         Top             =   600
         Width           =   1335
      End
      Begin VB.Label Label16 
         Caption         =   "预处理段数"
         Height          =   255
         Left            =   -72360
         TabIndex        =   40
         Top             =   1320
         Width           =   975
      End
      Begin VB.Label Label15 
         Caption         =   "加速度mm/min^2"
         Height          =   255
         Left            =   -74280
         TabIndex        =   39
         Top             =   2040
         Width           =   1455
      End
      Begin VB.Label Label14 
         Caption         =   "最大加速度mm/min^2"
         Height          =   255
         Left            =   -74280
         TabIndex        =   38
         Top             =   1320
         Width           =   1695
      End
      Begin VB.Label Label13 
         Caption         =   "拐弯时间min"
         Height          =   255
         Left            =   -74280
         TabIndex        =   37
         Top             =   600
         Width           =   1095
      End
      Begin VB.Label Label7 
         Caption         =   "速度(1/s):"
         Height          =   255
         Left            =   -74400
         TabIndex        =   31
         Top             =   1680
         Width           =   1095
      End
   End
   Begin VB.CommandButton Command2 
      Caption         =   "开主轴"
      Height          =   495
      Left            =   14040
      TabIndex        =   25
      Top             =   5520
      Width           =   855
   End
   Begin VB.CommandButton cmdZero 
      Caption         =   "位置清零"
      Height          =   375
      Left            =   14160
      TabIndex        =   24
      Top             =   2760
      Width           =   975
   End
   Begin VB.Timer Timer1 
      Interval        =   50
      Left            =   11640
      Top             =   5520
   End
   Begin VB.Frame Frame2 
      Caption         =   "轴位置"
      Height          =   1815
      Left            =   10440
      TabIndex        =   17
      Top             =   3480
      Width           =   2295
      Begin VB.Label lblZpos 
         Alignment       =   1  'Right Justify
         Caption         =   "0.000"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   720
         TabIndex        =   23
         Top             =   1320
         Width           =   1215
      End
      Begin VB.Label lblYpos 
         Alignment       =   1  'Right Justify
         Caption         =   "0.000"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   720
         TabIndex        =   22
         Top             =   840
         Width           =   1215
      End
      Begin VB.Label lblXpos 
         Alignment       =   1  'Right Justify
         Caption         =   "0.000"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   720
         TabIndex        =   21
         Top             =   360
         Width           =   1215
      End
      Begin VB.Label Label12 
         Caption         =   "Z"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   360
         TabIndex        =   20
         Top             =   1320
         Width           =   255
      End
      Begin VB.Label Label11 
         Caption         =   "Y"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   360
         TabIndex        =   19
         Top             =   840
         Width           =   255
      End
      Begin VB.Label Label10 
         Caption         =   "X"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   360
         TabIndex        =   18
         Top             =   360
         Width           =   255
      End
   End
   Begin VB.CommandButton cmdInitial 
      Caption         =   "初始化"
      Height          =   375
      Left            =   14160
      TabIndex        =   16
      Top             =   2040
      Width           =   855
   End
   Begin VB.CommandButton cmdStart 
      Caption         =   "启动"
      Height          =   510
      Left            =   12960
      TabIndex        =   15
      Top             =   6090
      Width           =   855
   End
   Begin VB.CommandButton cmdReset 
      Caption         =   "复位"
      Height          =   480
      Left            =   12960
      TabIndex        =   14
      Top             =   6720
      Width           =   855
   End
   Begin VB.CommandButton cmdZf 
      Caption         =   "Z-"
      Height          =   495
      Left            =   12240
      TabIndex        =   13
      Top             =   6720
      Width           =   495
   End
   Begin VB.CommandButton cmdZz 
      Caption         =   "Z "
      Height          =   495
      Left            =   12240
      TabIndex        =   12
      Top             =   5520
      Width           =   495
   End
   Begin VB.CommandButton cmdYf 
      Caption         =   "Y-"
      Height          =   495
      Left            =   11040
      TabIndex        =   11
      Top             =   6720
      Width           =   495
   End
   Begin VB.CommandButton cmdXz 
      Caption         =   "X "
      Height          =   495
      Left            =   11640
      TabIndex        =   10
      Top             =   6120
      Width           =   495
   End
   Begin VB.CommandButton cmdXf 
      Caption         =   "X-"
      Height          =   495
      Left            =   10440
      TabIndex        =   9
      Top             =   6120
      Width           =   495
   End
   Begin VB.CommandButton cmdYz 
      Caption         =   "Y "
      Height          =   495
      Left            =   11040
      TabIndex        =   8
      Top             =   5520
      Width           =   495
   End
   Begin VB.CommandButton cmdStop 
      Caption         =   "停止"
      Height          =   495
      Left            =   14040
      TabIndex        =   7
      Top             =   6720
      Width           =   855
   End
   Begin VB.CommandButton cmdZanting 
      Caption         =   "暂停"
      Height          =   495
      Left            =   14040
      TabIndex        =   4
      Top             =   6120
      Width           =   855
   End
   Begin VB.PictureBox Picture1 
      AutoRedraw      =   -1  'True
      BackColor       =   &H00C00000&
      Height          =   10200
      Left            =   120
      ScaleHeight     =   10140
      ScaleWidth      =   10140
      TabIndex        =   3
      Top             =   120
      Width           =   10200
   End
   Begin VB.CommandButton cmdrun 
      Caption         =   "仿真"
      Height          =   375
      Left            =   14160
      TabIndex        =   2
      Top             =   840
      Width           =   855
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   10440
      Top             =   5400
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin RichTextLib.RichTextBox RTB1 
      Height          =   3300
      Left            =   10440
      TabIndex        =   1
      Top             =   120
      Width           =   3500
      _ExtentX        =   6165
      _ExtentY        =   5821
      _Version        =   393217
      ReadOnly        =   -1  'True
      ScrollBars      =   3
      TextRTF         =   $"Form1.frx":00E5
   End
   Begin VB.CommandButton cmdopen 
      Caption         =   "打开"
      Height          =   375
      Left            =   14160
      TabIndex        =   0
      Top             =   240
      Width           =   855
   End
   Begin VB.Label Label4 
      Caption         =   "Y"
      Height          =   255
      Left            =   9225
      TabIndex        =   60
      Top             =   10440
      Width           =   135
   End
   Begin VB.Label Label1 
      Caption         =   "X"
      Height          =   255
      Left            =   8055
      TabIndex        =   59
      Top             =   10440
      Width           =   135
   End
   Begin VB.Label Label8 
      Caption         =   "0"
      Height          =   255
      Left            =   8280
      TabIndex        =   6
      Top             =   10440
      Width           =   615
   End
   Begin VB.Label Label9 
      Caption         =   "0"
      Height          =   255
      Left            =   9480
      TabIndex        =   5
      Top             =   10440
      Width           =   615
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim G() As Byte, M() As Byte '缓冲区1
Dim XYZ() As Double
Dim IJK() As Double
Dim r() As Double
Dim f() As Double
Dim Dv() As Double
Dim G1() As Byte, M1() As Byte  '刀补缓冲区
Dim XYZ1() As Double
Dim IJK1() As Double
Dim R1() As Double
Dim F1() As Double
Dim G2() As Byte, M2() As Byte '缓冲区2
Dim XYZ2() As Double
Dim IJK2() As Double
Dim R2() As Double
Dim F2() As Double
Dim Dv2() As Double
Dim firstexe As Boolean
Dim rows As Long '记录总行数
Dim i As Integer
Dim arcx As Double, arcy As Double
Dim jindu As Long
Dim maxx As Double, minx As Double, maxy As Double, miny As Double, maxz As Double, minz As Double
Dim offsetx As Double, offsety As Double, pbscale As Double
Dim stopflag As Boolean
Dim stepflag As Boolean
Dim tempxpos As Double, tempypos As Double, tempzpos As Double
Dim tempxpos1 As Double, tempypos1 As Double, tempzpos1 As Double
Dim center As Double

'******************************************************************
'控制卡程序
Private Sub getcrdsta(ByVal csts As Integer)
If (csts And &H1) <> 0 Then
    MsgBox ("bit0")
End If
If (csts And &H2) <> 0 Then
    MsgBox ("bit1")
End If
If (csts And &H4) <> 0 Then
    MsgBox ("bit2")
End If
If (csts And &H8) <> 0 Then
    MsgBox ("bit3")
End If
If (csts And &H10) <> 0 Then
    MsgBox ("bit4")
End If
If (csts And &H40) <> 0 Then
    MsgBox ("bit6")
End If
If (csts And &H80) <> 0 Then
    MsgBox ("bit7")
End If
If (csts And &H100) <> 0 Then
    MsgBox ("bit8")
End If
If (csts And &H200) <> 0 Then
    MsgBox ("bit9")
End If
If (csts And &H800) <> 0 Then
    MsgBox ("bit11")
End If
If (csts And &H1000) <> 0 Then
    MsgBox ("bit12")
End If
If (csts And &H2000) <> 0 Then
    MsgBox ("bit13")
End If
If (csts And &H4000) <> 0 Then
    MsgBox ("bit14")
End If
If (csts And &H8000) <> 0 Then
    MsgBox ("bit15")
End If
End Sub


Private Sub error(ByVal ret_value As Integer)      '返回值处理
Dim csts As Integer
Select Case (ret_value)
    Case -3
        MsgBox ("指令重入")
    Case -1
        MsgBox ("通讯错误!")
                        
    Case 0
'        no error

    Case 1
        Call GT_GetCmdSts(csts)
        Call cmderror(csts)
        'MsgBox ("命令错误!")
        
    Case 2
        MsgBox ("圆弧半径为零或弦长为零!")
        
    Case 3
        MsgBox ("直线长度为零或溢出!")
        
    Case 4
        MsgBox ("(加)速度小于等于零或溢出!")
        
    Case 5
        MsgBox ("圆弧弦长大于直径!")
        
    Case 7
        MsgBox ("Parameters error!")
        
End Select
End Sub

Private Sub cmderror(ByVal csts As Integer)
If (csts And &H1) <> 0 Then
    MsgBox ("命令错误bit0")
End If
If (csts And &H2) <> 0 Then
    MsgBox ("命令错误bit1")
End If
If (csts And &H4) <> 0 Then
    MsgBox ("命令错误bit2")
End If
If (csts And &H8) <> 0 Then
    MsgBox ("命令错误bit3")
End If
If (csts And &H10) <> 0 Then
    MsgBox ("命令错误bit4")
End If
If (csts And &H20) <> 0 Then
    MsgBox ("命令错误bit5")
End If
If (csts And &H40) <> 0 Then
    MsgBox ("命令错误bit6")
End If
If (csts And &H80) <> 0 Then
    MsgBox ("命令错误bit7")
End If
If (csts And &H100) <> 0 Then
    MsgBox ("命令错误bit8")
End If
If (csts And &H200) <> 0 Then
    MsgBox ("命令错误bit9")
End If
If (csts And &H400) <> 0 Then
    MsgBox ("命令错误bit10")
End If
If (csts And &H800) <> 0 Then
    MsgBox ("命令错误bit11")
End If
If (csts And &H1000) <> 0 Then
    MsgBox ("命令错误bit12")
End If
If (csts And &H2000) <> 0 Then
    MsgBox ("命令错误bit13")
End If
If (csts And &H4000) <> 0 Then
    MsgBox ("命令错误bit14")
End If
If (csts And &H8000) <> 0 Then
    MsgBox ("命令错误bit15")
End If
End Sub

Private Sub Initial()     ' 初始化
Call error(GT_Open())
Call error(GT_Reset())
Call GT_AlarmOff(1)
Call GT_AlarmOff(2)
Call GT_AlarmOff(3)

End Sub

Private Sub AxisInitial()
Dim i As Integer
'Dim kp As Double
'kp = 50

'Call error(GT_LmtSns(255))
For i = 1 To 3
Call GT_LmtsOff(i)
'Call error(GT_SetKp(i, kp))
'Call error(GT_Update(i))
Call error(GT_CtrlMode(i, 1))
Call error(GT_StepPulse(i))
Call error(GT_AxisOn(i))
Call error(GT_ClrSts(i))
'Call Delay(0.2)
Next i
End Sub

Private Sub MotionInitial()
Dim startvel As Double, maxvel As Double, stopacc As Double
startvel = 0.3
maxvel = 400
stopacc = 4.8
Call error(GT_SetStrtVel(startvel))
Call error(GT_SetMaxVel(maxvel))
Call error(GT_SetStpAcc(stopacc))
End Sub


Private Sub listempty()
Dim csts As Integer
Call GT_GetCmdSts(csts)
Do While (csts And -32768) <> 0
    Call GT_GetCmdSts(csts)
    DoEvents
Loop
End Sub

Private Sub chkFour_Click()
If chkFour.value = 1 Then
    picXY.Visible = True
    picZX.Visible = True
    picYZ.Visible = True
    Picture1.Height = 5095
    Picture1.Width = 5095
    Picture1.Top = 5225
    Picture1.Left = 5225
Else
    picXY.Visible = False
    picZX.Visible = False
    picYZ.Visible = False
    Picture1.Height = 10200
    Picture1.Width = 10200
    Picture1.Top = 120
    Picture1.Left = 120
End If
End Sub

Private Sub cmdClear_Click()
Picture1.Cls
picXY.Cls
picZX.Cls
picYZ.Cls
End Sub

Private Sub cmdDantiao_Click()
Static G(2) As Byte
Dim x As Long, y As Long, z As Long
Dim r As Double, i As Double, j As Double, k As Double
Static f As Double
Dim temp As String, s As String
Dim csts As Integer
Call error(GT_GetCrdSts(csts))
If (csts And 1) = 0 Then: Exit Sub
temp = txtDantiao.Text
Do While InStr(1, temp, "G", 1)
    Select Case Val(Mid$(temp, InStr(1, temp, "G", 1)   1))
        Case 0 To 3, 6, 33, 34, 35
            G(0) = 100   Val(Mid$(temp, InStr(1, temp, "G", 1)   1)) '为区别"G00"和没有,给00组G代码加100
        Case 17, 18, 19
            G(1) = Val(Mid$(temp, InStr(1, temp, "G", 1)   1))
        Case 90, 91
            G(2) = Val(Mid$(temp, InStr(1, temp, "G", 1)   1))
    End Select
    s = temp
    temp = Mid$(temp, InStr(1, temp, "G", 1)   1)
Loop
temp = s
If InStr(1, temp, "X", 1) <> 0 Then
    If G(2) = 91 Then
        Call GT_GetAtlPos(1, x)
        x = x   1600 * Val(Mid$(temp, InStr(1, temp, "X", 1)   1))
    Else
        x = 1600 * Val(Mid$(temp, InStr(1, temp, "X", 1)   1))
    End If
Else
    Call GT_GetAtlPos(1, x)
End If
If InStr(1, temp, "Y", 1) <> 0 Then
    If G(2) = 91 Then
        Call GT_GetAtlPos(1, y)
        y = y   1600 * Val(Mid$(temp, InStr(1, temp, "Y", 1)   1))
    Else
        y = 1600 * Val(Mid$(temp, InStr(1, temp, "Y", 1)   1))
    End If
Else
    Call GT_GetAtlPos(1, y)
End If
If InStr(1, temp, "Z", 1) <> 0 Then
    If G(2) = 91 Then
        Call GT_GetAtlPos(1, z)
        z = z   1600 * Val(Mid$(temp, InStr(1, temp, "Z", 1)   1))
    Else
        z = 1600 * Val(Mid$(temp, InStr(1, temp, "Z", 1)   1))
    End If
Else
    Call GT_GetAtlPos(1, z)
End If

If InStr(1, temp, "F", 1) <> 0 Then
    f = Val(Mid$(temp, InStr(1, temp, "F", 1)   1))
ElseIf f = 0 Then
    f = 1000
End If

If InStr(1, temp, "R", 1) <> 0 Then
    r = Val(Mid$(temp, InStr(1, temp, "R", 1)   1))
End If

If InStr(1, temp, "I", 1) <> 0 Then
    i = Val(Mid$(temp, InStr(1, temp, "I", 1)   1))
End If

If InStr(1, temp, "J", 1) <> 0 Then
    j = Val(Mid$(temp, InStr(1, temp, "J", 1)   1))
End If

If InStr(1, temp, "K", 1) <> 0 Then
    k = Val(Mid$(temp, InStr(1, temp, "K", 1)   1))
End If

Call GT_SetSynVel(f * 0.0266)
Call GT_SetSynAcc(0.8)

Select Case G(0)
    Case 100
        Call GT_LnXYZG0(x, y, z)
    Case 101
        Call GT_LnXYZ(x, y, z)
    Case 102
        Select Case G(1)
            Case 0, 17
                If r <> 0 Then
                    Call GT_ArcXYP(x, y, r * 1600, 1)
                ElseIf i <> 0 Or j <> 0 Then
                    Call GT_ArcXYP(x, y, Sqr(i ^ 2   j ^ 2) * 1600, 1)
                End If
            Case 18
                If r <> 0 Then
                    Call GT_ArcZXP(z, x, r * 1600, 1)
                ElseIf i <> 0 Or k <> 0 Then
                    Call GT_ArcZXP(z, x, Sqr(i ^ 2   k ^ 2) * 1600, 1)
                End If
            Case 19
                If r <> 0 Then
                    Call GT_ArcYZP(y, z, r * 1600, 1)
                ElseIf j <> 0 Or k <> 0 Then
                    Call GT_ArcYZP(y, z, Sqr(j ^ 2   k ^ 2) * 1600, 1)
                End If
        End Select
    Case 103
        Select Case G(1)
            Case 0, 17
                If r <> 0 Then
                    Call GT_ArcXYP(x, y, r * 1600, 1)
                ElseIf i <> 0 Or j <> 0 Then
                    Call GT_ArcXYP(x, y, Sqr(i ^ 2   j ^ 2) * 1600, 1)
                End If
            Case 18
                If r <> 0 Then
                    Call GT_ArcZXP(z, x, r * 1600, 1)
                ElseIf i <> 0 Or k <> 0 Then
                    Call GT_ArcZXP(z, x, Sqr(i ^ 2   k ^ 2) * 1600, 1)
                End If
            Case 19
                If r <> 0 Then
                    Call GT_ArcYZP(y, z, r * 1600, 1)
                ElseIf j <> 0 Or k <> 0 Then
                    Call GT_ArcYZP(y, z, Sqr(j ^ 2   k ^ 2) * 1600, 1)
                End If
        End Select
End Select
End Sub

Private Sub cmdEdit_Click()
Dim a As String
a = CommonDialog1.FileName
Call Shell("notepad.exe"   " "   a, vbNormalFocus)
End Sub

Private Sub cmdInitial_Click()
Call Initial
Call AxisInitial
Call MotionInitial
End Sub

Private Sub cmdQingchu_Click()
lblX1.Caption = "0.000"
lblX2.Caption = "0.000"
lblY1.Caption = "0.000"
lblY2.Caption = "0.000"
lblz.Caption = "0.000"
End Sub

Private Sub cmdReset_Click()
Call error(GT_Reset())
Call error(GT_Close())
End Sub

Private Sub cmdStart_Click() '启动加工
ReDim G(49, 2), M(49, 1)
ReDim XYZ(49, 2)
ReDim IJK(49, 2)
ReDim f(49)
ReDim r(49)
ReDim G1(49, 2), M1(49, 1)
ReDim XYZ1(49, 2)
ReDim IJK1(49, 2)
ReDim F1(49)
ReDim R1(49)
ReDim G2(49, 2), M2(49, 1)
ReDim XYZ2(49, 2)
ReDim IJK2(49, 2)
ReDim F2(49)
ReDim R2(49)
ReDim Dv2(49)
Dim temp As String
Dim j As Integer
Dim first As Boolean
first = True
If CommonDialog1.FileName = "" Then
    Exit Sub
Else
    tempxpos = 0: tempypos = 0: tempzpos = 0
    tempxpos1 = 0: tempypos1 = 0: tempzpos1 = 0
    'Call Initial
    'Call AxisInitial
    'Call MotionInitial
    Call GT_StrtList
    Call GT_MvXYZ(0, 0, 0, Val(txtVel.Text) * 0.0266, Val(txtAcc.Text) * 0.000000444) '1000mm/min,400mm/s^2
    'Call error(GT_EndList())
    
    firstexe = True
    stopflag = False
    cmdZanting.Enabled = True
    
    StatusBar1.Panels(3).Text = "加工进度:0%"
    jindu = 0
    cmdopen.Enabled = False
    cmdrun.Enabled = False
    
    'Open "temp.txt" For Output As #5
    'Close #5
    Open CommonDialog1.FileName For Input As #2
        
        Do Until EOF(2)
            If first Then
                G(0, 0) = 100: G(0, 1) = 17: G(0, 2) = 40
                For i = 0 To 49
                    If EOF(2) Then: Exit For
                    Line Input #2, temp
                    Do Until (Left$(temp, 1) <> ";") And (Left$(temp, 1) <> "%") And (Left$(temp, 1) <> "O") And (Trim(temp) <> "")
                        If EOF(2) Then: Exit For
                        Line Input #2, temp
                        If stopflag Then: GoTo Stopline
                    Loop
                    Call tiqu(temp)
                Next i
                
                For i = 0 To 49
                    For j = 0 To 2
                        G2(i, j) = G(i, j)
                    Next j
                    XYZ2(i, 0) = XYZ(i, 0)
                    XYZ2(i, 1) = XYZ(i, 1)
                    XYZ2(i, 2) = XYZ(i, 2)
                    IJK2(i, 0) = IJK(i, 0)
                    IJK2(i, 1) = IJK(i, 1)
                    IJK2(i, 2) = IJK(i, 2)
                    F2(i) = f(i)
                    R2(i) = r(i)
                    For j = 0 To 1
                        M2(i, j) = M(i, j)
                    Next j
                Next i
                
                For i = 0 To 48 '及时清零,以免影响提取结果
                    For j = 0 To 2
                        G(i, j) = 0
                    Next j
                    XYZ(i, 0) = 0
                    XYZ(i, 1) = 0
                    XYZ(i, 2) = 0
                    f(i) = 0
                    For j = 0 To 1
                        M(i, j) = 0
                    Next j
                Next i
                
                For i = 0 To 49
                    If EOF(2) Then: Exit For
                    Line Input #2, temp
                    Do Until (Left$(temp, 1) <> ";") And (Left$(temp, 1) <> "%") And (Left$(temp, 1) <> "O") And (Trim(temp) <> "")
                        If EOF(2) Then: Exit For
                        Line Input #2, temp
                        If stopflag Then: GoTo Stopline
                    Loop
                    Call tiqu(temp)
                Next i
                first = False
            Else
                For i = 0 To 48
                    For j = 0 To 2
                        G(i, j) = 0
                    Next j
                    XYZ(i, 0) = 0
                    XYZ(i, 1) = 0
                    XYZ(i, 2) = 0
                    f(i) = 0
                    For j = 0 To 1
                        M(i, j) = 0
                    Next j
                Next i
                For i = 0 To 49
                    If EOF(2) Then: Exit For
                    Line Input #2, temp
                    Do Until (Left$(temp, 1) <> ";") And (Left$(temp, 1) <> "%") And (Left$(temp, 1) <> "O") And (Trim(temp) <> "")
                        If EOF(2) Then: Exit For
                        Line Input #2, temp
                        If stopflag Then: GoTo Stopline
                    Loop
                    Call tiqu(temp)
                Next i
            End If
            'Call GT_InitLookAhead(0.0000016, 14400000, 3240000, 1000, 12, 1600)
            Call GT_InitLookAhead(Val(txtT.Text), Val(txtAcc_max.Text), Val(txtAcc.Text), Val(txtVel.Text) * 1.1, Val(txtN.Text), 1600)
            Call guiji
            Call excute
            firstexe = False
            If stopflag Then: GoTo Stopline
            For i = 0 To 49
                For j = 0 To 2
                    G2(i, j) = G(i, j)
                Next j
                XYZ2(i, 0) = XYZ(i, 0)
                XYZ2(i, 1) = XYZ(i, 1)
                XYZ2(i, 2) = XYZ(i, 2)
                IJK2(i, 0) = IJK(i, 0)
                IJK2(i, 1) = IJK(i, 1)
                IJK2(i, 2) = IJK(i, 2)
                F2(i) = f(i)
                R2(i) = r(i)
                For j = 0 To 1
                        M2(i, j) = M(i, j)
                    Next j
                If (M2(i, 0) = 130) Or (M2(i, 0) = 102) Then
                    'Call GT_InitLookAhead(0.0000016, 14400000, 3240000, 1000, 12, 1600)
                    Call GT_InitLookAhead(Val(txtT.Text), Val(txtAcc_max.Text), Val(txtAcc.Text), Val(txtVel.Text), Val(txtN.Text), 1600)
                    Call guiji
                    Call excute
                    Call GT_EndList
                    Call GT_StrtMtn
                    If stopflag Then: GoTo Stopline
                    
                    StatusBar1.Panels(3).Text = "加工进度:100%"
                    Exit For
                End If
                
            Next i
            
        Loop
Stopline: Close #2
    'Close #5
    temp = ""
    cmdopen.Enabled = True

End If
cmdrun.Enabled = True

ReDim G(0), M(0)
ReDim XYZ(0, 0)
ReDim IJK(0, 0)
ReDim f(0)
ReDim r(0)
ReDim G2(0), M2(0)
ReDim XYZ2(0, 0)
ReDim IJK2(0, 0)
ReDim F2(0)
ReDim R2(0)
cmdZanting.Enabled = False

End Sub

Private Sub excute() '写进缓冲区
Static tempx As Double, tempy As Double, tempz As Double
Static islastg0 As Boolean
Dim rtn As Integer
Dim vel As Double
Dim tempf2 As Double, tempdv2 As Double
'Call error(GT_AddList)
For i = 0 To 49
    Select Case M2(i, 1)
        Case 3
        Case 4
        Case 5
            
    End Select
    
    Do While GT_SetSynVel(F2(i) * 0.027) <> 0
        DoEvents
    Loop
    Do While GT_SetDccVel(Dv2(i) * 0.027) <> 0
        DoEvents
    Loop
    
    Select Case G2(i, 0)
        Case 100
            If i <> 0 Then
                If (XYZ2(i, 0) <> XYZ2(i - 1, 0)) Or (XYZ2(i, 1) <> XYZ2(i - 1, 1)) Or (XYZ2(i, 2) <> XYZ2(i - 1, 2)) Then
                    rtn = GT_LnXYZG0(XYZ2(i, 0) * 1600, XYZ2(i, 1) * 1600, XYZ2(i, 2) * 1600)
                    If rtn <> 0 Then
                        rtn = GT_StrtMtn()
                        Do While GT_LnXYZG0(XYZ2(i, 0) * 1600, XYZ2(i, 1) * 1600, XYZ2(i, 2) * 1600) <> 0
                            DoEvents
                        Loop
                    End If
                End If
            ElseIf (XYZ2(i, 0) <> tempx) Or (XYZ2(i, 1) <> tempy) Or (XYZ2(i, 2) <> tempz) Then
                rtn = GT_LnXYZG0(XYZ2(i, 0) * 1600, XYZ2(i, 1) * 1600, XYZ2(i, 2) * 1600)
                If rtn <> 0 Then
                    rtn = GT_StrtMtn()
                    Do While GT_LnXYZG0(XYZ2(i, 0) * 1600, XYZ2(i, 1) * 1600, XYZ2(i, 2) * 1600) <> 0
                        DoEvents
                    Loop
                End If
            End If
        Case 101
            If i <> 0 Then
                If (XYZ2(i, 0) <> XYZ2(i - 1, 0)) Or (XYZ2(i, 1) <> XYZ2(i - 1, 1)) Or (XYZ2(i, 2) <> XYZ2(i - 1, 2)) Then
                    
                    rtn = GT_LnXYZ(XYZ2(i, 0) * 1600, XYZ2(i, 1) * 1600, XYZ2(i, 2) * 1600)
                    If rtn <> 0 Then
                        rtn = GT_StrtMtn()
                        Do While GT_LnXYZ(XYZ2(i, 0) * 1600, XYZ2(i, 1) * 1600, XYZ2(i, 2) * 1600) <> 0
                            DoEvents
                        Loop
                    End If
                End If
            ElseIf (XYZ2(i, 0) <> tempx) Or (XYZ2(i, 1) <> tempy) Or (XYZ2(i, 2) <> tempz) Then
                rtn = GT_LnXYZ(XYZ2(i, 0) * 1600, XYZ2(i, 1) * 1600, XYZ2(i, 2) * 1600)
                If rtn <> 0 Then
                    rtn = GT_StrtMtn()
                    Do While GT_LnXYZ(XYZ2(i, 0) * 1600, XYZ2(i, 1) * 1600, XYZ2(i, 2) * 1600) <> 0
                        DoEvents
                    Loop
                End If
            End If
        Case 102
            Select Case G2(i, 1)
                Case 17
                    If R2(i) <> 0 Then
                        rtn = GT_ArcXYP(XYZ2(i, 0) * 1600, XYZ2(i, 1) * 1600, R2(i) * 1600, 1)
                        If rtn <> 0 Then
                            rtn = GT_StrtMtn()
                            Do While GT_ArcXYP(XYZ2(i, 0) * 1600, XYZ2(i, 1) * 1600, R2(i) * 1600, 1) <> 0
                                DoEvents
                            Loop
                        End If
                    ElseIf IJK2(i, 0) <> 0 Or IJK2(i, 1) <> 0 Then
                        rtn = GT_ArcXYP(XYZ2(i, 0) * 1600, XYZ2(i, 1) * 1600, Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2) * 1600, 1)
                        If rtn <> 0 Then
                            rtn = GT_StrtMtn()
                            Do While GT_ArcXYP(XYZ2(i, 0) * 1600, XYZ2(i, 1) * 1600, Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2) * 1600, 1) <> 0
                                DoEvents
                            Loop
                        End If
                    End If
                Case 18
                    If R2(i) <> 0 Then
                        rtn = GT_ArcZXP(XYZ2(i, 2) * 1600, XYZ2(i, 0) * 1600, R2(i) * 1600, 1)
                        If rtn <> 0 Then
                            rtn = GT_StrtMtn()
                            Do While GT_ArcZXP(XYZ2(i, 2) * 1600, XYZ2(i, 0) * 1600, R2(i) * 1600, 1) <> 0
                                DoEvents
                            Loop
                        End If
                    ElseIf IJK2(i, 0) <> 0 Or IJK2(i, 2) <> 0 Then
                        rtn = GT_ArcZXP(XYZ2(i, 2) * 1600, XYZ2(i, 0) * 1600, Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2) * 1600, 1)
                        If rtn <> 0 Then
                            rtn = GT_StrtMtn()
                            Do While GT_ArcZXP(XYZ2(i, 2) * 1600, XYZ2(i, 0) * 1600, Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2) * 1600, 1) <> 0
                                DoEvents
                            Loop
                        End If
                    End If
                Case 19
                    If R2(i) <> 0 Then
                        rtn = GT_ArcYZP(XYZ2(i, 1) * 1600, XYZ2(i, 2) * 1600, R2(i) * 1600, 1)
                        If rtn <> 0 Then
                            rtn = GT_StrtMtn()
                            Do While GT_ArcYZP(XYZ2(i, 1) * 1600, XYZ2(i, 2) * 1600, R2(i) * 1600, 1) <> 0
                                DoEvents
                            Loop
                        End If
                    ElseIf IJK2(i, 1) <> 0 Or IJK2(i, 2) <> 0 Then
                        rtn = GT_ArcYZP(XYZ2(i, 1) * 1600, XYZ2(i, 2) * 1600, Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2) * 1600, 1)
                        If rtn <> 0 Then
                            rtn = GT_StrtMtn()
                            Do While GT_ArcYZP(XYZ2(i, 1) * 1600, XYZ2(i, 2) * 1600, Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2) * 1600, 1) <> 0
                                DoEvents
                            Loop
                        End If
                    End If
            End Select
            
        Case 103
            Select Case G2(i, 1)
                Case 17
                    If R2(i) <> 0 Then
                        rtn = GT_ArcXYP(XYZ2(i, 0) * 1600, XYZ2(i, 1) * 1600, R2(i) * 1600, -1)
                        If rtn <> 0 Then
                            rtn = GT_StrtMtn()
                            Do While GT_ArcXYP(XYZ2(i, 0) * 1600, XYZ2(i, 1) * 1600, R2(i) * 1600, -1) <> 0
                                DoEvents
                            Loop
                        End If
                    ElseIf IJK2(i, 0) <> 0 Or IJK2(i, 1) <> 0 Then
                        rtn = GT_ArcXYP(XYZ2(i, 0) * 1600, XYZ2(i, 1) * 1600, Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2) * 1600, -1)
                        If rtn <> 0 Then
                            rtn = GT_StrtMtn()
                            Do While GT_ArcXYP(XYZ2(i, 0) * 1600, XYZ2(i, 1) * 1600, Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2) * 1600, -1) <> 0
                                DoEvents
                            Loop
                        End If
                    End If
                Case 18
                    If R2(i) <> 0 Then
                        rtn = GT_ArcZXP(XYZ2(i, 2) * 1600, XYZ2(i, 0) * 1600, R2(i) * 1600, -1)
                        If rtn <> 0 Then
                            rtn = GT_StrtMtn()
                            Do While GT_ArcZXP(XYZ2(i, 2) * 1600, XYZ2(i, 0) * 1600, R2(i) * 1600, -1) <> 0
                                DoEvents
                            Loop
                        End If
                    ElseIf IJK2(i, 0) <> 0 Or IJK2(i, 2) <> 0 Then
                        rtn = GT_ArcZXP(XYZ2(i, 2) * 1600, XYZ2(i, 0) * 1600, Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2) * 1600, -1)
                        If rtn <> 0 Then
                            rtn = GT_StrtMtn()
                            Do While GT_ArcZXP(XYZ2(i, 2) * 1600, XYZ2(i, 0) * 1600, Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2) * 1600, -1) <> 0
                                DoEvents
                            Loop
                        End If
                    End If
                Case 19
                    If R2(i) <> 0 Then
                        rtn = GT_ArcYZP(XYZ2(i, 1) * 1600, XYZ2(i, 2) * 1600, R2(i) * 1600, -1)
                        If rtn <> 0 Then
                            rtn = GT_StrtMtn()
                            Do While GT_ArcYZP(XYZ2(i, 1) * 1600, XYZ2(i, 2) * 1600, R2(i) * 1600, -1) <> 0
                                DoEvents
                            Loop
                        End If
                    ElseIf IJK2(i, 1) <> 0 Or IJK2(i, 2) <> 0 Then
                        rtn = GT_ArcYZP(XYZ2(i, 1) * 1600, XYZ2(i, 2) * 1600, Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2) * 1600, -1)
                        If rtn <> 0 Then
                            rtn = GT_StrtMtn()
                            Do While GT_ArcYZP(XYZ2(i, 1) * 1600, XYZ2(i, 2) * 1600, Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2) * 1600, -1) <> 0
                                DoEvents
                            Loop
                        End If
                    End If
            End Select
            
    End Select
    If (M2(i, 0) = 130) Or (M2(i, 0) = 102) Then
        tempx = 0
        tempy = 0
        tempz = 0
        StatusBar1.Panels(3).Text = "加工进度:100%"
        Exit Sub
    End If
    If stopflag Then: tempx = 0: tempy = 0: tempz = 0: Exit Sub
    jindu = jindu   1
    
Next i
'GT_EndList
'If firstexe Then
    'Call error(GT_StrtMtn())         '启动缓冲区的命令
'End If
If (jindu * 100 / rows) <= 100 Then '每处理50行更新一次加工进度
    StatusBar1.Panels(3).Text = "加工进度:" & CStr(Int(jindu * 100 / rows)) & "%"
Else
    StatusBar1.Panels(3).Text = "加工进度:100%"
End If
tempx = XYZ2(49, 0)
tempy = XYZ2(49, 1)
tempz = XYZ2(49, 2)
End Sub


Private Sub cmdX1_Click()
Dim X1 As Long
Call GT_GetAtlPos(1, X1)
lblX1.Caption = Format(CDbl(X1) / 1600, "0.000")
End Sub

Private Sub cmdX2_Click()
Dim x2 As Long
Call GT_GetAtlPos(1, x2)
lblX2.Caption = Format(CDbl(x2) / 1600, "0.000")
End Sub

Private Sub cmdY1_Click()
Dim Y1 As Long
Call GT_GetAtlPos(2, Y1)
lblY1.Caption = Format(CDbl(Y1) / 1600, "0.000")
End Sub

Private Sub cmdY2_Click()
Dim y2 As Long
Call GT_GetAtlPos(2, y2)
lblY2.Caption = Format(CDbl(y2) / 1600, "0.000")

End Sub

Private Sub cmdZ_Click()
Dim z As Long
Call GT_GetAtlPos(3, z)
lblz.Caption = Format(CDbl(z) / 1600, "0.000")
End Sub

Private Sub cmdZero_Click()
Call GT_ZeroPos(1)
Call GT_ZeroPos(2)
Call GT_ZeroPos(3)
tempxpos = 0: tempypos = 0: tempzpos = 0
End Sub

Private Sub cmdZf_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim X1 As Long, Y1 As Long, z1 As Long
Dim csts As Integer
'stepflag = True
Call error(GT_GetCrdSts(csts))
If (csts And 1) = 0 Then: Exit Sub
Call error(GT_GetAtlPos(3, z1))
Call error(GT_GetAtlPos(2, Y1))
Call error(GT_GetAtlPos(1, X1))
Call error(GT_StrtList())
Call error(GT_MvXYZ(X1, Y1, z1, Slider2.value * 0.0266, 0.8))
If chkDiandong.value = 1 Then
    Select Case Combo1.ListIndex
        Case 0
            Call GT_LnXYZ(X1, Y1, z1 - Slider1.value * 1600)
        Case 1
            Call GT_LnXYZ(X1, Y1, z1 - Slider1.value * 160)
        Case 2
            Call GT_LnXYZ(X1, Y1, z1 - Slider1.value * 16)
        Case 3
            Call GT_LnXYZ(X1, Y1, z1 - Slider1.value * 1.6)
    End Select
Else
    Call error(GT_LnXYZ(X1, Y1, -800000))
End If
Call error(GT_EndList())
Call error(GT_StrtMtn())
End Sub

Private Sub cmdZf_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim csts As Integer
Call GT_GetCrdSts(csts)
If (csts And 1) = 1 Then: Exit Sub
If chkDiandong.value <> 1 Then: Call GT_StpMtn
End Sub

Private Sub cmdZz_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim X1 As Long, Y1 As Long, z1 As Long
Dim csts As Integer
'stepflag = True
Call error(GT_GetCrdSts(csts))
If (csts And 1) = 0 Then: Exit Sub
Call error(GT_GetAtlPos(3, z1))
Call error(GT_GetAtlPos(2, Y1))
Call error(GT_GetAtlPos(1, X1))
Call error(GT_StrtList())
Call error(GT_MvXYZ(X1, Y1, z1, Slider2.value * 0.0266, 0.8))
If chkDiandong.value = 1 Then
    Select Case Combo1.ListIndex
        Case 0
            Call GT_LnXYZ(X1, Y1, z1   Slider1.value * 1600)
        Case 1
            Call GT_LnXYZ(X1, Y1, z1   Slider1.value * 160)
        Case 2
            Call GT_LnXYZ(X1, Y1, z1   Slider1.value * 16)
        Case 3
            Call GT_LnXYZ(X1, Y1, z1   Slider1.value * 1.6)
    End Select
Else
    Call error(GT_LnXYZ(X1, Y1, 800000))
End If
Call error(GT_EndList())
Call error(GT_StrtMtn())
End Sub

Private Sub cmdZz_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim csts As Integer
Call GT_GetCrdSts(csts)
If (csts And 1) = 1 Then: Exit Sub
If chkDiandong.value <> 1 Then: Call GT_StpMtn
End Sub


Private Sub cmdXf_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim X1 As Long, Y1 As Long, z1 As Long
Dim csts As Integer
'stepflag = True
Call error(GT_GetCrdSts(csts))
If (csts And 1) = 0 Then: Exit Sub
Call error(GT_GetAtlPos(3, z1))
Call error(GT_GetAtlPos(2, Y1))
Call error(GT_GetAtlPos(1, X1))
Call error(GT_StrtList())
Call error(GT_MvXYZ(X1, Y1, z1, Slider2.value * 0.0266, 0.8))
If chkDiandong.value = 1 Then
    Select Case Combo1.ListIndex
        Case 0
            Call GT_LnXYZ(X1 - Slider1.value * 1600, Y1, z1)
        Case 1
            Call GT_LnXYZ(X1 - Slider1.value * 160, Y1, z1)
        Case 2
            Call GT_LnXYZ(X1 - Slider1.value * 16, Y1, z1)
        Case 3
            Call GT_LnXYZ(X1 - Slider1.value * 1.6, Y1, z1)
    End Select
Else
    Call error(GT_LnXYZ(-800000, Y1, z1))
End If
Call error(GT_EndList())
Call error(GT_StrtMtn())
End Sub

Private Sub cmdXf_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim csts As Integer
Call GT_GetCrdSts(csts)
If (csts And 1) = 1 Then: Exit Sub
If chkDiandong.value <> 1 Then: Call GT_StpMtn
End Sub

Private Sub cmdXz_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim X1 As Long, Y1 As Long, z1 As Long
Dim csts As Integer
'stepflag = True
Call GT_GetCrdSts(csts)
If (csts And 1) = 0 Then: Exit Sub
Call GT_GetAtlPos(3, z1)
Call GT_GetAtlPos(2, Y1)
Call GT_GetAtlPos(1, X1)
Call GT_StrtList
Call GT_MvXYZ(X1, Y1, z1, Slider2.value * 0.0266, 0.8)
If chkDiandong.value = 1 Then
    Select Case Combo1.ListIndex
        Case 0
            Call GT_LnXYZ(X1   Slider1.value * 1600, Y1, z1)
        Case 1
            Call GT_LnXYZ(X1   Slider1.value * 160, Y1, z1)
        Case 2
            Call GT_LnXYZ(X1   Slider1.value * 16, Y1, z1)
        Case 3
            Call GT_LnXYZ(X1   Slider1.value * 1.6, Y1, z1)
    End Select
Else
    Call GT_LnXYZ(800000, Y1, z1)
End If
Call GT_EndList
Call GT_StrtMtn
End Sub

Private Sub cmdXz_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim csts As Integer
'stepflag = False
Call GT_GetCrdSts(csts)
If (csts And 1) = 1 Then: Exit Sub
If chkDiandong.value <> 1 Then: Call GT_StpMtn
End Sub

Private Sub cmdYf_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim X1 As Long, Y1 As Long, z1 As Long
Dim csts As Integer
'stepflag = True
Call error(GT_GetCrdSts(csts))
If (csts And 1) = 0 Then: Exit Sub
Call error(GT_GetAtlPos(3, z1))
Call error(GT_GetAtlPos(2, Y1))
Call error(GT_GetAtlPos(1, X1))
Call error(GT_StrtList())
Call error(GT_MvXYZ(X1, Y1, z1, Slider2.value * 0.0266, 0.8))
If chkDiandong.value = 1 Then
    Select Case Combo1.ListIndex
        Case 0
            Call GT_LnXYZ(X1, Y1 - Slider1.value * 1600, z1)
        Case 1
            Call GT_LnXYZ(X1, Y1 - Slider1.value * 160, z1)
        Case 2
            Call GT_LnXYZ(X1, Y1 - Slider1.value * 16, z1)
        Case 3
            Call GT_LnXYZ(X1, Y1 - Slider1.value * 1.6, z1)
    End Select
Else
    Call error(GT_LnXYZ(X1, -800000, z1))
End If
Call error(GT_EndList())
Call error(GT_StrtMtn())
End Sub

Private Sub cmdYf_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim csts As Integer
Call GT_GetCrdSts(csts)
If (csts And 1) = 1 Then: Exit Sub
If chkDiandong.value <> 1 Then: Call GT_StpMtn
End Sub

Private Sub cmdYz_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim X1 As Long, Y1 As Long, z1 As Long
Dim csts As Integer
'stepflag = True
Call error(GT_GetCrdSts(csts))
If (csts And 1) = 0 Then: Exit Sub
Call error(GT_GetAtlPos(3, z1))
Call error(GT_GetAtlPos(2, Y1))
Call error(GT_GetAtlPos(1, X1))
Call error(GT_StrtList())
Call error(GT_MvXYZ(X1, Y1, z1, Slider2.value * 0.0266, 0.8))
If chkDiandong.value = 1 Then
    Select Case Combo1.ListIndex
        Case 0
            Call GT_LnXYZ(X1, Y1   Slider1.value * 1600, z1)
        Case 1
            Call GT_LnXYZ(X1, Y1   Slider1.value * 160, z1)
        Case 2
            Call GT_LnXYZ(X1, Y1   Slider1.value * 16, z1)
        Case 3
            Call GT_LnXYZ(X1, Y1   Slider1.value * 1.6, z1)
    End Select
Else
    Call error(GT_LnXYZ(X1, 800000, z1))
End If
Call error(GT_EndList())
Call error(GT_StrtMtn())
End Sub

Private Sub cmdYz_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim csts As Integer
Call GT_GetCrdSts(csts)
If (csts And 1) = 1 Then: Exit Sub
If chkDiandong.value <> 1 Then: Call GT_StpMtn
End Sub


Private Sub guiji()
Dim j As Integer
Dim i As Long
Dim k As Integer
Dim Vel_end As Double
Dim num As Long
Dim out As Boolean
Static tempx As Double, tempy As Double, tempz As Double
Static tempg0 As Byte, tempg1 As Byte, tempcx As Double, tempcy As Double, tempr As Double, tempf As Double
j = 0: i = 1: k = 1

Do While i < 51
line1:  If j = 0 Then
            If firstexe Then
                Call GT_AddLookData(0, 17, 0, 0, 0, 0, 1000, 0, 0, j, -1, 0)
                j = j   1
                GoTo line1
            Else
                Call GT_AddLookData(tempg0, tempg1, tempr, tempx, tempy, tempz, tempf, tempcx, tempcy, j, -1, 0)
                j = j   1
                GoTo line1
            End If
        End If
    If (M2(i, 0) = 130) Or (M2(i, 0) = 102) Then
        tempx = 0
        tempy = 0
        tempz = 0
        tempg0 = 0
        tempg1 = 17
        tempr = 0
        tempcx = 0
        tempcy = 0
        tempf = 1000
        out = True
        Exit Do
    End If
    Select Case G2(i, 0)
        Case 100
            If GT_AddLookData(0, 17, 0, XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), 0, 0, j, i, 0) = 1 Then
                i = i   1
                GoTo line1
            End If
        Case 101
            If GT_AddLookData(1, 17, 0, XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), 0, 0, j, i, 0) = 1 Then
                i = i   1
                GoTo line1
            End If
        Case 102
            If G2(i, 1) = 17 Then
                
                    If R2(i) <> 0 Then
                        Call yuanxin(XYZ2(i - 1, 0), XYZ2(i - 1, 1), XYZ2(i, 0), XYZ2(i, 1), R2(i), True)
                        If GT_AddLookData(2, 17, Abs(R2(i)), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcx, arcy, j, i, 0) = 1 Then
                            i = i   1
                            GoTo line1
                        End If
                    ElseIf IJK2(i, 0) <> 0 Or IJK2(i, 1) <> 0 Then
                        arcx = XYZ2(i - 1, 0)   IJK2(i, 0)
                        arcy = XYZ2(i - 1, 1)   IJK2(i, 1)
                        If GT_AddLookData(2, 17, Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcx, arcy, j, i, 0) = 1 Then
                            i = i   1
                            GoTo line1
                        End If
                    End If
                
            ElseIf G2(i, 1) = 18 Then
                
                    If R2(i) <> 0 Then
                        Call yuanxin(XYZ2(i - 1, 0), XYZ2(i - 1, 2), XYZ2(i, 0), XYZ2(i, 2), R2(i), True)
                        If GT_AddLookData(2, 18, Abs(R2(i)), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcy, arcx, j, i, 0) = 1 Then
                            i = i   1
                            GoTo line1
                        End If
                    ElseIf IJK2(i, 0) <> 0 Or IJK2(i, 2) <> 0 Then
                        arcx = XYZ2(i - 1, 0)   IJK2(i, 0)
                        arcy = XYZ2(i - 1, 2)   IJK2(i, 2)
                        If GT_AddLookData(2, 18, Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcy, arcx, j, i, 0) = 1 Then
                            i = i   1
                            GoTo line1
                        End If
                    End If
                
            ElseIf G2(i, 1) = 19 Then
                
                    If R2(i) <> 0 Then
                        Call yuanxin(XYZ2(i - 1, 1), XYZ2(i - 1, 2), XYZ2(i, 1), XYZ2(i, 2), R2(i), True)
                        If GT_AddLookData(2, 19, Abs(R2(i)), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcx, arcy, j, i, 0) = 1 Then
                            i = i   1
                            GoTo line1
                        End If
                    ElseIf IJK2(i, 1) <> 0 Or IJK2(i, 2) <> 0 Then
                        arcx = XYZ2(i - 1, 1)   IJK2(i, 1)
                        arcy = XYZ2(i - 1, 2)   IJK2(i, 2)
                        If GT_AddLookData(2, 19, Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcx, arcy, j, i, 0) = 1 Then
                            i = i   1
                            GoTo line1
                        End If
                    End If
                
            End If
        Case 103
            If G2(i, 1) = 17 Then
                
                    If R2(i) <> 0 Then
                        Call yuanxin(XYZ2(i - 1, 0), XYZ2(i - 1, 1), XYZ2(i, 0), XYZ2(i, 1), R2(i), False)
                        If GT_AddLookData(3, 17, Abs(R2(i)), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcx, arcy, j, i, 0) = 1 Then
                            i = i   1
                            GoTo line1
                        End If
                    ElseIf IJK2(i, 0) <> 0 Or IJK2(i, 1) <> 0 Then
                        arcx = XYZ2(i - 1, 0)   IJK2(i, 0)
                        arcy = XYZ2(i - 1, 1)   IJK2(i, 1)
                        If GT_AddLookData(3, 17, Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcx, arcy, j, i, 0) = 1 Then
                            i = i   1
                            GoTo line1
                        End If
                    End If
                
            ElseIf G2(i, 1) = 18 Then
                
                    If R2(i) <> 0 Then
                        Call yuanxin(XYZ2(i - 1, 0), XYZ2(i - 1, 2), XYZ2(i, 0), XYZ2(i, 2), R2(i), False)
                        If GT_AddLookData(3, 18, Abs(R2(i)), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcy, arcx, j, i, 0) = 1 Then
                            i = i   1
                            GoTo line1
                        End If
                    ElseIf IJK2(i, 0) <> 0 Or IJK2(i, 2) <> 0 Then
                        arcx = XYZ2(i - 1, 0)   IJK2(i, 0)
                        arcy = XYZ2(i - 1, 2)   IJK2(i, 2)
                        If GT_AddLookData(3, 18, Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcy, arcx, j, i, 0) = 1 Then
                            i = i   1
                            GoTo line1
                        End If
                    End If
                
            ElseIf G2(i, 1) = 19 Then
                
                    If R2(i) <> 0 Then
                        Call yuanxin(XYZ2(i - 1, 1), XYZ2(i - 1, 2), XYZ2(i, 1), XYZ2(i, 2), R2(i), False)
                        If GT_AddLookData(3, 19, Abs(R2(i)), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcx, arcy, j, i, 0) = 1 Then
                            i = i   1
                            GoTo line1
                        End If
                    ElseIf IJK2(i, 1) <> 0 Or IJK2(i, 2) <> 0 Then
                        arcx = XYZ2(i - 1, 1)   IJK2(i, 1)
                        arcy = XYZ2(i - 1, 2)   IJK2(i, 2)
                        If GT_AddLookData(3, 19, Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcx, arcy, j, i, 0) = 1 Then
                            i = i   1
                            GoTo line1
                        End If
                    End If
                
            End If
    End Select
    j = j   1
    If j > (Val(txtN.Text) - 1) Then: Exit Do
    i = i   1
Loop
Do While True
    If GT_CalVel(Vel_end, num) = 0 Then
        If num >= 51 Then: Exit Do
        If num <> -1 Then
            Dv2(num) = Vel_end
            'Open "temp.txt" For Append As #5
                'Print #5, CStr(num) & "  " & CStr(G2(num, 0)) & " " & CStr(XYZ2(num, 0)) & " " & CStr(XYZ2(num, 1)) & " " & CStr(XYZ2(num, 2)) & " " & F2(num) & " " & CStr(Dv2(num))
            'Close #5
        End If
        
        
    Else
        Exit Do
    End If
    If i >= 51 Then
line3: If M(k, 0) <> 102 And M(k, 0) <> 130 And (out Eqv False) Then
        Select Case G(k, 0)
                Case 100
                    If GT_AddLookData(0, 17, 0, XYZ(k, 0), XYZ(k, 1), XYZ(k, 2), f(k), 0, 0, j, i   k, 0) = 1 Then
                        k = k   1
                        GoTo line3
                    End If
                Case 101
                    If GT_AddLookData(1, 17, 0, XYZ(k, 0), XYZ(k, 1), XYZ(k, 2), f(k), 0, 0, j, i   k, 0) = 1 Then
                        k = k   1
                        GoTo line3
                    End If
                Case 102
                    If G(k, 1) = 17 Then
                        
                            If r(k) <> 0 Then
                                Call yuanxin(XYZ(k - 1, 0), XYZ(k - 1, 1), XYZ(k, 0), XYZ(k, 1), r(k), True)
                                If GT_AddLookData(2, 17, Abs(r(k)), XYZ(k, 0), XYZ(k, 1), XYZ(k, 2), f(k), arcx, arcy, j, i   k, 0) = 1 Then
                                    k = k   1
                                    GoTo line3
                                End If
                            ElseIf IJK(k, 0) <> 0 Or IJK(k, 1) <> 0 Then
                                arcx = XYZ(k - 1, 0)   IJK(k, 0)
                                arcy = XYZ(k - 1, 1)   IJK(k, 1)
                                If GT_AddLookData(2, 17, Sqr(IJK(k, 0) ^ 2   IJK(k, 1) ^ 2), XYZ(k, 0), XYZ(k, 1), XYZ(k, 2), f(k), arcx, arcy, j, i   k, 0) = 1 Then
                                    k = k   1
                                    GoTo line3
                                End If
                            End If
                        
                    ElseIf G(k, 1) = 18 Then
                        
                            If r(k) <> 0 Then
                                Call yuanxin(XYZ(k - 1, 0), XYZ(k - 1, 2), XYZ(k, 0), XYZ(k, 2), r(k), True)
                                If GT_AddLookData(2, 18, Abs(r(k)), XYZ(k, 0), XYZ(k, 1), XYZ(k, 2), f(k), arcy, arcx, j, i   k, 0) = 1 Then
                                    k = k   1
                                    GoTo line3
                                End If
                            ElseIf IJK(k, 0) <> 0 Or IJK(k, 2) <> 0 Then
                                arcx = XYZ(k - 1, 0)   IJK(k, 0)
                                arcy = XYZ(k - 1, 2)   IJK(k, 2)
                                If GT_AddLookData(2, 18, Sqr(IJK(k, 0) ^ 2   IJK(k, 2) ^ 2), XYZ(k, 0), XYZ(k, 1), XYZ(k, 2), f(k), arcy, arcx, j, i   k, 0) = 1 Then
                                    k = k   1
                                    GoTo line3
                                End If
                            End If
                        
                    ElseIf G(k, 1) = 19 Then
                        
                            If r(k) <> 0 Then
                                Call yuanxin(XYZ(k - 1, 1), XYZ(k - 1, 2), XYZ(k, 1), XYZ(k, 2), r(k), True)
                                If GT_AddLookData(2, 19, Abs(r(k)), XYZ(k, 0), XYZ(k, 1), XYZ(k, 2), f(k), arcx, arcy, j, i   k, 0) = 1 Then
                                    k = k   1
                                    GoTo line3
                                End If
                            ElseIf IJK(k, 1) <> 0 Or IJK(k, 2) <> 0 Then
                                arcx = XYZ(k - 1, 1)   IJK(k, 1)
                                arcy = XYZ(k - 1, 2)   IJK(k, 2)
                                If GT_AddLookData(2, 19, Sqr(IJK(k, 1) ^ 2   IJK(k, 2) ^ 2), XYZ(k, 0), XYZ(k, 1), XYZ(k, 2), f(k), arcx, arcy, j, i   k, 0) = 1 Then
                                    k = k   1
                                    GoTo line3
                                End If
                            End If
                        
                    End If
                Case 103
                    If G(k, 1) = 17 Then
                        
                            If r(k) <> 0 Then
                                Call yuanxin(XYZ(k - 1, 0), XYZ(k - 1, 1), XYZ(k, 0), XYZ(k, 1), r(k), False)
                                If GT_AddLookData(3, 17, Abs(r(k)), XYZ(k, 0), XYZ(k, 1), XYZ(k, 2), f(k), arcx, arcy, j, i   k, 0) = 1 Then
                                    k = k   1
                                    GoTo line3
                                End If
                            ElseIf IJK(k, 0) <> 0 Or IJK(k, 1) <> 0 Then
                                arcx = XYZ(k - 1, 0)   IJK(k, 0)
                                arcy = XYZ(k - 1, 1)   IJK(k, 1)
                                If GT_AddLookData(3, 17, Sqr(IJK(k, 0) ^ 2   IJK(k, 1) ^ 2), XYZ(k, 0), XYZ(k, 1), XYZ(k, 2), f(k), arcx, arcy, j, i   k, 0) = 1 Then
                                    k = k   1
                                    GoTo line3
                                End If
                            End If
                        
                    ElseIf G(k, 1) = 18 Then
                        
                            If r(k) <> 0 Then
                                Call yuanxin(XYZ(k - 1, 0), XYZ(k - 1, 2), XYZ(k, 0), XYZ(k, 2), r(k), False)
                                If GT_AddLookData(3, 18, Abs(r(k)), XYZ(k, 0), XYZ(k, 1), XYZ(k, 2), f(k), arcy, arcx, j, i   k, 0) = 1 Then
                                    k = k   1
                                    GoTo line3
                                End If
                            ElseIf IJK(k, 0) <> 0 Or IJK(k, 2) <> 0 Then
                                arcx = XYZ(k - 1, 0)   IJK(k, 0)
                                arcy = XYZ(k - 1, 2)   IJK(k, 2)
                                If GT_AddLookData(3, 18, Sqr(IJK(k, 0) ^ 2   IJK(k, 2) ^ 2), XYZ(k, 0), XYZ(k, 1), XYZ(k, 2), f(k), arcy, arcx, j, i   k, 0) = 1 Then
                                    k = k   1
                                    GoTo line3
                                End If
                            End If
                        
                    ElseIf G(k, 1) = 19 Then
                        
                            If r(k) <> 0 Then
                                Call yuanxin(XYZ(k - 1, 1), XYZ(k - 1, 2), XYZ(k, 1), XYZ(k, 2), r(k), False)
                                If GT_AddLookData(3, 19, Abs(r(k)), XYZ(k, 0), XYZ(k, 1), XYZ(k, 2), f(k), arcx, arcy, j, i   k, 0) = 1 Then
                                    k = k   1
                                    GoTo line3
                                End If
                            ElseIf IJK(k, 1) <> 0 Or IJK(k, 2) <> 0 Then
                                arcx = XYZ(k - 1, 1)   IJK(k, 1)
                                arcy = XYZ(k - 1, 2)   IJK(k, 2)
                                If GT_AddLookData(3, 19, Sqr(IJK(k, 1) ^ 2   IJK(k, 2) ^ 2), XYZ(k, 0), XYZ(k, 1), XYZ(k, 2), f(k), arcx, arcy, j, i   k, 0) = 1 Then
                                    k = k   1
                                    GoTo line3
                                End If
                            End If
                        
                    End If
            End Select
            k = k   1
        End If
    End If
    i = i   1
    Do While True
line2:  If i < 51 Then
            If (M2(i, 0) = 130) Or (M2(i, 0) = 102) Or out Then
                tempx = 0
                tempy = 0
                tempz = 0
                tempg0 = 0
                tempg1 = 17
                tempr = 0
                tempcx = 0
                tempcy = 0
                out = True
                Exit Do
            End If
            Select Case G2(i, 0)
                Case 100
                    If GT_AddLookData(0, 17, 0, XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), 0, 0, j, i, 0) = 1 Then
                        i = i   1
                        GoTo line2
                    Else
                        tempg0 = 0: tempg1 = 17: tempr = 0: tempcx = 0: tempcy = 0: tempf = F2(i)
                        Exit Do
                    End If
                Case 101
                    If GT_AddLookData(1, 17, 0, XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), 0, 0, j, i, 0) = 1 Then
                        i = i   1
                        GoTo line2
                    Else
                        tempg0 = 1: tempg1 = 17: tempr = 0: tempcx = 0: tempcy = 0
                        Exit Do
                    End If
                Case 102
                    If G2(i, 1) = 17 Then
                        
                            If R2(i) <> 0 Then
                                Call yuanxin(XYZ2(i - 1, 0), XYZ2(i - 1, 1), XYZ2(i, 0), XYZ2(i, 1), R2(i), True)
                                If GT_AddLookData(2, 17, Abs(R2(i)), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcx, arcy, j, i, 0) = 1 Then
                                    i = i   1
                                    GoTo line2
                                Else
                                    tempg0 = 2: tempg1 = 17: tempr = Abs(R2(i)): tempcx = arcx: tempcy = arcy:: tempf = F2(i)
                                    Exit Do
                                End If
                            ElseIf IJK2(i, 0) <> 0 Or IJK2(i, 1) <> 0 Then
                                arcx = XYZ2(i - 1, 0)   IJK2(i, 0)
                                arcy = XYZ2(i - 1, 1)   IJK2(i, 1)
                                If GT_AddLookData(2, 17, Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcx, arcy, j, i, 0) = 1 Then
                                    i = i   1
                                    GoTo line2
                                Else
                                    tempg0 = 2: tempg1 = 17: tempr = Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2): tempcx = arcx: tempcy = arcy: tempf = F2(i)
                                    Exit Do
                                End If
                            End If
                        
                    ElseIf G2(i, 1) = 18 Then
                        
                            If R2(i) <> 0 Then
                                Call yuanxin(XYZ2(i - 1, 0), XYZ2(i - 1, 2), XYZ2(i, 0), XYZ2(i, 2), R2(i), True)
                                If GT_AddLookData(2, 18, Abs(R2(i)), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcy, arcx, j, i, 0) = 1 Then
                                    i = i   1
                                    GoTo line2
                                Else
                                    tempg0 = 2: tempg1 = 18: tempr = Abs(R2(i)): tempcx = arcy: tempcy = arcx: tempf = F2(i)
                                    Exit Do
                                End If
                            ElseIf IJK2(i, 0) <> 0 Or IJK2(i, 2) <> 0 Then
                                arcx = XYZ2(i - 1, 0)   IJK2(i, 0)
                                arcy = XYZ2(i - 1, 2)   IJK2(i, 2)
                                If GT_AddLookData(2, 18, Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcy, arcx, j, i, 0) = 1 Then
                                    i = i   1
                                    GoTo line2
                                Else
                                    tempg0 = 2: tempg1 = 18: tempr = Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2): tempcx = arcy: tempcy = arcx: tempf = F2(i)
                                    Exit Do
                                End If
                            End If
                        
                    ElseIf G2(i, 1) = 19 Then
                        
                            If R2(i) <> 0 Then
                                Call yuanxin(XYZ2(i - 1, 1), XYZ2(i - 1, 2), XYZ2(i, 1), XYZ2(i, 2), R2(i), True)
                                If GT_AddLookData(2, 19, Abs(R2(i)), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcx, arcy, j, i, 0) = 1 Then
                                    i = i   1
                                    GoTo line2
                                Else
                                    tempg0 = 2: tempg1 = 19: tempr = Abs(R2(i)): tempcx = arcx: tempcy = arcy: tempf = F2(i)
                                    Exit Do
                                End If
                            ElseIf IJK2(i, 1) <> 0 Or IJK2(i, 2) <> 0 Then
                                arcx = XYZ2(i - 1, 1)   IJK2(i, 1)
                                arcy = XYZ2(i - 1, 2)   IJK2(i, 2)
                                If GT_AddLookData(2, 19, Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcx, arcy, j, i, 0) = 1 Then
                                    i = i   1
                                    GoTo line2
                                Else
                                    tempg0 = 2: tempg1 = 19: tempr = Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2): tempcx = arcx: tempcy = arcy: tempf = F2(i)
                                    Exit Do
                                End If
                            End If
                        
                    End If
                Case 103
                    If G2(i, 1) = 17 Then
                        
                            If R2(i) <> 0 Then
                                Call yuanxin(XYZ2(i - 1, 0), XYZ2(i - 1, 1), XYZ2(i, 0), XYZ2(i, 1), R2(i), False)
                                If GT_AddLookData(3, 17, Abs(R2(i)), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcx, arcy, j, i, 0) = 1 Then
                                    i = i   1
                                    GoTo line2
                                Else
                                    tempg0 = 3: tempg1 = 17: tempr = Abs(R2(i)): tempcx = arcx: tempcy = arcy: tempf = F2(i)
                                    Exit Do
                                End If
                            ElseIf IJK2(i, 0) <> 0 Or IJK2(i, 1) <> 0 Then
                                arcx = XYZ2(i - 1, 0)   IJK2(i, 0)
                                arcy = XYZ2(i - 1, 1)   IJK2(i, 1)
                                If GT_AddLookData(3, 17, Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcx, arcy, j, i, 0) = 1 Then
                                    i = i   1
                                    GoTo line2
                                Else
                                    tempg0 = 3: tempg1 = 17: tempr = Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2): tempcx = arcx: tempcy = arcy: tempf = F2(i)
                                    Exit Do
                                End If
                            End If
                       
                    ElseIf G2(i, 1) = 18 Then
                       
                            If R2(i) <> 0 Then
                                Call yuanxin(XYZ2(i - 1, 0), XYZ2(i - 1, 2), XYZ2(i, 0), XYZ2(i, 2), R2(i), False)
                                If GT_AddLookData(3, 18, Abs(R2(i)), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcy, arcx, j, i, 0) = 1 Then
                                    i = i   1
                                    GoTo line2
                                Else
                                    tempg0 = 3: tempg1 = 18: tempr = Abs(R2(i)): tempcx = arcy: tempcy = arcx: tempf = F2(i)
                                    Exit Do
                                End If
                            ElseIf IJK2(i, 0) <> 0 Or IJK2(i, 2) <> 0 Then
                                arcx = XYZ2(i - 1, 0)   IJK2(i, 0)
                                arcy = XYZ2(i - 1, 2)   IJK2(i, 2)
                                If GT_AddLookData(3, 18, Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcy, arcx, j, i, 0) = 1 Then
                                    i = i   1
                                    GoTo line2
                                Else
                                    tempg0 = 3: tempg1 = 18: tempr = Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2): tempcx = arcy: tempcy = arcx: tempf = F2(i)
                                    Exit Do
                                End If
                            End If
                        
                    ElseIf G2(i, 1) = 19 Then
                        
                            If R2(i) <> 0 Then
                                Call yuanxin(XYZ2(i - 1, 1), XYZ2(i - 1, 2), XYZ2(i, 1), XYZ2(i, 2), R2(i), False)
                                If GT_AddLookData(3, 19, Abs(R2(i)), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcx, arcy, j, i, 0) = 1 Then
                                    i = i   1
                                    GoTo line2
                                Else
                                    tempg0 = 3: tempg1 = 19: tempr = Abs(R2(i)): tempcx = arcx: tempcy = arcy: tempf = F2(i)
                                    Exit Do
                                End If
                            ElseIf IJK2(i, 1) <> 0 Or IJK2(i, 2) <> 0 Then
                                arcx = XYZ2(i - 1, 1)   IJK2(i, 1)
                                arcy = XYZ2(i - 1, 2)   IJK2(i, 2)
                                If GT_AddLookData(3, 19, Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 0), XYZ2(i, 1), XYZ2(i, 2), F2(i), arcx, arcy, j, i, 0) = 1 Then
                                    i = i   1
                                    GoTo line2
                                Else
                                    tempg0 = 3: tempg1 = 19: tempr = Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2): tempcx = arcx: tempcy = arcy: tempf = F2(i)
                                    Exit Do
                                End If
                            End If
                        
                    End If
            End Select
        Else
            Exit Do
        End If
    Loop

Loop

tempx = XYZ2(50, 0)
tempy = XYZ2(50, 1)
tempz = XYZ2(50, 2)
End Sub
'*********************************************************************


Private Sub Delay(s As Double) '延时子程序
Dim StartTimer As Variant
Dim OldTimer As Variant
Dim DelayYear As Long, DelayDay As Integer
StartTimer = Timer
Do
    DoEvents
    If Timer < OldTimer Then
        If DelayDay > 365 Then
            DelayYear = DelayYear   1
            DelayDay = 0
        Else
            DelayDay = DelayDay   1
        End If
        
    End If
    OldTimer = Timer
Loop Until (DelayYear * 365   DelayDay) * 86400   Timer - StartTimer > s
End Sub

Private Sub yuanxin(ByVal a As Double, ByVal b As Double, ByVal C As Double, ByVal d As Double, ByVal r As Double, ByVal dir As Boolean) '已知起点,终点,半径,走向,求圆心
Dim yxx1 As Double, yxy1 As Double, yxx2 As Double, yxy2 As Double
Dim Xs As Double, xe As Double, Ys As Double, ye As Double
Dim xyzhi As Boolean
Dim cenx As Double, ceny As Double, l As Double, e As Double, k As Double
xyzhi = False
cenx = (a   C) / 2
ceny = (b   d) / 2
l = Sqr((a - C) ^ 2   (b - d) ^ 2) / 2
If Abs(r ^ 2 - l ^ 2) < 0.001 Then
    e = 0
Else
    e = Sqr(r ^ 2 - l ^ 2)
End If
If C = a Then
    yxx1 = cenx   e: yxy1 = ceny: yxx2 = cenx - e: yxy2 = ceny
Else
    k = (d - b) / (C - a)
    If k = 0 Then
        yxx1 = cenx: yxy1 = ceny   e: yxx2 = cenx: yxy2 = ceny - e
    ElseIf k < 0 Then
        yxx1 = e * Cos(Atn(1 / (-k)))   cenx
        yxx2 = -e * Cos(Atn(1 / (-k)))   cenx
        yxy1 = e * Sin(Atn(1 / (-k)))   ceny
        yxy2 = -e * Sin(Atn(1 / (-k)))   ceny
    Else
        yxx1 = e * Cos(Atn(1 / (k)))   cenx
        yxx2 = -e * Cos(Atn(1 / (k)))   cenx
        yxy1 = -e * Sin(Atn(1 / (k)))   ceny
        yxy2 = e * Sin(Atn(1 / (k)))   ceny
    End If
End If

If dir Then
    Xs = a - yxx1
    xe = C - yxx1
    Ys = b - yxy1
    ye = d - yxy1
    If (Ys >= 0) And (ye >= 0) And (Xs < xe) Then
        If r > 0 Then
            arcx = yxx1: arcy = yxy1
        Else
            arcx = yxx2: arcy = yxy2
        End If
        xyzhi = True
    ElseIf (Xs = xe) And (Xs < 0) And (xe < 0) And (Ys < ye) Then
        If r > 0 Then
            arcx = yxx1: arcy = yxy1
        Else
            arcx = yxx2: arcy = yxy2
        End If
        xyzhi = True
    ElseIf (Xs = xe) And (Xs > 0) And (xe > 0) And (Ys > ye) Then
        If r > 0 Then
            arcx = yxx1: arcy = yxy1
        Else
            arcx = yxx2: arcy = yxy2
        End If
        xyzhi = True
    ElseIf (Ys > 0) And (ye < 0) And (xe <> Xs) Then
        If (((((ye - Ys) / (xe - Xs)) > 0) And (Xs > xe)) Or ((((ye - Ys) / (xe - Xs)) < 0) And (Xs < xe))) And (((Xs * ye - xe * Ys) / (ye - Ys)) > 0) Then
            If r > 0 Then
                arcx = yxx1: arcy = yxy1
            Else
                arcx = yxx2: arcy = yxy2
            End If
            xyzhi = True
        End If
    ElseIf (Ys <= 0) And (ye <= 0) And (Xs > xe) Then
        If r > 0 Then
            arcx = yxx1: arcy = yxy1
        Else
            arcx = yxx2: arcy = yxy2
        End If
        xyzhi = True
    ElseIf (Ys < 0) And (ye > 0) And (xe <> Xs) Then
        If (((((ye - Ys) / (xe - Xs)) > 0) And (Xs < xe)) Or ((((ye - Ys) / (xe - Xs)) < 0) And (Xs > xe))) And (((Xs * ye - xe * Ys) / (ye - Ys)) < 0) Then
            If r > 0 Then
                arcx = yxx1: arcy = yxy1
            Else
                arcx = yxx2: arcy = yxy2
            End If
            xyzhi = True
        End If
    End If
    
    If (r > 0) And (xyzhi = False) Then
        arcx = yxx2: arcy = yxy2
    ElseIf (r < 0) And (xyzhi = False) Then
        arcx = yxx1: arcy = yxy1
    End If
   
Else
    Xs = a - yxx2
    xe = C - yxx2
    Ys = b - yxy2
    ye = d - yxy2
    If (Ys >= 0) And (ye >= 0) And (Xs > xe) Then
        If r > 0 Then
            arcx = yxx2: arcy = yxy2
        Else
            arcx = yxx1: arcy = yxy1
        End If
        xyzhi = True
    ElseIf (Xs = xe) And (Xs < 0) And (xe < 0) And (Ys > ye) Then
        If r > 0 Then
            arcx = yxx2: arcy = yxy2
        Else
            arcx = yxx1: arcy = yxy1
        End If
        xyzhi = True
    ElseIf (Xs = xe) And (Xs > 0) And (xe > 0) And (Ys < ye) Then
        If r > 0 Then
            arcx = yxx2: arcy = yxy2
        Else
            arcx = yxx1: arcy = yxy1
        End If
        xyzhi = True
    ElseIf (Ys > 0) And (ye < 0) And (xe <> Xs) Then
        If (((((ye - Ys) / (xe - Xs)) > 0) And (Xs > xe)) Or ((((ye - Ys) / (xe - Xs)) < 0) And (Xs < xe))) And (((Xs * ye - xe * Ys) / (ye - Ys)) < 0) Then
            If r > 0 Then
                arcx = yxx2: arcy = yxy2
            Else
                arcx = yxx1: arcy = yxy1
            End If
            xyzhi = True
        End If
    ElseIf (Ys <= 0) And (ye <= 0) And (Xs < xe) Then
        If r > 0 Then
            arcx = yxx2: arcy = yxy2
        Else
            arcx = yxx1: arcy = yxy1
        End If
        xyzhi = True
    ElseIf (Ys < 0) And (ye > 0) And (xe <> Xs) Then
        If (((((ye - Ys) / (xe - Xs)) > 0) And (Xs < xe)) Or ((((ye - Ys) / (xe - Xs)) < 0) And (Xs > xe))) And (((Xs * ye - xe * Ys) / (ye - Ys)) > 0) Then
            If r > 0 Then
                arcx = yxx2: arcy = yxy2
            Else
                arcx = yxx1: arcy = yxy1
            End If
            xyzhi = True
        End If
    End If
    
    If (r > 0) And (xyzhi = False) Then
        arcx = yxx1: arcy = yxy1
    ElseIf (r < 0) And (xyzhi = False) Then
        arcx = yxx2: arcy = yxy2
    End If
    
End If
End Sub

Function hd(ByVal a As Double, ByVal b As Double, ByVal C As Double, ByVal d As Double, ByVal r As Double) As Double '已知起点,终点,半径,求劣弧弧度
Dim l As Double
l = Sqr((a - C) ^ 2   (b - d) ^ 2) / 2 / Abs(r)
If (1 - l) < 0.0000001 Then
    hd = 3.14159
ElseIf r > 0 Then
    hd = Atn(l / Sqr(-l * l   1)) * 2
Else
    hd = 6.283 - Atn(l / Sqr(-l * l   1)) * 2
End If
End Function

Function hd2(ByVal a As Double, ByVal b As Double, ByVal C As Double, ByVal d As Double, ByVal dir As Boolean) As Double '已知起点,终点,走向,求劣弧弧度
Dim qdhd As Double
Dim zdhd As Double
qdhd = qd(a, b, arcx, arcy)
zdhd = qd(C, d, arcx, arcy)
If dir Then
    If qdhd > zdhd Then
        hd2 = qdhd - zdhd
    Else
        hd2 = qdhd - zdhd   6.28318
    End If
Else
    If qdhd > zdhd Then
        hd2 = zdhd - qdhd   6.28318
    Else
        hd2 = zdhd - qdhd
    End If
End If
End Function

Function qd(ByVal sx As Double, ByVal sy As Double, ByVal yx As Double, ByVal yy As Double) As Double '求起点弧度
Dim er As Double
If (sx - yx) > 0 And (sy - yy) >= 0 Then
    qd = Atn((sy - yy) / (sx - yx))
ElseIf (sx - yx) < 0 And (sy - yy) > 0 Then
    qd = 3.14159265 - Atn((sy - yy) / (yx - sx))
ElseIf (sx - yx) < 0 And (sy - yy) <= 0 Then
    qd = 3.14159265   Atn((yy - sy) / (yx - sx))
ElseIf (sx - yx) > 0 And (sy - yy) < 0 Then
    qd = 6.2831853 - Atn((yy - sy) / (sx - yx))
ElseIf (sx - yx) = 0 Then
    If (sy - yy) < 0 Then
        qd = 4.712389
    ElseIf (sy - yy) > 0 Then
        qd = 1.57
    End If
End If
End Function

Private Sub tiqu(ByVal temp As String) '数控代码提取
Dim s As String
Dim j As Integer
temp = Replace(temp, "D", "a", , , 1)
temp = Replace(temp, "E", "a", , , 1)
s = temp 'temp将被改变,设置临时变量保存temp

Do While InStr(1, temp, "G", 1)
    If Asc(Mid$(temp, InStr(1, temp, "G", 1)   1)) >= 48 And Asc(Mid$(temp, InStr(1, temp, "G", 1)   1)) <= 57 Then
        Select Case Val(Mid$(temp, InStr(1, temp, "G", 1)   1))
            Case 0 To 3, 6, 33, 34, 35
                G(i, 0) = 100   Val(Mid$(temp, InStr(1, temp, "G", 1)   1)) '为区别"G00"和没有,给00组G代码加100
            Case 17, 18, 19
                G(i, 1) = Val(Mid$(temp, InStr(1, temp, "G", 1)   1))
            Case 40 To 52, 68, 69
                G(i, 2) = Val(Mid$(temp, InStr(1, temp, "G", 1)   1))
        End Select
    End If
    s = temp
    temp = Mid$(temp, InStr(1, temp, "G", 1)   1)
Loop
 '因为部分G指令为模态,如果该行没有相应G指令,则把上一行的值赋给该行
For j = 0 To 2
    If (G(i, j) = 0) And (i = 0) Then
        G(i, j) = G(50, j)
    ElseIf G(i, j) = 0 Then
        G(i, j) = G(i - 1, j)
    End If
Next j

temp = s
If InStr(1, temp, "X", 1) <> 0 Then
    XYZ(i, 0) = Val(Mid$(temp, InStr(1, temp, "X", 1)   1))
ElseIf i <> 0 Then   '为第一行时不执行
    XYZ(i, 0) = XYZ(i - 1, 0)  '上一行的值赋给该行
ElseIf i = 0 Then
    XYZ(i, 0) = XYZ(50, 0)
End If

If InStr(1, temp, "Y", 1) <> 0 Then
    XYZ(i, 1) = Val(Mid$(temp, InStr(1, temp, "Y", 1)   1))
ElseIf i <> 0 Then
    XYZ(i, 1) = XYZ(i - 1, 1)
ElseIf i = 0 Then
    XYZ(i, 1) = XYZ(50, 1)
End If
                    
If InStr(1, temp, "Z", 1) <> 0 Then
    XYZ(i, 2) = Val(Mid$(temp, InStr(1, temp, "Z", 1)   1))   Val(txtZpz.Text)
ElseIf i <> 0 Then
    XYZ(i, 2) = XYZ(i - 1, 2)
ElseIf i = 0 Then
    XYZ(i, 2) = XYZ(50, 2)
End If
                    
If InStr(1, temp, "F", 1) <> 0 Then
    f(i) = Val(Mid$(temp, InStr(1, temp, "F", 1)   1))
ElseIf i <> 0 And G(i, 0) <> 100 Then
    f(i) = f(i - 1)
ElseIf i = 0 And G(i, 0) <> 100 Then
    f(i) = f(50)
Else
    f(i) = 1000
End If

If InStr(1, temp, "R", 1) <> 0 Then
    r(i) = Val(Mid$(temp, InStr(1, temp, "R", 1)   1))
Else
    r(i) = 0
End If

If InStr(1, temp, "I", 1) <> 0 Then
    IJK(i, 0) = Val(Mid$(temp, InStr(1, temp, "I", 1)   1))
Else
    IJK(i, 0) = 0
End If

If InStr(1, temp, "J", 1) <> 0 Then
    IJK(i, 1) = Val(Mid$(temp, InStr(1, temp, "J", 1)   1))
Else
    IJK(i, 1) = 0
End If

If InStr(1, temp, "K", 1) <> 0 Then
    IJK(i, 2) = Val(Mid$(temp, InStr(1, temp, "K", 1)   1))
Else
    IJK(i, 2) = 0
End If

s = temp
Do While InStr(1, temp, "M", 1)
    Select Case Val(Mid$(temp, InStr(1, temp, "M", 1)   1))
        Case 0 To 2, 30
            M(i, 0) = 100   Val(Mid$(temp, InStr(1, temp, "M", 1)   1)) '为区别"M00"和没有,给00组M代码加100
        Case 3, 4, 5
            M(i, 1) = Val(Mid$(temp, InStr(1, temp, "M", 1)   1))
    End Select
    s = temp
    temp = Mid$(temp, InStr(1, temp, "M", 1)   1)
Loop


If (M(i, 1) = 0) And (i = 0) Then
    M(i, 1) = M(50, 1)
ElseIf M(i, 1) = 0 Then
    M(i, 1) = M(i - 1, 1)
End If
temp = s

If (M(i, 0) = 130) Or (M(i, 0) = 102) Then: Exit Sub
'Open "temp.txt" For Append As #3
'Print #3, CStr(G(i, 0)) & Space$(1) & CStr(G(i, 1)) & Space$(1) & CStr(XYZ(i, 0)) & Space$(1) & CStr(XYZ(i, 1)) & Space$(1) & CStr(XYZ(i, 2)) & Space$(1) & CStr(f(i))
'Close #3
If i = 1 Then '及时清零,以免影响i=49时的提取结果
    For j = 0 To 2
        G(50, j) = 0
    Next j
    For j = 0 To 1
        M(50, j) = 0
    Next j
End If
End Sub

Private Sub pic(ByVal enbig As Double, ByVal st As Double, ByVal en As Double, ByVal tempx As Double, tempy As Double, tempz As Double)
Select Case G2(i, 0)
    Case 102, 103
        If G2(i, 1) = 17 Then
            
                If R2(i) <> 0 Then
                    picXY.Circle (arcx, arcy), Abs(R2(i)), RGB(255, 255, 255), st, en
                    
                    If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                        picZX.Line (arcx - Abs(R2(i)), XYZ2(i, 2))-(arcx   Abs(R2(i)), XYZ2(i, 2)), RGB(255, 255, 255)
                    ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                        If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                            picZX.Line (arcx - Abs(R2(i)), XYZ2(i, 2))-(XYZ2(i - 1, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picZX.Line (arcx - Abs(R2(i)), XYZ2(i, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    ElseIf enbig >= 6.2832 Then
                        If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                            picZX.Line (arcx   Abs(R2(i)), XYZ2(i, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picZX.Line (arcx   Abs(R2(i)), XYZ2(i, 2))-(XYZ2(i - 1, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    Else
                        picZX.Line (XYZ2(i - 1, 0), XYZ2(i, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                    
                    If (enbig >= 7.85398 And st <= 4.71239) Or (st <= 1.5708 And enbig >= 4.71239) Or enbig >= 10.9956 Then
                        picYZ.Line (arcy - Abs(R2(i)), XYZ2(i, 2))-(arcy   Abs(R2(i)), XYZ2(i, 2)), RGB(255, 255, 255)
                    ElseIf enbig >= 7.85398 And st >= 4.71239 Then
                        If XYZ2(i, 1) >= XYZ2(i - 1, 1) Then
                            picYZ.Line (XYZ2(i - 1, 1), XYZ2(i, 2))-(arcy   Abs(R2(i)), XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(arcy   Abs(R2(i)), XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    ElseIf st <= 4.17239 And enbig >= 4.17239 Then
                        If XYZ2(i, 1) >= XYZ2(i - 1, 1) Then
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(arcy - Abs(R2(i)), XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picYZ.Line (XYZ2(i - 1, 1), XYZ2(i, 2))-(arcy - Abs(R2(i)), XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    Else
                        picYZ.Line (XYZ2(i - 1, 1), XYZ2(i, 2))-(XYZ2(i, 1), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                ElseIf (XYZ2(i - 1, 0) = XYZ2(i, 0)) And (XYZ2(i - 1, 1) = XYZ2(i, 1)) Then
                    picXY.Circle (arcx, arcy), Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), RGB(255, 255, 255)
                    picZX.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2))-(arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2)), RGB(255, 255, 255)
                    picYZ.Line (arcy - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2))-(arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2)), RGB(255, 255, 255)
                
                Else
                    picXY.Circle (arcx, arcy), Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), RGB(255, 255, 255), st, en
                    
                    If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                        picZX.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2))-(arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2)), RGB(255, 255, 255)
                    ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                        If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                            picZX.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2))-(XYZ2(i - 1, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picZX.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    ElseIf enbig >= 6.2832 Then
                        If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                            picZX.Line (arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picZX.Line (arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2))-(XYZ2(i - 1, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    Else
                        picZX.Line (XYZ2(i - 1, 0), XYZ2(i, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                    
                    If (enbig >= 7.85398 And st <= 4.71239) Or (st <= 1.5708 And enbig >= 4.71239) Or enbig >= 10.9956 Then
                        picYZ.Line (arcy - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2))-(arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2)), RGB(255, 255, 255)
                    ElseIf enbig >= 7.85398 And st >= 4.71239 Then
                        If XYZ2(i, 1) >= XYZ2(i - 1, 1) Then
                            picYZ.Line (XYZ2(i - 1, 1), XYZ2(i, 2))-(arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    ElseIf st <= 4.17239 And enbig >= 4.17239 Then
                        If XYZ2(i, 1) >= XYZ2(i - 1, 1) Then
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(arcy - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picYZ.Line (XYZ2(i - 1, 1), XYZ2(i, 2))-(arcy - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    Else
                        picYZ.Line (XYZ2(i - 1, 1), XYZ2(i, 2))-(XYZ2(i, 1), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                    
                End If
            
        ElseIf G2(i, 1) = 18 Then
            
                If R2(i) <> 0 Then
                    If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                        picXY.Line (arcx - Abs(R2(i)), XYZ2(i, 1))-(arcx   Abs(R2(i)), XYZ2(i, 1)), RGB(255, 255, 255)
                    ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                        If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                            picXY.Line (arcx - Abs(R2(i)), XYZ2(i, 1))-(XYZ2(i - 1, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        Else
                            picXY.Line (arcx - Abs(R2(i)), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        End If
                    ElseIf enbig >= 6.2832 Then
                        If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                            picXY.Line (arcx   Abs(R2(i)), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        Else
                            picXY.Line (arcx   Abs(R2(i)), XYZ2(i, 1))-(XYZ2(i - 1, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        End If
                    Else
                        picXY.Line (XYZ2(i - 1, 0), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                    End If
                    
                    picZX.Circle (arcx, arcy), Abs(R2(i)), RGB(255, 255, 255), st, en
                    
                    If (enbig >= 7.85398 And st <= 4.71239) Or (st <= 1.5708 And enbig >= 4.71239) Or enbig >= 10.9956 Then
                        picYZ.Line (XYZ2(i, 1), arcy - Abs(R2(i)))-(XYZ2(i, 1), arcy   Abs(R2(i))), RGB(255, 255, 255)
                    ElseIf enbig >= 7.85398 And st >= 4.71239 Then
                        If XYZ2(i, 2) >= XYZ2(i - 1, 2) Then
                            picYZ.Line (XYZ2(i, 1), XYZ2(i - 1, 2))-(XYZ2(i, 1), arcy   Abs(R2(i))), RGB(255, 255, 255)
                        Else
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(XYZ2(i, 1), arcy   Abs(R2(i))), RGB(255, 255, 255)
                        End If
                    ElseIf st <= 4.17239 And enbig >= 4.17239 Then
                        If XYZ2(i, 2) >= XYZ2(i - 1, 2) Then
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(XYZ2(i, 1), arcy - Abs(R2(i))), RGB(255, 255, 255)
                        Else
                            picYZ.Line (XYZ2(i, 1), XYZ2(i - 1, 2))-(XYZ2(i, 1), arcy - Abs(R2(i))), RGB(255, 255, 255)
                        End If
                    Else
                        picYZ.Line (XYZ2(i, 1), XYZ2(i - 1, 2))-(XYZ2(i, 1), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                ElseIf (XYZ2(i - 1, 0) = XYZ2(i, 0)) And (XYZ2(i - 1, 2) = XYZ2(i, 2)) Then
                    picXY.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1)), RGB(255, 255, 255)
                    picZX.Circle (arcx, arcy), Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), RGB(255, 255, 255)
                    picYZ.Line (XYZ2(i, 1), arcy - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 1), arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                Else
                    If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                        picXY.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1)), RGB(255, 255, 255)
                    ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                        If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                            picXY.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(XYZ2(i - 1, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        Else
                            picXY.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        End If
                    ElseIf enbig >= 6.2832 Then
                        If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                            picXY.Line (arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        Else
                            picXY.Line (arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(XYZ2(i - 1, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        End If
                    Else
                        picXY.Line (XYZ2(i - 1, 0), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                    End If
                    
                    picZX.Circle (arcx, arcy), Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), RGB(255, 255, 255), st, en
                    
                    If (enbig >= 7.85398 And st <= 4.71239) Or (st <= 1.5708 And enbig >= 4.71239) Or enbig >= 10.9956 Then
                        picYZ.Line (XYZ2(i, 1), arcy - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 1), arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                    ElseIf enbig >= 7.85398 And st >= 4.71239 Then
                        If XYZ2(i, 2) >= XYZ2(i - 1, 2) Then
                            picYZ.Line (XYZ2(i, 1), XYZ2(i - 1, 2))-(XYZ2(i, 1), arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        Else
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(XYZ2(i, 1), arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        End If
                    ElseIf st <= 4.17239 And enbig >= 4.17239 Then
                        If XYZ2(i, 2) >= XYZ2(i - 1, 2) Then
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(XYZ2(i, 1), arcy - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        Else
                            picYZ.Line (XYZ2(i, 1), XYZ2(i - 1, 2))-(XYZ2(i, 1), arcy - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        End If
                    Else
                        picYZ.Line (XYZ2(i, 1), XYZ2(i - 1, 2))-(XYZ2(i, 1), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                End If
            
        ElseIf G2(i, 1) = 19 Then
            
                If R2(i) <> 0 Then
                    picYZ.Circle (arcx, arcy), Abs(R2(i)), RGB(255, 255, 255), st, en
                    
                    If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                        picXY.Line (XYZ2(i, 0), arcx - Abs(R2(i)))-(XYZ2(i, 0), arcx   Abs(R2(i))), RGB(255, 255, 255)
                    ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                        If XYZ2(i - 1, 1) >= XYZ2(i, 1) Then
                            picXY.Line (XYZ2(i, 0), arcx - Abs(R2(i)))-(XYZ2(i, 0), XYZ2(i - 1, 1)), RGB(255, 255, 255)
                        Else
                            picXY.Line (XYZ2(i, 0), arcx - Abs(R2(i)))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        End If
                    ElseIf enbig >= 6.2832 Then
                        If XYZ2(i - 1, 1) >= XYZ2(i, 1) Then
                            picXY.Line (XYZ2(i, 0), arcx   Abs(R2(i)))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        Else
                            picXY.Line (XYZ2(i, 0), arcx   Abs(R2(i)))-(XYZ2(i, 0), XYZ2(i - 1, 1)), RGB(255, 255, 255)
                        End If
                    Else
                        picXY.Line (XYZ2(i, 0), XYZ2(i - 1, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                    End If
                    
                    If (enbig >= 7.85398 And st <= 4.71239) Or (st <= 1.5708 And enbig >= 4.71239) Or enbig >= 10.9956 Then
                        picZX.Line (XYZ2(i, 0), arcy - Abs(R2(i)))-(XYZ2(i, 0), arcy   Abs(R2(i))), RGB(255, 255, 255)
                    ElseIf enbig >= 7.85398 And st >= 4.71239 Then
                        If XYZ2(i, 2) >= XYZ2(i - 1, 2) Then
                            picZX.Line (XYZ2(i, 0), XYZ2(i - 1, 2))-(XYZ2(i, 0), arcy   Abs(R2(i))), RGB(255, 255, 255)
                        Else
                            picZX.Line (XYZ2(i, 0), XYZ2(i, 2))-(XYZ2(i, 0), arcy   Abs(R2(i))), RGB(255, 255, 255)
                        End If
                    ElseIf st <= 4.17239 And enbig >= 4.17239 Then
                        If XYZ2(i, 2) >= XYZ2(i - 1, 2) Then
                            picZX.Line (XYZ2(i, 0), XYZ2(i, 2))-(XYZ2(i, 0), arcy - Abs(R2(i))), RGB(255, 255, 255)
                        Else
                            picZX.Line (XYZ2(i, 0), XYZ2(i - 1, 2))-(XYZ2(i, 0), arcy - Abs(R2(i))), RGB(255, 255, 255)
                        End If
                    Else
                        picZX.Line (XYZ2(i, 0), XYZ2(i - 1, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                ElseIf (XYZ2(i - 1, 1) = XYZ2(i, 1)) And (XYZ2(i - 1, 2) = XYZ2(i, 2)) Then
                    picYZ.Circle (arcx, arcy), Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2), RGB(255, 255, 255)
                    picXY.Line (XYZ2(i, 0), arcx - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), arcx   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                    picZX.Line (XYZ2(i, 0), arcy - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), arcy   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                Else
                    picYZ.Circle (arcx, arcy), Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2), RGB(255, 255, 255), st, en
                    
                    If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                        picXY.Line (XYZ2(i, 0), arcx - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), arcx   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                    ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                        If XYZ2(i - 1, 1) >= XYZ2(i, 1) Then
                            picXY.Line (XYZ2(i, 0), arcx - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), XYZ2(i - 1, 1)), RGB(255, 255, 255)
                        Else
                            picXY.Line (XYZ2(i, 0), arcx - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        End If
                    ElseIf enbig >= 6.2832 Then
                        If XYZ2(i - 1, 1) >= XYZ2(i, 1) Then
                            picXY.Line (XYZ2(i, 0), arcx   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        Else
                            picXY.Line (XYZ2(i, 0), arcx   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), XYZ2(i - 1, 1)), RGB(255, 255, 255)
                        End If
                    Else
                        picXY.Line (XYZ2(i, 0), XYZ2(i - 1, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                    End If
                    
                    If (enbig >= 7.85398 And st <= 4.71239) Or (st <= 1.5708 And enbig >= 4.71239) Or enbig >= 10.9956 Then
                        picZX.Line (XYZ2(i, 0), arcy - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), arcy   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                    ElseIf enbig >= 7.85398 And st >= 4.71239 Then
                        If XYZ2(i, 2) >= XYZ2(i - 1, 2) Then
                            picZX.Line (XYZ2(i, 0), XYZ2(i - 1, 2))-(XYZ2(i, 0), arcy   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        Else
                            picZX.Line (XYZ2(i, 0), XYZ2(i, 2))-(XYZ2(i, 0), arcy   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        End If
                    ElseIf st <= 4.17239 And enbig >= 4.17239 Then
                        If XYZ2(i, 2) >= XYZ2(i - 1, 2) Then
                            picZX.Line (XYZ2(i, 0), XYZ2(i, 2))-(XYZ2(i, 0), arcy - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        Else
                            picZX.Line (XYZ2(i, 0), XYZ2(i - 1, 2))-(XYZ2(i, 0), arcy - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        End If
                    Else
                        picZX.Line (XYZ2(i, 0), XYZ2(i - 1, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                End If
            
        End If
    Case 104
        If G2(i, 1) = 17 Then
            If i <> 0 Then
                If R2(i) <> 0 Then
                    picXY.Circle (arcx, arcy), Abs(R2(i)), RGB(255, 255, 255), st, en
                    
                    If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                        picZX.Line (arcx - Abs(R2(i)), XYZ2(i, 2))-(arcx   Abs(R2(i)), XYZ2(i, 2)), RGB(255, 255, 255)
                    ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                        If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                            picZX.Line (arcx - Abs(R2(i)), XYZ2(i, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picZX.Line (arcx - Abs(R2(i)), XYZ2(i, 2))-(XYZ2(i - 1, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    ElseIf enbig >= 6.2832 Then
                        If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                            picZX.Line (arcx   Abs(R2(i)), XYZ2(i, 2))-(XYZ2(i - 1, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picZX.Line (arcx   Abs(R2(i)), XYZ2(i, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    Else
                        picZX.Line (XYZ2(i - 1, 0), XYZ2(i, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                    
                    If (enbig >= 7.85398 And st <= 4.71239) Or (st <= 1.5708 And enbig >= 4.71239) Or enbig >= 10.9956 Then
                        picYZ.Line (arcy - Abs(R2(i)), XYZ2(i, 2))-(arcy   Abs(R2(i)), XYZ2(i, 2)), RGB(255, 255, 255)
                    ElseIf enbig >= 7.85398 And st >= 4.71239 Then
                        If XYZ2(i, 1) >= XYZ2(i - 1, 1) Then
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(arcy   Abs(R2(i)), XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picYZ.Line (XYZ2(i - 1, 1), XYZ2(i, 2))-(arcy   Abs(R2(i)), XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    ElseIf st <= 4.17239 And enbig >= 4.17239 Then
                        If XYZ2(i, 1) >= XYZ2(i - 1, 1) Then
                            picYZ.Line (XYZ2(i - 1, 1), XYZ2(i, 2))-(arcy - Abs(R2(i)), XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(arcy - Abs(R2(i)), XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    Else
                        picYZ.Line (XYZ2(i - 1, 1), XYZ2(i, 2))-(XYZ2(i, 1), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                Else
                    picXY.Circle (arcx, arcy), Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), RGB(255, 255, 255), st, en
                    
                    If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                        picZX.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2))-(arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2)), RGB(255, 255, 255)
                    ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                        If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                            picZX.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picZX.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2))-(XYZ2(i - 1, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    ElseIf enbig >= 6.2832 Then
                        If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                            picZX.Line (arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2))-(XYZ2(i - 1, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picZX.Line (arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    Else
                        picZX.Line (XYZ2(i - 1, 0), XYZ2(i, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                    
                    If (enbig >= 7.85398 And st <= 4.71239) Or (st <= 1.5708 And enbig >= 4.71239) Or enbig >= 10.9956 Then
                        picYZ.Line (arcy - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2))-(arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2)), RGB(255, 255, 255)
                    ElseIf enbig >= 7.85398 And st >= 4.71239 Then
                        If XYZ2(i, 1) >= XYZ2(i - 1, 1) Then
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picYZ.Line (XYZ2(i - 1, 1), XYZ2(i, 2))-(arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    ElseIf st <= 4.17239 And enbig >= 4.17239 Then
                        If XYZ2(i, 1) >= XYZ2(i - 1, 1) Then
                            picYZ.Line (XYZ2(i - 1, 1), XYZ2(i, 2))-(arcy - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(arcy - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    Else
                        picYZ.Line (XYZ2(i - 1, 1), XYZ2(i, 2))-(XYZ2(i, 1), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                End If
            Else
                If R2(i) <> 0 Then
                    picXY.Circle (arcx, arcy), Abs(R2(i)), RGB(255, 255, 255), st, en
                
                    If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                        picZX.Line (arcx - Abs(R2(i)), XYZ2(i, 2))-(arcx   Abs(R2(i)), XYZ2(i, 2)), RGB(255, 255, 255)
                    ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                        If tempx >= XYZ2(i, 0) Then
                            picZX.Line (arcx - Abs(R2(i)), XYZ2(i, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picZX.Line (arcx - Abs(R2(i)), XYZ2(i, 2))-(tempx, XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    ElseIf enbig >= 6.2832 Then
                        If tempx >= XYZ2(i, 0) Then
                            picZX.Line (arcx   Abs(R2(i)), XYZ2(i, 2))-(tempx, XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picZX.Line (arcx   Abs(R2(i)), XYZ2(i, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    Else
                        picZX.Line (tempx, XYZ2(i, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                    
                    If (enbig >= 7.85398 And st <= 4.71239) Or (st <= 1.5708 And enbig >= 4.71239) Or enbig >= 10.9956 Then
                        picYZ.Line (arcy - Abs(R2(i)), XYZ2(i, 2))-(arcy   Abs(R2(i)), XYZ2(i, 2)), RGB(255, 255, 255)
                    ElseIf enbig >= 7.85398 And st >= 4.71239 Then
                        If XYZ2(i, 1) >= tempy Then
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(arcy   Abs(R2(i)), XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picYZ.Line (tempy, XYZ2(i, 2))-(arcy   Abs(R2(i)), XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    ElseIf st <= 4.17239 And enbig >= 4.17239 Then
                        If XYZ2(i, 1) >= tempy Then
                            picYZ.Line (tempy, XYZ2(i, 2))-(arcy - Abs(R2(i)), XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(arcy - Abs(R2(i)), XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    Else
                        picYZ.Line (tempy, XYZ2(i, 2))-(XYZ2(i, 1), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                Else
                    picXY.Circle (arcx, arcy), Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), RGB(255, 255, 255), st, en
                
                    If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                        picZX.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2))-(arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2)), RGB(255, 255, 255)
                    ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                        If tempx >= XYZ2(i, 0) Then
                            picZX.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picZX.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2))-(tempx, XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    ElseIf enbig >= 6.2832 Then
                        If tempx >= XYZ2(i, 0) Then
                            picZX.Line (arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2))-(tempx, XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picZX.Line (arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    Else
                        picZX.Line (tempx, XYZ2(i, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                    
                    If (enbig >= 7.85398 And st <= 4.71239) Or (st <= 1.5708 And enbig >= 4.71239) Or enbig >= 10.9956 Then
                        picYZ.Line (arcy - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2))-(arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2)), RGB(255, 255, 255)
                    ElseIf enbig >= 7.85398 And st >= 4.71239 Then
                        If XYZ2(i, 1) >= tempy Then
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picYZ.Line (tempy, XYZ2(i, 2))-(arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    ElseIf st <= 4.17239 And enbig >= 4.17239 Then
                        If XYZ2(i, 1) >= tempy Then
                            picYZ.Line (tempy, XYZ2(i, 2))-(arcy - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2)), RGB(255, 255, 255)
                        Else
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(arcy - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                    Else
                        picYZ.Line (tempy, XYZ2(i, 2))-(XYZ2(i, 1), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                End If
            End If
        ElseIf G2(i, 1) = 18 Then
            If i <> 0 Then
                If R2(i) <> 0 Then
                    If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                        picXY.Line (arcx - Abs(R2(i)), XYZ2(i, 1))-(arcx   Abs(R2(i)), XYZ2(i, 1)), RGB(255, 255, 255)
                    ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                        If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                            picXY.Line (arcx - Abs(R2(i)), XYZ2(i, 1))-(XYZ2(i - 1, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        Else
                            picXY.Line (arcx - Abs(R2(i)), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        End If
                    ElseIf enbig >= 6.2832 Then
                        If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                            picXY.Line (arcx   Abs(R2(i)), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        Else
                            picXY.Line (arcx   Abs(R2(i)), XYZ2(i, 1))-(XYZ2(i - 1, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        End If
                    Else
                        picXY.Line (XYZ2(i - 1, 0), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                    End If
                    
                    picZX.Circle (arcx, arcy), Abs(R2(i)), RGB(255, 255, 255), st, en
                    
                    If (enbig >= 7.85398 And st <= 4.71239) Or (st <= 1.5708 And enbig >= 4.71239) Or enbig >= 10.9956 Then
                        picYZ.Line (XYZ2(i, 1), arcy - Abs(R2(i)))-(XYZ2(i, 1), arcy   Abs(R2(i))), RGB(255, 255, 255)
                    ElseIf enbig >= 7.85398 And st >= 4.71239 Then
                        If XYZ2(i, 2) >= XYZ2(i - 1, 2) Then
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(XYZ2(i, 1), arcy   Abs(R2(i))), RGB(255, 255, 255)
                        Else
                            picYZ.Line (XYZ2(i, 1), XYZ2(i - 1, 2))-(XYZ2(i, 1), arcy   Abs(R2(i))), RGB(255, 255, 255)
                        End If
                    ElseIf st <= 4.17239 And enbig >= 4.17239 Then
                        If XYZ2(i, 2) >= XYZ2(i - 1, 2) Then
                            picYZ.Line (XYZ2(i, 1), XYZ2(i - 1, 2))-(XYZ2(i, 1), arcy - Abs(R2(i))), RGB(255, 255, 255)
                        Else
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(XYZ2(i, 1), arcy - Abs(R2(i))), RGB(255, 255, 255)
                        End If
                    Else
                        picYZ.Line (XYZ2(i, 1), XYZ2(i - 1, 2))-(XYZ2(i, 1), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                Else
                    If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                        picXY.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1)), RGB(255, 255, 255)
                    ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                        If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                            picXY.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        Else
                            picXY.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(XYZ2(i - 1, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        End If
                    ElseIf enbig >= 6.2832 Then
                        If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                            picXY.Line (arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(XYZ2(i - 1, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        Else
                            picXY.Line (arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        End If
                    Else
                        picXY.Line (XYZ2(i - 1, 0), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                    End If
                    
                    picZX.Circle (arcx, arcy), Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), RGB(255, 255, 255), st, en
                    
                    If (enbig >= 7.85398 And st <= 4.71239) Or (st <= 1.5708 And enbig >= 4.71239) Or enbig >= 10.9956 Then
                        picYZ.Line (XYZ2(i, 1), arcy - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 1), arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                    ElseIf enbig >= 7.85398 And st >= 4.71239 Then
                        If XYZ2(i, 2) >= XYZ2(i - 1, 2) Then
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(XYZ2(i, 1), arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        Else
                            picYZ.Line (XYZ2(i, 1), XYZ2(i - 1, 2))-(XYZ2(i, 1), arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        End If
                    ElseIf st <= 4.17239 And enbig >= 4.17239 Then
                        If XYZ2(i, 2) >= XYZ2(i - 1, 2) Then
                            picYZ.Line (XYZ2(i, 1), XYZ2(i - 1, 2))-(XYZ2(i, 1), arcy - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        Else
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(XYZ2(i, 1), arcy - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        End If
                    Else
                        picYZ.Line (XYZ2(i, 1), XYZ2(i - 1, 2))-(XYZ2(i, 1), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                End If
            Else
                If R2(i) <> 0 Then
                    If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                        picXY.Line (arcx - Abs(R2(i)), XYZ2(i, 1))-(arcx   Abs(R2(i)), XYZ2(i, 1)), RGB(255, 255, 255)
                    ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                        If tempx >= XYZ2(i, 0) Then
                            picXY.Line (arcx - Abs(R2(i)), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        Else
                            picXY.Line (arcx - Abs(R2(i)), XYZ2(i, 1))-(tempx, XYZ2(i, 1)), RGB(255, 255, 255)
                        End If
                    ElseIf enbig >= 6.2832 Then
                        If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                            picXY.Line (arcx   Abs(R2(i)), XYZ2(i, 1))-(tempx, XYZ2(i, 1)), RGB(255, 255, 255)
                        Else
                            picXY.Line (arcx   Abs(R2(i)), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        End If
                    Else
                        picXY.Line (tempx, XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                    End If
                    
                    picZX.Circle (arcx, arcy), Abs(R2(i)), RGB(255, 255, 255), st, en
                    
                    If (enbig >= 7.85398 And st <= 4.71239) Or (st <= 1.5708 And enbig >= 4.71239) Or enbig >= 10.9956 Then
                        picYZ.Line (XYZ2(i, 1), arcy - Abs(R2(i)))-(XYZ2(i, 1), arcy   Abs(R2(i))), RGB(255, 255, 255)
                    ElseIf enbig >= 7.85398 And st >= 4.71239 Then
                        If XYZ2(i, 2) >= tempz Then
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(XYZ2(i, 1), arcy   Abs(R2(i))), RGB(255, 255, 255)
                        Else
                            picYZ.Line (XYZ2(i, 1), tempz)-(XYZ2(i, 1), arcy   Abs(R2(i))), RGB(255, 255, 255)
                        End If
                    ElseIf st <= 4.17239 And enbig >= 4.17239 Then
                        If XYZ2(i, 2) >= tempz Then
                            picYZ.Line (XYZ2(i, 1), tempz)-(XYZ2(i, 1), arcy - Abs(R2(i))), RGB(255, 255, 255)
                        Else
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(XYZ2(i, 1), arcy - Abs(R2(i))), RGB(255, 255, 255)
                        End If
                    Else
                        picYZ.Line (XYZ2(i, 1), tempz)-(XYZ2(i, 1), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                Else
                    If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                        picXY.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1)), RGB(255, 255, 255)
                    ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                        If tempx >= XYZ2(i, 0) Then
                            picXY.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        Else
                            picXY.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(tempx, XYZ2(i, 1)), RGB(255, 255, 255)
                        End If
                    ElseIf enbig >= 6.2832 Then
                        If tempx >= XYZ2(i, 0) Then
                            picXY.Line (arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(tempx, XYZ2(i, 1)), RGB(255, 255, 255)
                        Else
                            picXY.Line (arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        End If
                    Else
                        picXY.Line (tempx, XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                    End If
                    
                    picZX.Circle (arcx, arcy), Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), RGB(255, 255, 255), st, en
                    
                    If (enbig >= 7.85398 And st <= 4.71239) Or (st <= 1.5708 And enbig >= 4.71239) Or enbig >= 10.9956 Then
                        picYZ.Line (XYZ2(i, 1), arcy - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 1), arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                    ElseIf enbig >= 7.85398 And st >= 4.71239 Then
                        If XYZ2(i, 2) >= tempz Then
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(XYZ2(i, 1), arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        Else
                            picYZ.Line (XYZ2(i, 1), tempz)-(XYZ2(i, 1), arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        End If
                    ElseIf st <= 4.17239 And enbig >= 4.17239 Then
                        If XYZ2(i, 2) >= tempz Then
                            picYZ.Line (XYZ2(i, 1), tempz)-(XYZ2(i, 1), arcy - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        Else
                            picYZ.Line (XYZ2(i, 1), XYZ2(i, 2))-(XYZ2(i, 1), arcy - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        End If
                    Else
                        picYZ.Line (XYZ2(i, 1), tempz)-(XYZ2(i, 1), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                End If
            End If
        ElseIf G2(i, 1) = 19 Then
            If i <> 0 Then
                If R2(i) <> 0 Then
                    picYZ.Circle (arcx, arcy), Abs(R2(i)), RGB(255, 255, 255), st, en
                    If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                        picXY.Line (XYZ2(i, 0), arcx - Abs(R2(i)))-(XYZ2(i, 0), arcx   Abs(R2(i))), RGB(255, 255, 255)
                    ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                        If XYZ2(i - 1, 1) >= XYZ2(i, 1) Then
                            picXY.Line (XYZ2(i, 0), arcx - Abs(R2(i)))-(XYZ2(i, 0), XYZ2(i - 1, 1)), RGB(255, 255, 255)
                        Else
                            Picture1.Line (XYZ2(i, 0), arcx - Abs(R2(i)))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        End If
                    ElseIf enbig >= 6.2832 Then
                        If XYZ2(i - 1, 1) >= XYZ2(i, 1) Then
                            picXY.Line (XYZ2(i, 0), arcx   Abs(R2(i)))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        Else
                            picXY.Line (XYZ2(i, 0), arcx   Abs(R2(i)))-(XYZ2(i, 0), XYZ2(i - 1, 1)), RGB(255, 255, 255)
                        End If
                    Else
                        picXY.Line (XYZ2(i, 0), XYZ2(i - 1, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                    End If
                    
                    If (enbig >= 7.85398 And st <= 4.71239) Or (st <= 1.5708 And enbig >= 4.71239) Or enbig >= 10.9956 Then
                        picZX.Line (XYZ2(i, 0), arcy - Abs(R2(i)))-(XYZ2(i, 0), arcy   Abs(R2(i))), RGB(255, 255, 255)
                    ElseIf enbig >= 7.85398 And st >= 4.71239 Then
                        If XYZ2(i, 2) >= XYZ2(i - 1, 2) Then
                            picZX.Line (XYZ2(i, 0), XYZ2(i, 2))-(XYZ2(i, 0), arcy   Abs(R2(i))), RGB(255, 255, 255)
                        Else
                            picZX.Line (XYZ2(i, 0), XYZ2(i - 1, 2))-(XYZ2(i, 0), arcy   Abs(R2(i))), RGB(255, 255, 255)
                        End If
                    ElseIf st <= 4.17239 And enbig >= 4.17239 Then
                        If XYZ2(i, 2) >= XYZ2(i - 1, 2) Then
                            picZX.Line (XYZ2(i, 0), XYZ2(i - 1, 2))-(XYZ2(i, 0), arcy - Abs(R2(i))), RGB(255, 255, 255)
                        Else
                            picZX.Line (XYZ2(i, 0), XYZ2(i, 2))-(XYZ2(i, 0), arcy - Abs(R2(i))), RGB(255, 255, 255)
                        End If
                    Else
                        picZX.Line (XYZ2(i, 0), XYZ2(i - 1, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                Else
                    picYZ.Circle (arcx, arcy), Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2), RGB(255, 255, 255), st, en
                    
                    If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                        picXY.Line (XYZ2(i, 0), arcx - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), arcx   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                    ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                        If XYZ2(i - 1, 1) >= XYZ2(i, 1) Then
                            picXY.Line (XYZ2(i, 0), arcx - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        Else
                            picXY.Line (XYZ2(i, 0), arcx - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), XYZ2(i - 1, 1)), RGB(255, 255, 255)
                        End If
                    ElseIf enbig >= 6.2832 Then
                        If XYZ2(i - 1, 1) >= XYZ2(i, 1) Then
                            picXY.Line (XYZ2(i, 0), arcx   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), XYZ2(i - 1, 1)), RGB(255, 255, 255)
                        Else
                            picXY.Line (XYZ2(i, 0), arcx   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        End If
                    Else
                        picXY.Line (XYZ2(i, 0), XYZ2(i - 1, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                    End If
                    
                    If (enbig >= 7.85398 And st <= 4.71239) Or (st <= 1.5708 And enbig >= 4.71239) Or enbig >= 10.9956 Then
                        picZX.Line (XYZ2(i, 0), arcy - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), arcy   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                    ElseIf enbig >= 7.85398 And st >= 4.71239 Then
                        If XYZ2(i, 2) >= XYZ2(i - 1, 2) Then
                            picZX.Line (XYZ2(i, 0), XYZ2(i, 2))-(XYZ2(i, 0), arcy   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        Else
                            picZX.Line (XYZ2(i, 0), XYZ2(i - 1, 2))-(XYZ2(i, 0), arcy   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        End If
                    ElseIf st <= 4.17239 And enbig >= 4.17239 Then
                        If XYZ2(i, 2) >= XYZ2(i - 1, 2) Then
                            picZX.Line (XYZ2(i, 0), XYZ2(i - 1, 2))-(XYZ2(i, 0), arcy - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        Else
                            picZX.Line (XYZ2(i, 0), XYZ2(i, 2))-(XYZ2(i, 0), arcy - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        End If
                    Else
                        picZX.Line (XYZ2(i, 0), XYZ2(i - 1, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                End If
            Else
                If R2(i) <> 0 Then
                    picYZ.Circle (arcx, arcy), Abs(R2(i)), RGB(255, 255, 255), st, en
                    
                    If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                        picXY.Line (XYZ2(i, 0), arcx - Abs(R2(i)))-(XYZ2(i, 0), arcx   Abs(R2(i))), RGB(255, 255, 255)
                    ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                        If tempy >= XYZ2(i, 1) Then
                            picXY.Line (XYZ2(i, 0), arcx - Abs(R2(i)))-(XYZ2(i, 0), tempy), RGB(255, 255, 255)
                        Else
                            picXY.Line (XYZ2(i, 0), arcx - Abs(R2(i)))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        End If
                    ElseIf enbig >= 6.2832 Then
                        If tempy >= XYZ2(i, 1) Then
                            picXY.Line (XYZ2(i, 0), arcx   Abs(R2(i)))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        Else
                            picXY.Line (XYZ2(i, 0), arcx   Abs(R2(i)))-(XYZ2(i, 0), tempy), RGB(255, 255, 255)
                        End If
                    Else
                        picXY.Line (XYZ2(i, 0), tempy)-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                    End If
                    
                    If (enbig >= 7.85398 And st <= 4.71239) Or (st <= 1.5708 And enbig >= 4.71239) Or enbig >= 10.9956 Then
                        picZX.Line (XYZ2(i, 0), arcy - Abs(R2(i)))-(XYZ2(i, 0), arcy   Abs(R2(i))), RGB(255, 255, 255)
                    ElseIf enbig >= 7.85398 And st >= 4.71239 Then
                        If XYZ2(i, 2) >= tempz Then
                            picZX.Line (XYZ2(i, 0), XYZ2(i, 2))-(XYZ2(i, 0), arcy   Abs(R2(i))), RGB(255, 255, 255)
                        Else
                            picZX.Line (XYZ2(i, 0), tempz)-(XYZ2(i, 0), arcy   Abs(R2(i))), RGB(255, 255, 255)
                        End If
                    ElseIf st <= 4.17239 And enbig >= 4.17239 Then
                        If XYZ2(i, 2) >= tempz Then
                            picZX.Line (XYZ2(i, 0), tempz)-(XYZ2(i, 0), arcy - Abs(R2(i))), RGB(255, 255, 255)
                        Else
                            picZX.Line (XYZ2(i, 0), XYZ2(i, 2))-(XYZ2(i, 0), arcy - Abs(R2(i))), RGB(255, 255, 255)
                        End If
                    Else
                        picZX.Line (XYZ2(i, 0), tempz)-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                Else
                    picYZ.Circle (arcx, arcy), Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2), RGB(255, 255, 255), st, en
                    
                    If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                        picXY.Line (XYZ2(i, 0), arcx - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), arcx   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                    ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                        If tempy >= XYZ2(i, 1) Then
                            picXY.Line (XYZ2(i, 0), arcx - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), tempy), RGB(255, 255, 255)
                        Else
                            picXY.Line (XYZ2(i, 0), arcx - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        End If
                    ElseIf enbig >= 6.2832 Then
                        If tempy >= XYZ2(i, 1) Then
                            picXY.Line (XYZ2(i, 0), arcx   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                        Else
                            picXY.Line (XYZ2(i, 0), arcx   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), tempy), RGB(255, 255, 255)
                        End If
                    Else
                        picXY.Line (XYZ2(i, 0), tempy)-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                    End If
                    
                    If (enbig >= 7.85398 And st <= 4.71239) Or (st <= 1.5708 And enbig >= 4.71239) Or enbig >= 10.9956 Then
                        picZX.Line (XYZ2(i, 0), arcy - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), arcy   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                    ElseIf enbig >= 7.85398 And st >= 4.71239 Then
                        If XYZ2(i, 2) >= tempz Then
                            picZX.Line (XYZ2(i, 0), XYZ2(i, 2))-(XYZ2(i, 0), arcy   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        Else
                            picZX.Line (XYZ2(i, 0), tempz)-(XYZ2(i, 0), arcy   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        End If
                    ElseIf st <= 4.17239 And enbig >= 4.17239 Then
                        If XYZ2(i, 2) >= tempz Then
                            picZX.Line (XYZ2(i, 0), tempz)-(XYZ2(i, 0), arcy - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        Else
                            picZX.Line (XYZ2(i, 0), XYZ2(i, 2))-(XYZ2(i, 0), arcy - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        End If
                    Else
                        picZX.Line (XYZ2(i, 0), tempz)-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                    End If
                End If
            End If
        End If
End Select
End Sub


Private Sub process() '仿真画图
Static tempx As Double, tempy As Double, tempz As Double
Dim st As Double, en As Double
Dim X1 As Double, Y1 As Double, z1 As Double, xj1 As Double, yj1 As Double, zj1 As Double
Dim a As Double, jlhd As Double
Dim enbig As Double
DoEvents
For i = 1 To 50
    'Select Case M2(i, 1)
        'Case 3
            'lblZhuzhou.Caption = "(仿真)正转"
        'Case 4
            'lblZhuzhou.Caption = "(仿真)反转"
        'Case 5
            'lblZhuzhou.Caption = "关"
    'End Select
    Select Case G2(i, 0)
        Case 100
            
                If Check1.value = 1 Then
                    If Check4.value = 1 Then
                        xj1 = XYZ2(i - 1, 0): yj1 = XYZ2(i - 1, 1): zj1 = XYZ2(i - 1, 2)
                        Call AF(xj1, yj1, zj1)
                        X1 = XYZ2(i, 0): Y1 = XYZ2(i, 1): z1 = XYZ2(i, 2)
                        Call AF(X1, Y1, z1)
                        Picture1.Line (xj1, yj1)-(X1, Y1), RGB(0, 255, 0)
                    Else
                        Picture1.Line (XYZ2(i - 1, 0), XYZ2(i - 1, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(0, 255, 0)
                    End If
                    If chkFour.value = 1 Then
                        picXY.Line (XYZ2(i - 1, 0), XYZ2(i - 1, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(0, 255, 0)
                        picZX.Line (XYZ2(i - 1, 0), XYZ2(i - 1, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(0, 255, 0)
                        picYZ.Line (XYZ2(i - 1, 1), XYZ2(i - 1, 2))-(XYZ2(i, 1), XYZ2(i, 2)), RGB(0, 255, 0)
                    End If
                End If
            
        Case 101
           
                If Check4.value = 1 Then
                    xj1 = XYZ2(i - 1, 0): yj1 = XYZ2(i - 1, 1): zj1 = XYZ2(i - 1, 2)
                    Call AF(xj1, yj1, zj1)
                    X1 = XYZ2(i, 0): Y1 = XYZ2(i, 1): z1 = XYZ2(i, 2)
                    Call AF(X1, Y1, z1)
                    Picture1.Line (xj1, yj1)-(X1, Y1), RGB(255, 255, 255)
                Else
                    Picture1.Line (XYZ2(i - 1, 0), XYZ2(i - 1, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                End If
                If chkFour.value = 1 Then
                    picXY.Line (XYZ2(i - 1, 0), XYZ2(i - 1, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                    picZX.Line (XYZ2(i - 1, 0), XYZ2(i - 1, 2))-(XYZ2(i, 0), XYZ2(i, 2)), RGB(255, 255, 255)
                    picYZ.Line (XYZ2(i - 1, 1), XYZ2(i - 1, 2))-(XYZ2(i, 1), XYZ2(i, 2)), RGB(255, 255, 255)
                End If
            
        Case 102
            If G2(i, 1) = 17 Then
               
                    If R2(i) <> 0 Then
                        Call yuanxin(XYZ2(i - 1, 0), XYZ2(i - 1, 1), XYZ2(i, 0), XYZ2(i, 1), R2(i), True)
                    Else
                        arcx = XYZ2(i - 1, 0)   IJK2(i, 0)
                        arcy = XYZ2(i - 1, 1)   IJK2(i, 1)
                    End If
                    
                    If R2(i) <> 0 Then
                        st = qd(XYZ2(i, 0), XYZ2(i, 1), arcx, arcy)
                        'st = 6.28318 - st
                        jlhd = hd(XYZ2(i - 1, 0), XYZ2(i - 1, 1), XYZ2(i, 0), XYZ2(i, 1), R2(i))
                        en = st   jlhd
                        enbig = en
                        If en > 6.28318 Then
                            en = en - 6.28318
                        End If
                        If Check4.value = 1 Then
                            For a = 0 To jlhd Step jlhd / 50
                                If a <> 0 Then
                                    X1 = (XYZ2(i, 0) - arcx) * Cos(a) - (XYZ2(i, 1) - arcy) * Sin(a)   arcx
                                    Y1 = (XYZ2(i, 0) - arcx) * Sin(a)   (XYZ2(i, 1) - arcy) * Cos(a)   arcy
                                    Call AF(X1, Y1, z1)
                                    Picture1.Line (xj1, yj1)-(X1, Y1), RGB(255, 255, 255)
                                    xj1 = X1: yj1 = Y1: z1 = XYZ2(i, 2)
                                Else
                                    xj1 = XYZ2(i, 0): yj1 = XYZ2(i, 1): zj1 = XYZ2(i, 2): z1 = XYZ2(i, 2)
                                    Call AF(xj1, yj1, zj1)
                                End If
                            Next a
                        Else
                            Picture1.Circle (arcx, arcy), Abs(R2(i)), RGB(255, 255, 255), st, en
                        End If
                        
                        If chkFour.value = 1 Then
                            Call pic(enbig, st, en, tempx, tempy, tempz)
                        End If
                        
                    ElseIf (XYZ2(i - 1, 0) = XYZ2(i, 0)) And (XYZ2(i - 1, 1) = XYZ2(i, 1)) Then
                        If Check4.value = 1 Then
                            For a = 0 To 6.283 Step 6.283 / 50
                                If a <> 0 Then
                                    X1 = -IJK2(i, 0) * Cos(a) - (-IJK2(i, 1) * Sin(a))   XYZ2(i, 0)   IJK2(i, 0)
                                    Y1 = -IJK2(i, 0) * Sin(a)   (-IJK2(i, 1) * Cos(a))   XYZ2(i, 1)   IJK2(i, 1)
                                    Call AF(X1, Y1, z1)
                                    Picture1.Line (xj1, yj1)-(X1, Y1), RGB(255, 255, 255)
                                    xj1 = X1: yj1 = Y1: z1 = XYZ2(i, 2)
                                Else
                                    xj1 = XYZ2(i, 0): yj1 = XYZ2(i, 1): zj1 = XYZ2(i, 2): z1 = XYZ2(i, 2)
                                    Call AF(xj1, yj1, zj1)
                                End If
                            Next a
                        Else
                            Picture1.Circle (arcx, arcy), Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), RGB(255, 255, 255)
                        End If
                        
                        If chkFour.value = 1 Then
                            Call pic(enbig, st, en, tempx, tempy, tempz)
                        End If
                    
                    Else
                        st = qd(XYZ2(i, 0), XYZ2(i, 1), arcx, arcy)
                        jlhd = hd2(XYZ2(i - 1, 0), XYZ2(i - 1, 1), XYZ2(i, 0), XYZ2(i, 1), True)
                        en = st   jlhd
                        enbig = en
                        If en > 6.28318 Then
                            en = en - 6.28318
                        End If
                        If Check4.value = 1 Then
                            For a = 0 To jlhd Step jlhd / 50
                                If a <> 0 Then
                                    X1 = (XYZ2(i, 0) - arcx) * Cos(a) - (XYZ2(i, 1) - arcy) * Sin(a)   arcx
                                    Y1 = (XYZ2(i, 0) - arcx) * Sin(a)   (XYZ2(i, 1) - arcy) * Cos(a)   arcy
                                    Call AF(X1, Y1, z1)
                                    Picture1.Line (xj1, yj1)-(X1, Y1), RGB(255, 255, 255)
                                    xj1 = X1: yj1 = Y1: z1 = XYZ2(i, 2)
                                Else
                                    xj1 = XYZ2(i, 0): yj1 = XYZ2(i, 1): zj1 = XYZ2(i, 2): z1 = XYZ2(i, 2)
                                    Call AF(xj1, yj1, zj1)
                                End If
                            Next a
                        Else
                            Picture1.Circle (arcx, arcy), Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), RGB(255, 255, 255), st, en
                        End If
                        
                        If chkFour.value = 1 Then
                            Call pic(enbig, st, en, tempx, tempy, tempz)
                        End If
                        
                    End If
                    
                
              
                
            ElseIf G2(i, 1) = 18 Then
                
                    If R2(i) <> 0 Then
                        Call yuanxin(XYZ2(i - 1, 0), XYZ2(i - 1, 2), XYZ2(i, 0), XYZ2(i, 2), R2(i), True)
                    Else
                        arcx = XYZ2(i - 1, 0)   IJK2(i, 0)
                        arcy = XYZ2(i - 1, 2)   IJK2(i, 2)
                    End If
                    
                    If R2(i) <> 0 Then
                        st = qd(XYZ2(i, 0), XYZ2(i, 2), arcx, arcy)
                        'st = 6.28318 - st
                        jlhd = hd(XYZ2(i - 1, 0), XYZ2(i - 1, 2), XYZ2(i, 0), XYZ2(i, 2), R2(i))
                        en = st   jlhd
                        enbig = en
                        If en > 6.28318 Then
                            en = en - 6.28318
                        End If
                        If Check4.value = 1 Then
                            For a = 0 To jlhd Step jlhd / 50
                                If a <> 0 Then
                                    X1 = (XYZ2(i, 0) - arcx) * Cos(a) - (XYZ2(i, 2) - arcy) * Sin(a)   arcx
                                    z1 = (XYZ2(i, 0) - arcx) * Sin(a)   (XYZ2(i, 2) - arcy) * Cos(a)   arcy
                                    Call AF(X1, Y1, z1)
                                    Picture1.Line (xj1, yj1)-(X1, Y1), RGB(255, 255, 255)
                                    xj1 = X1: yj1 = Y1: Y1 = XYZ2(i, 1): zj1 = z1
                                Else
                                    xj1 = XYZ2(i, 0): yj1 = XYZ2(i, 1): Y1 = XYZ2(i, 1): zj1 = XYZ2(i, 2)
                                    Call AF(xj1, yj1, zj1)
                                End If
                            Next a
                        Else
                            If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                                Picture1.Line (arcx - Abs(R2(i)), XYZ2(i, 1))-(arcx   Abs(R2(i)), XYZ2(i, 1)), RGB(255, 255, 255)
                            ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                                If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                                    Picture1.Line (arcx - Abs(R2(i)), XYZ2(i, 1))-(XYZ2(i - 1, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                Else
                                    Picture1.Line (arcx - Abs(R2(i)), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                End If
                            ElseIf enbig >= 6.2832 Then
                                If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                                    Picture1.Line (arcx   Abs(R2(i)), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                Else
                                    Picture1.Line (arcx   Abs(R2(i)), XYZ2(i, 1))-(XYZ2(i - 1, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                End If
                            Else
                                Picture1.Line (XYZ2(i - 1, 0), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                            End If
                        End If
                        
                        If chkFour.value = 1 Then
                            Call pic(enbig, st, en, tempx, tempy, tempz)
                        End If
                        
                    ElseIf (XYZ2(i - 1, 0) = XYZ2(i, 0)) And (XYZ2(i - 1, 2) = XYZ2(i, 2)) Then
                        If Check4.value = 1 Then
                            For a = 0 To 6.283 Step 6.283 / 50
                                If a <> 0 Then
                                    X1 = -IJK2(i, 0) * Cos(a) - (-IJK2(i, 2) * Sin(a))   XYZ2(i, 0)   IJK2(i, 0)
                                    z1 = -IJK2(i, 0) * Sin(a)   (-IJK2(i, 2) * Cos(a))   XYZ2(i, 2)   IJK2(i, 2)
                                    Call AF(X1, Y1, z1)
                                    Picture1.Line (xj1, yj1)-(X1, Y1), RGB(255, 255, 255)
                                    xj1 = X1: yj1 = Y1: Y1 = XYZ2(i, 1): zj1 = z1
                                Else
                                    xj1 = XYZ2(i, 0): yj1 = XYZ2(i, 1): Y1 = XYZ2(i, 1): zj1 = XYZ2(i, 2)
                                    Call AF(xj1, yj1, zj1)
                                End If
                            Next a
                        Else
                            Picture1.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1)), RGB(255, 255, 255)
                        End If
                        
                        If chkFour.value = 1 Then
                            Call pic(enbig, st, en, tempx, tempy, tempz)
                        End If
                        
                    Else
                        st = qd(XYZ2(i, 0), XYZ2(i, 2), arcx, arcy)
                        jlhd = hd2(XYZ2(i - 1, 0), XYZ2(i - 1, 2), XYZ2(i, 0), XYZ2(i, 2), True)
                        en = st   jlhd
                        enbig = en
                        If en > 6.28318 Then
                            en = en - 6.28318
                        End If
                        If Check4.value = 1 Then
                            For a = 0 To jlhd Step jlhd / 50
                                If a <> 0 Then
                                    X1 = (XYZ2(i, 0) - arcx) * Cos(a) - (XYZ2(i, 2) - arcy) * Sin(a)   arcx
                                    z1 = (XYZ2(i, 0) - arcx) * Sin(a)   (XYZ2(i, 2) - arcy) * Cos(a)   arcy
                                    Call AF(X1, Y1, z1)
                                    Picture1.Line (xj1, yj1)-(X1, Y1), RGB(255, 255, 255)
                                    xj1 = X1: yj1 = Y1: Y1 = XYZ2(i, 1): zj1 = z1
                                Else
                                    xj1 = XYZ2(i, 0): yj1 = XYZ2(i, 1): Y1 = XYZ2(i, 1): zj1 = XYZ2(i, 2)
                                    Call AF(xj1, yj1, zj1)
                                End If
                            Next a
                        Else
                            If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                                Picture1.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1)), RGB(255, 255, 255)
                            ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                                If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                                    Picture1.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(XYZ2(i - 1, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                Else
                                    Picture1.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                End If
                            ElseIf enbig >= 6.2832 Then
                                If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                                    Picture1.Line (arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                Else
                                    Picture1.Line (arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(XYZ2(i - 1, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                End If
                            Else
                                Picture1.Line (XYZ2(i - 1, 0), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                            End If
                        End If
                        
                        If chkFour.value = 1 Then
                            Call pic(enbig, st, en, tempx, tempy, tempz)
                        End If
                    End If
                    
                
                
            ElseIf G2(i, 1) = 19 Then
              
                    If R2(i) <> 0 Then
                        Call yuanxin(XYZ2(i - 1, 1), XYZ2(i - 1, 2), XYZ2(i, 1), XYZ2(i, 2), R2(i), True)
                    Else
                        arcx = XYZ2(i - 1, 1)   IJK2(i, 1)
                        arcy = XYZ2(i - 1, 2)   IJK2(i, 2)
                    End If
                    
                    If R2(i) <> 0 Then
                        st = qd(XYZ2(i, 1), XYZ2(i, 2), arcx, arcy)
                        jlhd = hd(XYZ2(i - 1, 1), XYZ2(i - 1, 2), XYZ2(i, 1), XYZ2(i, 2), R2(i))
                        en = st   jlhd
                        enbig = en
                        If en > 6.28318 Then
                            en = en - 6.28318
                        End If
                        If Check4.value = 1 Then
                            For a = 0 To jlhd Step jlhd / 50
                                If a <> 0 Then
                                    Y1 = (XYZ2(i, 1) - arcx) * Cos(a) - (XYZ2(i, 2) - arcy) * Sin(a)   arcx
                                    z1 = (XYZ2(i, 1) - arcx) * Sin(a)   (XYZ2(i, 2) - arcy) * Cos(a)   arcy
                                    Call AF(X1, Y1, z1)
                                    Picture1.Line (xj1, yj1)-(X1, Y1), RGB(255, 255, 255)
                                    xj1 = X1: X1 = XYZ2(i, 0): yj1 = Y1: zj1 = z1
                                Else
                                    xj1 = XYZ2(i, 0): X1 = XYZ2(i, 0): yj1 = XYZ2(i, 1): zj1 = XYZ2(i, 2)
                                    Call AF(xj1, yj1, zj1)
                                End If
                            Next a
                        Else
                            If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                                Picture1.Line (XYZ2(i, 0), arcx - Abs(R2(i)))-(XYZ2(i, 0), arcx   Abs(R2(i))), RGB(255, 255, 255)
                            ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                                If XYZ2(i - 1, 1) >= XYZ2(i, 1) Then
                                    Picture1.Line (XYZ2(i, 0), arcx - Abs(R2(i)))-(XYZ2(i, 0), XYZ2(i - 1, 1)), RGB(255, 255, 255)
                                Else
                                    Picture1.Line (XYZ2(i, 0), arcx - Abs(R2(i)))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                End If
                            ElseIf enbig >= 6.2832 Then
                                If XYZ2(i - 1, 1) >= XYZ2(i, 1) Then
                                    Picture1.Line (XYZ2(i, 0), arcx   Abs(R2(i)))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                Else
                                    Picture1.Line (XYZ2(i, 0), arcx   Abs(R2(i)))-(XYZ2(i, 0), XYZ2(i - 1, 1)), RGB(255, 255, 255)
                                End If
                            Else
                                Picture1.Line (XYZ2(i, 0), XYZ2(i - 1, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                            End If
                        End If
                        
                        If chkFour.value = 1 Then
                            Call pic(enbig, st, en, tempx, tempy, tempz)
                        End If
                        
                    ElseIf (XYZ2(i - 1, 1) = XYZ2(i, 1)) And (XYZ2(i - 1, 2) = XYZ2(i, 2)) Then
                        If Check4.value = 1 Then
                            For a = 0 To 6.283 Step 6.283 / 50
                                If a <> 0 Then
                                    Y1 = -IJK2(i, 1) * Cos(a) - (-IJK2(i, 2) * Sin(a))   XYZ2(i, 1)   IJK2(i, 1)
                                    z1 = -IJK2(i, 1) * Sin(a)   (-IJK2(i, 2) * Cos(a))   XYZ2(i, 2)   IJK2(i, 2)
                                    Call AF(X1, Y1, z1)
                                    Picture1.Line (xj1, yj1)-(X1, Y1), RGB(255, 255, 255)
                                    xj1 = X1: X1 = XYZ2(i, 0): yj1 = Y1: zj1 = z1
                                Else
                                    xj1 = XYZ2(i, 0): X1 = XYZ2(i, 0): yj1 = XYZ2(i, 1): zj1 = XYZ2(i, 2)
                                    Call AF(xj1, yj1, zj1)
                                End If
                            Next a
                        Else
                            Picture1.Line (XYZ2(i, 0), arcx - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        End If
                        
                        If chkFour.value = 1 Then
                            Call pic(enbig, st, en, tempx, tempy, tempz)
                        End If
                        
                    Else
                        st = qd(XYZ2(i, 1), XYZ2(i, 2), arcx, arcy)
                        jlhd = hd2(XYZ2(i - 1, 1), XYZ2(i - 1, 2), XYZ2(i, 1), XYZ2(i, 2), True)
                        en = st   jlhd
                        enbig = en
                        If en > 6.28318 Then
                            en = en - 6.28318
                        End If
                        If Check4.value = 1 Then
                            For a = 0 To jlhd Step jlhd / 50
                                If a <> 0 Then
                                    Y1 = (XYZ2(i, 1) - arcx) * Cos(a) - (XYZ2(i, 2) - arcy) * Sin(a)   arcx
                                    z1 = (XYZ2(i, 1) - arcx) * Sin(a)   (XYZ2(i, 2) - arcy) * Cos(a)   arcy
                                    Call AF(X1, Y1, z1)
                                    Picture1.Line (xj1, yj1)-(X1, Y1), RGB(255, 255, 255)
                                    xj1 = X1: X1 = XYZ2(i, 0): yj1 = Y1: zj1 = z1
                                Else
                                    xj1 = XYZ2(i, 0): X1 = XYZ2(i, 0): yj1 = XYZ2(i, 1): zj1 = XYZ2(i, 2)
                                    Call AF(xj1, yj1, zj1)
                                End If
                            Next a
                        Else
                            If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                                Picture1.Line (XYZ2(i, 0), arcx - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), arcx   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                            ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                                If XYZ2(i - 1, 1) >= XYZ2(i, 1) Then
                                    Picture1.Line (XYZ2(i, 0), arcx - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), XYZ2(i - 1, 1)), RGB(255, 255, 255)
                                Else
                                    Picture1.Line (XYZ2(i, 0), arcx - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                End If
                            ElseIf enbig >= 6.2832 Then
                                If XYZ2(i - 1, 1) >= XYZ2(i, 1) Then
                                    Picture1.Line (XYZ2(i, 0), arcx   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                Else
                                    Picture1.Line (XYZ2(i, 0), arcx   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), XYZ2(i - 1, 1)), RGB(255, 255, 255)
                                End If
                            Else
                                Picture1.Line (XYZ2(i, 0), XYZ2(i - 1, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                            End If
                        End If
                        
                        If chkFour.value = 1 Then
                            Call pic(enbig, st, en, tempx, tempy, tempz)
                        End If
                        
                    End If
                    
                
            End If
            
        Case 103
            If G2(i, 1) = 17 Then
                
                    If R2(i) <> 0 Then
                        Call yuanxin(XYZ2(i - 1, 0), XYZ2(i - 1, 1), XYZ2(i, 0), XYZ2(i, 1), R2(i), False)
                    Else
                        arcx = XYZ2(i - 1, 0)   IJK2(i, 0)
                        arcy = XYZ2(i - 1, 1)   IJK2(i, 1)
                    End If
                    If R2(i) <> 0 Then
                        st = qd(XYZ2(i - 1, 0), XYZ2(i - 1, 1), arcx, arcy)
                        jlhd = hd(XYZ2(i - 1, 0), XYZ2(i - 1, 1), XYZ2(i, 0), XYZ2(i, 1), R2(i))
                        en = st   jlhd
                        enbig = en
                        If en > 6.28318 Then
                            en = en - 6.28318
                        End If
                        If Check4.value = 1 Then
                            For a = 0 To jlhd Step jlhd / 50
                                If a <> 0 Then
                                    X1 = (XYZ2(i - 1, 0) - arcx) * Cos(a) - (XYZ2(i - 1, 1) - arcy) * Sin(a)   arcx
                                    Y1 = (XYZ2(i - 1, 0) - arcx) * Sin(a)   (XYZ2(i - 1, 1) - arcy) * Cos(a)   arcy
                                    Call AF(X1, Y1, z1)
                                    Picture1.Line (xj1, yj1)-(X1, Y1), RGB(255, 255, 255)
                                    xj1 = X1: yj1 = Y1: z1 = XYZ2(i - 1, 2)
                                Else
                                    xj1 = XYZ2(i - 1, 0): yj1 = XYZ2(i - 1, 1): zj1 = XYZ2(i - 1, 2): z1 = XYZ2(i - 1, 2)
                                    Call AF(xj1, yj1, zj1)
                                End If
                            Next a
                        Else
                            Picture1.Circle (arcx, arcy), Abs(R2(i)), RGB(255, 255, 255), st, en
                        End If
                        
                        If chkFour.value = 1 Then
                            Call pic(enbig, st, en, tempx, tempy, tempz)
                        End If
                        
                    ElseIf (XYZ2(i - 1, 0) = XYZ2(i, 0)) And (XYZ2(i - 1, 1) = XYZ2(i, 1)) Then
                        If Check4.value = 1 Then
                            For a = 0 To 6.283 Step 6.283 / 50
                                If a <> 0 Then
                                    X1 = -IJK2(i, 0) * Cos(a) - (-IJK2(i, 1) * Sin(a))   XYZ2(i, 0)   IJK2(i, 0)
                                    Y1 = -IJK2(i, 0) * Sin(a)   (-IJK2(i, 1) * Cos(a))   XYZ2(i, 1)   IJK2(i, 1)
                                    Call AF(X1, Y1, z1)
                                    Picture1.Line (xj1, yj1)-(X1, Y1), RGB(255, 255, 255)
                                    xj1 = X1: yj1 = Y1: z1 = XYZ2(i, 2)
                                Else
                                    xj1 = XYZ2(i, 0): yj1 = XYZ2(i, 1): zj1 = XYZ2(i, 2): z1 = XYZ2(i, 2)
                                    Call AF(xj1, yj1, zj1)
                                End If
                            Next a
                        Else
                            Picture1.Circle (arcx, arcy), Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), RGB(255, 255, 255)
                        End If
                        
                        If chkFour.value = 1 Then
                            picXY.Circle (arcx, arcy), Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), RGB(255, 255, 255)
                            picZX.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2))-(arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2)), RGB(255, 255, 255)
                            picYZ.Line (arcy - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2))-(arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), XYZ2(i, 2)), RGB(255, 255, 255)
                        End If
                        
                    Else
                        st = qd(XYZ2(i - 1, 0), XYZ2(i - 1, 1), arcx, arcy)
                        jlhd = hd2(XYZ2(i - 1, 0), XYZ2(i - 1, 1), XYZ2(i, 0), XYZ2(i, 1), False)
                        en = st   jlhd
                        enbig = en
                        If en > 6.28318 Then
                            en = en - 6.28318
                        End If
                        If Check4.value = 1 Then
                            For a = 0 To jlhd Step jlhd / 50
                                If a <> 0 Then
                                    X1 = (XYZ2(i - 1, 0) - arcx) * Cos(a) - (XYZ2(i - 1, 1) - arcy) * Sin(a)   arcx
                                    Y1 = (XYZ2(i - 1, 0) - arcx) * Sin(a)   (XYZ2(i - 1, 1) - arcy) * Cos(a)   arcy
                                    Call AF(X1, Y1, z1)
                                    Picture1.Line (xj1, yj1)-(X1, Y1), RGB(255, 255, 255)
                                    xj1 = X1: yj1 = Y1: z1 = XYZ2(i - 1, 2)
                                Else
                                    xj1 = XYZ2(i - 1, 0): yj1 = XYZ2(i - 1, 1): zj1 = XYZ2(i - 1, 2): z1 = XYZ2(i - 1, 2)
                                    Call AF(xj1, yj1, zj1)
                                End If
                            Next a
                        Else
                            Picture1.Circle (arcx, arcy), Sqr(IJK2(i, 0) ^ 2   IJK2(i, 1) ^ 2), RGB(255, 255, 255), st, en
                        End If
                        
                        If chkFour.value = 1 Then
                            Call pic(enbig, st, en, tempx, tempy, tempz)
                        End If
                        
                    End If
                
            ElseIf G2(i, 1) = 18 Then
                
                    If R2(i) <> 0 Then
                        Call yuanxin(XYZ2(i - 1, 0), XYZ2(i - 1, 2), XYZ2(i, 0), XYZ2(i, 2), R2(i), False)
                    Else
                        arcx = XYZ2(i - 1, 0)   IJK2(i, 0)
                        arcy = XYZ2(i - 1, 2)   IJK2(i, 2)
                    End If
                    If R2(i) <> 0 Then
                        st = qd(XYZ2(i - 1, 0), XYZ2(i - 1, 2), arcx, arcy)
                        jlhd = hd(XYZ2(i - 1, 0), XYZ2(i - 1, 2), XYZ2(i, 0), XYZ2(i, 2), R2(i))
                        en = st   jlhd
                        enbig = en
                        If en > 6.28318 Then
                            en = en - 6.28318
                        End If
                        If Check4.value = 1 Then
                            For a = 0 To jlhd Step jlhd / 50
                                If a <> 0 Then
                                    X1 = (XYZ2(i - 1, 0) - arcx) * Cos(a) - (XYZ2(i - 1, 2) - arcy) * Sin(a)   arcx
                                    z1 = (XYZ2(i - 1, 0) - arcx) * Sin(a)   (XYZ2(i - 1, 2) - arcy) * Cos(a)   arcy
                                    Call AF(X1, Y1, z1)
                                    Picture1.Line (xj1, yj1)-(X1, Y1), RGB(255, 255, 255)
                                    xj1 = X1: yj1 = Y1: Y1 = XYZ2(i - 1, 1): z1 = XYZ2(i - 1, 2)
                                Else
                                    xj1 = XYZ2(i - 1, 0): yj1 = XYZ2(i - 1, 1): Y1 = XYZ2(i - 1, 1): zj1 = XYZ2(i - 1, 2)
                                    Call AF(xj1, yj1, zj1)
                                End If
                            Next a
                        Else
                            If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                                Picture1.Line (arcx - Abs(R2(i)), XYZ2(i, 1))-(arcx   Abs(R2(i)), XYZ2(i, 1)), RGB(255, 255, 255)
                            ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                                If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                                    Picture1.Line (arcx - Abs(R2(i)), XYZ2(i, 1))-(XYZ2(i - 1, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                Else
                                    Picture1.Line (arcx - Abs(R2(i)), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                End If
                            ElseIf enbig >= 6.2832 Then
                                If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                                    Picture1.Line (arcx   Abs(R2(i)), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                Else
                                    Picture1.Line (arcx   Abs(R2(i)), XYZ2(i, 1))-(XYZ2(i - 1, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                End If
                            Else
                                Picture1.Line (XYZ2(i - 1, 0), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                            End If
                        End If
                        
                        If chkFour.value = 1 Then
                            Call pic(enbig, st, en, tempx, tempy, tempz)
                        End If
                        
                    ElseIf (XYZ2(i - 1, 0) = XYZ2(i, 0)) And (XYZ2(i - 1, 2) = XYZ2(i, 2)) Then
                        If Check4.value = 1 Then
                            For a = 0 To 6.283 Step 6.283 / 50
                                If a <> 0 Then
                                    X1 = -IJK2(i, 0) * Cos(a) - (-IJK2(i, 2) * Sin(a))   XYZ2(i, 0)   IJK2(i, 0)
                                    z1 = -IJK2(i, 0) * Sin(a)   (-IJK2(i, 2) * Cos(a))   XYZ2(i, 2)   IJK2(i, 2)
                                    Call AF(X1, Y1, z1)
                                    Picture1.Line (xj1, yj1)-(X1, Y1), RGB(255, 255, 255)
                                    xj1 = X1: yj1 = Y1: Y1 = XYZ2(i, 1): z1 = XYZ2(i, 2)
                                Else
                                    xj1 = XYZ2(i, 0): yj1 = XYZ2(i, 1):  Y1 = XYZ2(i, 1): zj1 = XYZ2(i, 2)
                                    Call AF(xj1, yj1, zj1)
                                End If
                            Next a
                        Else
                            Picture1.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1)), RGB(255, 255, 255)
                        End If
                        
                        If chkFour.value = 1 Then
                            picXY.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1)), RGB(255, 255, 255)
                            picZX.Circle (arcx, arcy), Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), RGB(255, 255, 255)
                            picYZ.Line (XYZ2(i, 1), arcy - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 1), arcy   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        End If
                        
                    Else
                        st = qd(XYZ2(i - 1, 0), XYZ2(i - 1, 2), arcx, arcy)
                        jlhd = hd2(XYZ2(i - 1, 0), XYZ2(i - 1, 2), XYZ2(i, 0), XYZ2(i, 2), False)
                        en = st   jlhd
                        enbig = en
                        If en > 6.28318 Then
                            en = en - 6.28318
                        End If
                        If Check4.value = 1 Then
                            For a = 0 To jlhd Step jlhd / 50
                                If a <> 0 Then
                                    X1 = (XYZ2(i - 1, 0) - arcx) * Cos(a) - (XYZ2(i - 1, 2) - arcy) * Sin(a)   arcx
                                    z1 = (XYZ2(i - 1, 0) - arcx) * Sin(a)   (XYZ2(i - 1, 2) - arcy) * Cos(a)   arcy
                                    Call AF(X1, Y1, z1)
                                    Picture1.Line (xj1, yj1)-(X1, Y1), RGB(255, 255, 255)
                                    xj1 = X1: yj1 = Y1: Y1 = XYZ2(i - 1, 1): z1 = XYZ2(i - 1, 2)
                                Else
                                    xj1 = XYZ2(i - 1, 0): yj1 = XYZ2(i - 1, 1): Y1 = XYZ2(i - 1, 1): zj1 = XYZ2(i - 1, 2)
                                    Call AF(xj1, yj1, zj1)
                                End If
                            Next a
                        Else
                            If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                                Picture1.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1)), RGB(255, 255, 255)
                            ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                                If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                                    Picture1.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(XYZ2(i - 1, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                Else
                                    Picture1.Line (arcx - Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                End If
                            ElseIf enbig >= 6.2832 Then
                                If XYZ2(i - 1, 0) >= XYZ2(i, 0) Then
                                    Picture1.Line (arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                Else
                                    Picture1.Line (arcx   Sqr(IJK2(i, 0) ^ 2   IJK2(i, 2) ^ 2), XYZ2(i, 1))-(XYZ2(i - 1, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                End If
                            Else
                                Picture1.Line (XYZ2(i - 1, 0), XYZ2(i, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                            End If
                        End If
                        
                        If chkFour.value = 1 Then
                            Call pic(enbig, st, en, tempx, tempy, tempz)
                        End If
                        
                    End If
                
            ElseIf G2(i, 1) = 19 Then
               
                    If R2(i) <> 0 Then
                        Call yuanxin(XYZ2(i - 1, 1), XYZ2(i - 1, 2), XYZ2(i, 1), XYZ2(i, 2), R2(i), False)
                    Else
                        arcx = XYZ2(i - 1, 1)   IJK2(i, 1)
                        arcy = XYZ2(i - 1, 2)   IJK2(i, 2)
                    End If
                    If R2(i) <> 0 Then
                        st = qd(XYZ2(i - 1, 1), XYZ2(i - 1, 2), arcx, arcy)
                        jlhd = hd(XYZ2(i - 1, 1), XYZ2(i - 1, 2), XYZ2(i, 1), XYZ2(i, 2), R2(i))
                        en = st   jlhd
                        enbig = en
                        If en > 6.28318 Then
                            en = en - 6.28318
                        End If
                        If Check4.value = 1 Then
                            For a = 0 To jlhd Step jlhd / 50
                                If a <> 0 Then
                                    Y1 = (XYZ2(i - 1, 1) - arcx) * Cos(a) - (XYZ2(i - 1, 2) - arcy) * Sin(a)   arcx
                                    z1 = (XYZ2(i - 1, 1) - arcx) * Sin(a)   (XYZ2(i - 1, 2) - arcy) * Cos(a)   arcy
                                    Call AF(X1, Y1, z1)
                                    Picture1.Line (xj1, yj1)-(X1, Y1), RGB(255, 255, 255)
                                    xj1 = X1: X1 = XYZ2(i - 1, 0): yj1 = Y1
                                Else
                                    xj1 = XYZ2(i - 1, 0): X1 = XYZ2(i - 1, 0): yj1 = XYZ2(i - 1, 1): zj1 = XYZ2(i - 1, 2)
                                    Call AF(xj1, yj1, zj1)
                                End If
                            Next a
                        Else
                            If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                                Picture1.Line (XYZ2(i, 0), arcx - Abs(R2(i)))-(XYZ2(i, 0), arcx   Abs(R2(i))), RGB(255, 255, 255)
                            ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                                If XYZ2(i - 1, 1) >= XYZ2(i, 1) Then
                                    Picture1.Line (XYZ2(i, 0), arcx - Abs(R2(i)))-(XYZ2(i, 0), XYZ2(i - 1, 1)), RGB(255, 255, 255)
                                Else
                                    Picture1.Line (XYZ2(i, 0), arcx - Abs(R2(i)))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                End If
                            ElseIf enbig >= 6.2832 Then
                                If XYZ2(i - 1, 1) >= XYZ2(i, 1) Then
                                    Picture1.Line (XYZ2(i, 0), arcx   Abs(R2(i)))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                Else
                                    Picture1.Line (XYZ2(i, 0), arcx   Abs(R2(i)))-(XYZ2(i, 0), XYZ2(i - 1, 1)), RGB(255, 255, 255)
                                End If
                            Else
                                Picture1.Line (XYZ2(i, 0), XYZ2(i - 1, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                            End If
                        End If
                        
                        If chkFour.value = 1 Then
                            Call pic(enbig, st, en, tempx, tempy, tempz)
                        End If
                        
                    ElseIf (XYZ2(i - 1, 1) = XYZ2(i, 1)) And (XYZ2(i - 1, 2) = XYZ2(i, 2)) Then
                        If Check4.value = 1 Then
                            For a = 0 To 6.283 Step 6.283 / 50
                                If a <> 0 Then
                                    Y1 = -IJK2(i, 1) * Cos(a) - (-IJK2(i, 2) * Sin(a))   XYZ2(i, 1)   IJK2(i, 1)
                                    z1 = -IJK2(i, 1) * Sin(a)   (-IJK2(i, 2) * Cos(a))   XYZ2(i, 2)   IJK2(i, 2)
                                    Call AF(X1, Y1, z1)
                                    Picture1.Line (xj1, yj1)-(X1, Y1), RGB(255, 255, 255)
                                    xj1 = X1: X1 = XYZ2(i, 0): yj1 = Y1
                                Else
                                    xj1 = XYZ2(i, 0): X1 = XYZ2(i, 0): yj1 = XYZ2(i, 1): zj1 = XYZ2(i, 2)
                                    Call AF(xj1, yj1, zj1)
                                End If
                            Next a
                        Else
                            Picture1.Line (XYZ2(i, 0), arcx - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), arcx   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        End If
                        
                        If chkFour.value = 1 Then
                            picYZ.Circle (arcx, arcy), Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2), RGB(255, 255, 255)
                            picXY.Line (XYZ2(i, 0), arcx - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), arcx   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                            picZX.Line (XYZ2(i, 0), arcy - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), arcy   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                        End If
                        
                    Else
                        st = qd(XYZ2(i - 1, 1), XYZ2(i - 1, 2), arcx, arcy)
                        jlhd = hd2(XYZ2(i - 1, 1), XYZ2(i - 1, 2), XYZ2(i, 1), XYZ2(i, 2), False)
                        en = st   jlhd
                        enbig = en
                        If en > 6.28318 Then
                            en = en - 6.28318
                        End If
                        If Check4.value = 1 Then
                            For a = 0 To jlhd Step jlhd / 50
                                If a <> 0 Then
                                    Y1 = (XYZ2(i - 1, 1) - arcx) * Cos(a) - (XYZ2(i - 1, 2) - arcy) * Sin(a)   arcx
                                    z1 = (XYZ2(i - 1, 1) - arcx) * Sin(a)   (XYZ2(i - 1, 2) - arcy) * Cos(a)   arcy
                                    Call AF(X1, Y1, z1)
                                    Picture1.Line (xj1, yj1)-(X1, Y1), RGB(255, 255, 255)
                                    xj1 = X1: X1 = XYZ2(i - 1, 0): yj1 = Y1
                                Else
                                    xj1 = XYZ2(i - 1, 0): X1 = XYZ2(i - 1, 0): yj1 = XYZ2(i - 1, 1): zj1 = XYZ2(i - 1, 2)
                                    Call AF(xj1, yj1, zj1)
                                End If
                            Next a
                        Else
                            If (enbig >= 9.424778) Or ((enbig >= 3.14159 And st <= 3.14159) And enbig >= 6.2832) Then
                                Picture1.Line (XYZ2(i, 0), arcx - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), arcx   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2)), RGB(255, 255, 255)
                            ElseIf (enbig >= 3.14159 And st <= 3.14159) And enbig <= 6.2832 Then
                                If XYZ2(i - 1, 1) >= XYZ2(i, 1) Then
                                    Picture1.Line (XYZ2(i, 0), arcx - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), XYZ2(i - 1, 1)), RGB(255, 255, 255)
                                Else
                                    Picture1.Line (XYZ2(i, 0), arcx - Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                End If
                            ElseIf enbig >= 6.2832 Then
                                If XYZ2(i - 1, 1) >= XYZ2(i, 1) Then
                                    Picture1.Line (XYZ2(i, 0), arcx   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                                Else
                                    Picture1.Line (XYZ2(i, 0), arcx   Sqr(IJK2(i, 1) ^ 2   IJK2(i, 2) ^ 2))-(XYZ2(i, 0), XYZ2(i - 1, 1)), RGB(255, 255, 255)
                                End If
                            Else
                                Picture1.Line (XYZ2(i, 0), XYZ2(i - 1, 1))-(XYZ2(i, 0), XYZ2(i, 1)), RGB(255, 255, 255)
                            End If
                        End If
                        
                        If chkFour.value = 1 Then
                            Call pic(enbig, st, en, tempx, tempy, tempz)
                        End If
                        
                        
                    End If
                
            End If
    End Select
    If (M2(i, 0) = 130) Or (M2(i, 0) = 102) Then
        tempx = 0
        tempy = 0
        tempz = 0
        StatusBar1.Panels(3).Text = "加工进度:100%"
        Exit Sub
    End If
    jindu = jindu   1
    If stopflag Then: tempx = 0: tempy = 0: tempz = 0: Exit Sub
    If Check2.value = 1 Then
       Delay (Val(Text4))
    End If
Next i
If (jindu * 100 / rows) <= 100 Then '每处理50行更新一次加工进度
    StatusBar1.Panels(3).Text = "加工进度:" & CStr(Int(jindu * 100 / rows)) & "%"
Else
    StatusBar1.Panels(3).Text = "加工进度:100%"
End If
tempx = XYZ2(50, 0)
tempy = XYZ2(50, 1)
tempz = XYZ2(50, 2)
End Sub


Private Sub cmdopen_Click()
On Error GoTo ERRORline
Dim temp As String
Dim tempval As Double
Dim hasx As Boolean, hasy As Boolean, hasz As Boolean
CommonDialog1.DialogTitle = "打开数控程序"
CommonDialog1.Filter = "All Fils(*.*)|*.*|PIM Files|*.PIM|NC Files|*.NC|txt Files|*.txt|"
CommonDialog1.Flags = 1
CommonDialog1.Action = 1
If CommonDialog1.FileName = "" Then
    Exit Sub
Else
    RTB1.Text = ""
    StatusBar1.Panels(2).Text = "程序行数:"
    cmdrun.Enabled = False
    cmdStart.Enabled = False
    maxx = 0.0000001
    minx = 10 ^ 10
    maxy = 0.0000001
    miny = 10 ^ 10
    maxz = 0.0000001
    minz = 10 ^ 10
    Open CommonDialog1.FileName For Input As #1
        rows = 0
        Do Until EOF(1) '计算程序行数
            Line Input #1, temp
            temp = Replace(temp, "D", "a", , , 1)
            temp = Replace(temp, "E", "a", , , 1)
            If InStr(1, temp, "X", 1) <> 0 Then
                hasx = True
                tempval = Val(Mid$(temp, InStr(1, temp, "X", 1)   1))
                If maxx < tempval Then
                    maxx = tempval
                End If
                If minx > tempval Then
                    minx = tempval
                End If
            End If
            If InStr(1, temp, "Y", 1) <> 0 Then
                hasy = True
                tempval = Val(Mid$(temp, InStr(1, temp, "Y", 1)   1))
                If maxy < tempval Then
                    maxy = tempval
                End If
                If miny > tempval Then
                    miny = tempval
                End If
            End If
            If InStr(1, temp, "Z", 1) <> 0 Then
                hasz = True
                tempval = Val(Mid$(temp, InStr(1, temp, "Z", 1)   1))
                If maxz < tempval Then
                    maxz = tempval
                End If
                If minz > tempval Then
                    minz = tempval
                End If
            End If
            If hasx Eqv False Then
                maxx = 0: minx = 0
            End If
            If hasy Eqv False Then
                maxy = 0: miny = 0
            End If
            If hasz Eqv False Then
                maxz = 0: minz = 0
            End If
            
            rows = rows   1
        Loop
    Close #1
    If Val(Text1.Text) <> 0 Then
        pbscale = Val(Text1.Text)
        Picture1.Scale (0, pbscale)-(pbscale, 0)
        picXY.Scale (0, pbscale)-(pbscale, 0)
        picZX.Scale (0, pbscale)-(pbscale, 0)
        picYZ.Scale (0, pbscale)-(pbscale, 0)
    Else
        Picture1.Scale (-250, 250)-(250, -250)
        picXY.Scale (-250, 250)-(250, -250)
        picZX.Scale (-250, 250)-(250, -250)
        picYZ.Scale (-250, 250)-(250, -250)
    End If
    If Val(Text2.Text) <> 0 Then
        offsetx = Val(Text2.Text)
        Picture1.Scale (offsetx, pbscale)-(pbscale   offsetx, 0)
        picXY.Scale (offsetx, pbscale)-(pbscale   offsetx, 0)
        picZX.Scale (offsetx, pbscale)-(pbscale   offsetx, 0)
        picYZ.Scale (offsetx, pbscale)-(pbscale   offsetx, 0)
    Else
        offsetx = 0
    End If
    If Val(Text3.Text) <> 0 Then
        offsety = Val(Text3.Text)
        Picture1.Scale (offsetx, pbscale   offsety)-(pbscale   offsetx, offsety)
        picXY.Scale (offsetx, pbscale   offsety)-(pbscale   offsetx, offsety)
        picZX.Scale (offsetx, pbscale   offsety)-(pbscale   offsetx, offsety)
        picYZ.Scale (offsetx, pbscale   offsety)-(pbscale   offsetx, offsety)
    Else
        offsety = 0
    End If
    If Check3.value = 1 Then
        If (maxx - minx) >= (maxy - miny) Then
            If Check4.value = 1 Then
                Picture1.Scale (minx - (maxx - minx) / 8   offsetx, maxx - minx   miny   (maxx - minx) / 8   offsety - (maxx - minx - maxy   miny) / 2)-(maxx   (maxx - minx) / 8   offsetx, miny - (maxx - minx) / 8   offsety - (maxx - minx - maxy   miny) / 2)
                picXY.Scale (minx - (maxx - minx) / 8   offsetx, maxx - minx   miny   (maxx - minx) / 8   offsety - (maxx - minx - maxy   miny) / 2)-(maxx   (maxx - minx) / 8   offsetx, miny - (maxx - minx) / 8   offsety - (maxx - minx - maxy   miny) / 2)
                'picZX.Scale (minx - (maxx - minx) / 8   offsetx, maxx - minx   miny   (maxx - minx) / 8   offsety - (maxx - minx - maxy   miny) / 2)-(maxx   (maxx - minx) / 8   offsetx, miny - (maxx - minx) / 8   offsety - (maxx - minx - maxy   miny) / 2)
                'picYZ.Scale (minx - (maxx - minx) / 8   offsetx, maxx - minx   miny   (maxx - minx) / 8   offsety - (maxx - minx - maxy   miny) / 2)-(maxx   (maxx - minx) / 8   offsetx, miny - (maxx - minx) / 8   offsety - (maxx - minx - maxy   miny) / 2)
            Else
                Picture1.Scale (minx - (maxx - minx) / 50   offsetx, maxx - minx   miny   (maxx - minx) / 50   offsety - (maxx - minx - maxy   miny) / 2)-(maxx   (maxx - minx) / 50   offsetx, miny - (maxx - minx) / 50   offsety - (maxx - minx - maxy   miny) / 2)
                picXY.Scale (minx - (maxx - minx) / 50   offsetx, maxx - minx   miny   (maxx - minx) / 50   offsety - (maxx - minx - maxy   miny) / 2)-(maxx   (maxx - minx) / 50   offsetx, miny - (maxx - minx) / 50   offsety - (maxx - minx - maxy   miny) / 2)
                'picZX.Scale (minx - (maxx - minx) / 50   offsetx, maxx - minx   miny   (maxx - minx) / 50   offsety - (maxx - minx - maxy   miny) / 2)-(maxx   (maxx - minx) / 50   offsetx, miny - (maxx - minx) / 50   offsety - (maxx - minx - maxy   miny) / 2)
                'picYZ.Scale (minx - (maxx - minx) / 50   offsetx, maxx - minx   miny   (maxx - minx) / 50   offsety - (maxx - minx - maxy   miny) / 2)-(maxx   (maxx - minx) / 50   offsetx, miny - (maxx - minx) / 50   offsety - (maxx - minx - maxy   miny) / 2)
            End If
        Else
            If Check4.value = 1 Then
                Picture1.Scale (minx - (maxy - miny) / 8   offsetx - (maxy - miny - maxx   minx) / 2, maxy   (maxy - miny) / 8   offsety)-(maxy - miny   minx   (maxy - miny) / 8 - (maxy - miny - maxx   minx) / 2   offsetx, miny - (maxy - miny) / 8   offsety)
                picXY.Scale (minx - (maxy - miny) / 8   offsetx - (maxy - miny - maxx   minx) / 2, maxy   (maxy - miny) / 8   offsety)-(maxy - miny   minx   (maxy - miny) / 8 - (maxy - miny - maxx   minx) / 2   offsetx, miny - (maxy - miny) / 8   offsety)
                'picZX.Scale (minx - (maxy - miny) / 8   offsetx - (maxy - miny - maxx   minx) / 2, maxy   (maxy - miny) / 8   offsety)-(maxy - miny   minx   (maxy - miny) / 8 - (maxy - miny - maxx   minx) / 2   offsetx, miny - (maxy - miny) / 8   offsety)
                'picYZ.Scale (minx - (maxy - miny) / 8   offsetx - (maxy - miny - maxx   minx) / 2, maxy   (maxy - miny) / 8   offsety)-(maxy - miny   minx   (maxy - miny) / 8 - (maxy - miny - maxx   minx) / 2   offsetx, miny - (maxy - miny) / 8   offsety)
            Else
                Picture1.Scale (minx - (maxy - miny) / 50   offsetx - (maxy - miny - maxx   minx) / 2, maxy   (maxy - miny) / 50   offsety)-(maxy - miny   minx   (maxy - miny) / 50 - (maxy - miny - maxx   minx) / 2   offsetx, miny - (maxy - miny) / 50   offsety)
                picXY.Scale (minx - (maxy - miny) / 50   offsetx - (maxy - miny - maxx   minx) / 2, maxy   (maxy - miny) / 50   offsety)-(maxy - miny   minx   (maxy - miny) / 50 - (maxy - miny - maxx   minx) / 2   offsetx, miny - (maxy - miny) / 50   offsety)
                'picZX.Scale (minx - (maxy - miny) / 50   offsetx - (maxy - miny - maxx   minx) / 2, maxy   (maxy - miny) / 50   offsety)-(maxy - miny   minx   (maxy - miny) / 50 - (maxy - miny - maxx   minx) / 2   offsetx, miny - (maxy - miny) / 50   offsety)
                'picYZ.Scale (minx - (maxy - miny) / 50   offsetx - (maxy - miny - maxx   minx) / 2, maxy   (maxy - miny) / 50   offsety)-(maxy - miny   minx   (maxy - miny) / 50 - (maxy - miny - maxx   minx) / 2   offsetx, miny - (maxy - miny) / 50   offsety)
            End If
        End If
        
        If (maxx - minx) >= (maxz - minz) Then
            picZX.Scale (minx - (maxx - minx) / 8   offsetx, maxx - minx   minz   (maxx - minx) / 8   offsety - (maxx - minx - maxz   minz) / 2)-(maxx   (maxx - minx) / 8   offsetx, minz - (maxx - minx) / 8   offsety - (maxx - minx - maxz   minz) / 2)
        Else
            picZX.Scale (minx - (maxz - minz) / 8   offsetx - (maxz - minz - maxx   minx) / 2, maxz   (maxz - minz) / 8   offsety)-(maxz - minz   minx   (maxz - minz) / 8 - (maxz - minz - maxx   minx) / 2   offsetx, minz - (maxz - minz) / 8   offsety)
        End If
        
        If (maxy - miny) >= (maxz - minz) Then
            picYZ.Scale (miny - (maxy - miny) / 8   offsetx, maxy - miny   minz   (maxy - miny) / 8   offsety - (maxy - miny - maxz   minz) / 2)-(maxy   (maxy - miny) / 8   offsetx, minz - (maxy - miny) / 8   offsety - (maxy - miny - maxz   minz) / 2)
        Else
            picYZ.Scale (miny - (maxz - minz) / 8   offsetx - (maxz - minz - maxy   miny) / 2, maxz   (maxz - minz) / 8   offsety)-(maxz - minz   miny   (maxz - minz) / 8 - (maxz - minz - maxy   miny) / 2   offsetx, minz - (maxz - minz) / 8   offsety)
        End If
    End If
    StatusBar1.Panels(3).Text = "加工进度:0%"
    StatusBar1.Panels(2).Text = "程序行数:" & CStr(rows) & "行"
    Form1.Caption = "雕铣机数控系统" & "      " & CommonDialog1.FileTitle
    RTB1.LoadFile CommonDialog1.FileName, rtfText
    cmdrun.Enabled = True
    cmdStart.Enabled = True
    
End If
Exit Sub
ERRORline: MsgBox ("加工程序出错!")
End Sub

Private Sub cmdrun_Click()
On Error GoTo ERRORline
ReDim G(50, 2), M(50, 1)
ReDim XYZ(50, 2)
ReDim IJK(50, 2)
ReDim f(50)
ReDim r(50)
ReDim G1(50, 2), M1(50, 1)
ReDim XYZ1(50, 2)
ReDim IJK1(50, 2)
ReDim F1(50)
ReDim R1(50)
ReDim G2(50, 2), M2(50, 1)
ReDim XYZ2(50, 2)
ReDim IJK2(50, 2)
ReDim F2(50)
ReDim R2(50)
ReDim Dv2(50)
Dim temp As String
Dim j As Integer
Dim first As Boolean
first = True
pbscale = 300
If CommonDialog1.FileName = "" Then
    Exit Sub
Else
    firstexe = True
    stopflag = False
    If Val(Text1.Text) <> 0 Then
        pbscale = Val(Text1.Text)
        Picture1.Scale (0, pbscale)-(pbscale, 0)
        picXY.Scale (0, pbscale)-(pbscale, 0)
        picZX.Scale (0, pbscale)-(pbscale, 0)
        picYZ.Scale (0, pbscale)-(pbscale, 0)
    Else
        Picture1.Scale (-250, 250)-(250, -250)
        picXY.Scale (-250, 250)-(250, -250)
        picZX.Scale (-250, 250)-(250, -250)
        picYZ.Scale (-250, 250)-(250, -250)
    End If
    If Val(Text2.Text) <> 0 Then
        offsetx = Val(Text2.Text)
        Picture1.Scale (offsetx, pbscale)-(pbscale   offsetx, 0)
        picXY.Scale (offsetx, pbscale)-(pbscale   offsetx, 0)
        picZX.Scale (offsetx, pbscale)-(pbscale   offsetx, 0)
        picYZ.Scale (offsetx, pbscale)-(pbscale   offsetx, 0)
    Else
        offsetx = 0
    End If
    If Val(Text3.Text) <> 0 Then
        offsety = Val(Text3.Text)
        Picture1.Scale (offsetx, pbscale   offsety)-(pbscale   offsetx, offsety)
        picXY.Scale (offsetx, pbscale   offsety)-(pbscale   offsetx, offsety)
        picZX.Scale (offsetx, pbscale   offsety)-(pbscale   offsetx, offsety)
        picYZ.Scale (offsetx, pbscale   offsety)-(pbscale   offsetx, offsety)
    Else
        offsety = 0
    End If
    If Check3.value = 1 Then
        If (maxx - minx) >= (maxy - miny) Then
            If Check4.value = 1 Then
                Picture1.Scale (minx - (maxx - minx) / 8   offsetx, maxx - minx   miny   (maxx - minx) / 8   offsety - (maxx - minx - maxy   miny) / 2)-(maxx   (maxx - minx) / 8   offsetx, miny - (maxx - minx) / 8   offsety - (maxx - minx - maxy   miny) / 2)
                picXY.Scale (minx - (maxx - minx) / 8   offsetx, maxx - minx   miny   (maxx - minx) / 8   offsety - (maxx - minx - maxy   miny) / 2)-(maxx   (maxx - minx) / 8   offsetx, miny - (maxx - minx) / 8   offsety - (maxx - minx - maxy   miny) / 2)
                'picZX.Scale (minx - (maxx - minx) / 8   offsetx, maxx - minx   miny   (maxx - minx) / 8   offsety - (maxx - minx - maxy   miny) / 2)-(maxx   (maxx - minx) / 8   offsetx, miny - (maxx - minx) / 8   offsety - (maxx - minx - maxy   miny) / 2)
                'picYZ.Scale (minx - (maxx - minx) / 8   offsetx, maxx - minx   miny   (maxx - minx) / 8   offsety - (maxx - minx - maxy   miny) / 2)-(maxx   (maxx - minx) / 8   offsetx, miny - (maxx - minx) / 8   offsety - (maxx - minx - maxy   miny) / 2)
            Else
                Picture1.Scale (minx - (maxx - minx) / 50   offsetx, maxx - minx   miny   (maxx - minx) / 50   offsety - (maxx - minx - maxy   miny) / 2)-(maxx   (maxx - minx) / 50   offsetx, miny - (maxx - minx) / 50   offsety - (maxx - minx - maxy   miny) / 2)
                picXY.Scale (minx - (maxx - minx) / 50   offsetx, maxx - minx   miny   (maxx - minx) / 50   offsety - (maxx - minx - maxy   miny) / 2)-(maxx   (maxx - minx) / 50   offsetx, miny - (maxx - minx) / 50   offsety - (maxx - minx - maxy   miny) / 2)
                'picZX.Scale (minx - (maxx - minx) / 50   offsetx, maxx - minx   miny   (maxx - minx) / 50   offsety - (maxx - minx - maxy   miny) / 2)-(maxx   (maxx - minx) / 50   offsetx, miny - (maxx - minx) / 50   offsety - (maxx - minx - maxy   miny) / 2)
                'picYZ.Scale (minx - (maxx - minx) / 50   offsetx, maxx - minx   miny   (maxx - minx) / 50   offsety - (maxx - minx - maxy   miny) / 2)-(maxx   (maxx - minx) / 50   offsetx, miny - (maxx - minx) / 50   offsety - (maxx - minx - maxy   miny) / 2)
            End If
        Else
            If Check4.value = 1 Then
                Picture1.Scale (minx - (maxy - miny) / 8   offsetx - (maxy - miny - maxx   minx) / 2, maxy   (maxy - miny) / 8   offsety)-(maxy - miny   minx   (maxy - miny) / 8 - (maxy - miny - maxx   minx) / 2   offsetx, miny - (maxy - miny) / 8   offsety)
                picXY.Scale (minx - (maxy - miny) / 8   offsetx - (maxy - miny - maxx   minx) / 2, maxy   (maxy - miny) / 8   offsety)-(maxy - miny   minx   (maxy - miny) / 8 - (maxy - miny - maxx   minx) / 2   offsetx, miny - (maxy - miny) / 8   offsety)
                'picZX.Scale (minx - (maxy - miny) / 8   offsetx - (maxy - miny - maxx   minx) / 2, maxy   (maxy - miny) / 8   offsety)-(maxy - miny   minx   (maxy - miny) / 8 - (maxy - miny - maxx   minx) / 2   offsetx, miny - (maxy - miny) / 8   offsety)
                'picYZ.Scale (minx - (maxy - miny) / 8   offsetx - (maxy - miny - maxx   minx) / 2, maxy   (maxy - miny) / 8   offsety)-(maxy - miny   minx   (maxy - miny) / 8 - (maxy - miny - maxx   minx) / 2   offsetx, miny - (maxy - miny) / 8   offsety)
            Else
                Picture1.Scale (minx - (maxy - miny) / 50   offsetx - (maxy - miny - maxx   minx) / 2, maxy   (maxy - miny) / 50   offsety)-(maxy - miny   minx   (maxy - miny) / 50 - (maxy - miny - maxx   minx) / 2   offsetx, miny - (maxy - miny) / 50   offsety)
                picXY.Scale (minx - (maxy - miny) / 50   offsetx - (maxy - miny - maxx   minx) / 2, maxy   (maxy - miny) / 50   offsety)-(maxy - miny   minx   (maxy - miny) / 50 - (maxy - miny - maxx   minx) / 2   offsetx, miny - (maxy - miny) / 50   offsety)
                'picZX.Scale (minx - (maxy - miny) / 50   offsetx - (maxy - miny - maxx   minx) / 2, maxy   (maxy - miny) / 50   offsety)-(maxy - miny   minx   (maxy - miny) / 50 - (maxy - miny - maxx   minx) / 2   offsetx, miny - (maxy - miny) / 50   offsety)
                'picYZ.Scale (minx - (maxy - miny) / 50   offsetx - (maxy - miny - maxx   minx) / 2, maxy   (maxy - miny) / 50   offsety)-(maxy - miny   minx   (maxy - miny) / 50 - (maxy - miny - maxx   minx) / 2   offsetx, miny - (maxy - miny) / 50   offsety)
            End If
        End If
        
        If (maxx - minx) >= (maxz - minz) Then
            picZX.Scale (minx - (maxx - minx) / 8   offsetx, maxx - minx   minz   (maxx - minx) / 8   offsety - (maxx - minx - maxz   minz) / 2)-(maxx   (maxx - minx) / 8   offsetx, minz - (maxx - minx) / 8   offsety - (maxx - minx - maxz   minz) / 2)
        Else
            picZX.Scale (minx - (maxz - minz) / 8   offsetx - (maxz - minz - maxx   minx) / 2, maxz   (maxz - minz) / 8   offsety)-(maxz - minz   minx   (maxz - minz) / 8 - (maxz - minz - maxx   minx) / 2   offsetx, minz - (maxz - minz) / 8   offsety)
        End If
        
        If (maxy - miny) >= (maxz - minz) Then
            picYZ.Scale (miny - (maxy - miny) / 8   offsetx, maxy - miny   minz   (maxy - miny) / 8   offsety - (maxy - miny - maxz   minz) / 2)-(maxy   (maxy - miny) / 8   offsetx, minz - (maxy - miny) / 8   offsety - (maxy - miny - maxz   minz) / 2)
        Else
            picYZ.Scale (miny - (maxz - minz) / 8   offsetx - (maxz - minz - maxy   miny) / 2, maxz   (maxz - minz) / 8   offsety)-(maxz - minz   miny   (maxz - minz) / 8 - (maxz - minz - maxy   miny) / 2   offsetx, minz - (maxz - minz) / 8   offsety)
        End If
    End If
    
    
    
    cmdZanting.Enabled = True

    StatusBar1.Panels(3).Text = "加工进度:0%"
    jindu = 0
    Picture1.Cls
    picXY.Cls
    picZX.Cls
    picYZ.Cls
    Picture1.DrawWidth = 1
    'Open "temp.txt" For Output As #5
    'Close #5
    cmdopen.Enabled = False
    cmdrun.Enabled = False

    Open CommonDialog1.FileName For Input As #2
        
        Do Until EOF(2)
            If first Then
                G(1, 0) = 100: G(1, 1) = 17: G(1, 2) = 40
                G(0, 0) = 100: G(0, 1) = 17: G(0, 2) = 40
                For i = 1 To 50 '执行前先读入100行代码进行解析
                    If EOF(2) Then: Exit For
                    Line Input #2, temp
                    Do Until (Left$(temp, 1) <> ";") And (Left$(temp, 1) <> "%") And (Left$(temp, 1) <> "O") And (Trim(temp) <> "")
                        If EOF(2) Then: Exit For
                        Line Input #2, temp
                        If stopflag Then: GoTo Stopline
                    Loop
                    Call tiqu(temp)
                Next i
                
                For i = 0 To 50
                    For j = 0 To 2
                        G2(i, j) = G(i, j)
                    Next j
                    XYZ2(i, 0) = XYZ(i, 0)
                    XYZ2(i, 1) = XYZ(i, 1)
                    XYZ2(i, 2) = XYZ(i, 2)
                    IJK2(i, 0) = IJK(i, 0)
                    IJK2(i, 1) = IJK(i, 1)
                    IJK2(i, 2) = IJK(i, 2)
                    F2(i) = f(i)
                    R2(i) = r(i)
                    For j = 0 To 1
                        M2(i, j) = M(i, j)
                    Next j
                Next i
                
                
                
                For i = 1 To 49 '及时清零,以免影响提取结果
                    For j = 0 To 2
                        G(i, j) = 0
                    Next j
                    XYZ(i, 0) = 0
                    XYZ(i, 1) = 0
                    XYZ(i, 2) = 0
                    f(i) = 0
                    For j = 0 To 1
                        M(i, j) = 0
                    Next j
                Next i
                
                For j = 0 To 2
                    G(0, j) = G(50, j)
                Next j
                XYZ(0, 0) = XYZ(50, 0)
                XYZ(0, 1) = XYZ(50, 1)
                XYZ(0, 2) = XYZ(50, 2)
                IJK(0, 0) = IJK(50, 0)
                IJK(0, 1) = IJK(50, 1)
                IJK(0, 2) = IJK(50, 2)
                f(0) = f(50)
                r(0) = r(50)
                For j = 0 To 1
                    M(0, j) = M(50, j)
                Next j
                
                For i = 1 To 50
                    If EOF(2) Then: Exit For
                    Line Input #2, temp
                    Do Until (Left$(temp, 1) <> ";") And (Left$(temp, 1) <> "%") And (Left$(temp, 1) <> "O") And (Trim(temp) <> "")
                        If EOF(2) Then: Exit For
                        Line Input #2, temp
                        If stopflag Then: GoTo Stopline
                    Loop
                    Call tiqu(temp)
                Next i
                first = False
            Else
                For i = 1 To 49
                    For j = 0 To 2
                        G(i, j) = 0
                    Next j
                    XYZ(i, 0) = 0
                    XYZ(i, 1) = 0
                    XYZ(i, 2) = 0
                    f(i) = 0
                    For j = 0 To 1
                        M(i, j) = 0
                    Next j
                Next i
                
                For j = 0 To 2
                    G(0, j) = G(50, j)
                Next j
                XYZ(0, 0) = XYZ(50, 0)
                XYZ(0, 1) = XYZ(50, 1)
                XYZ(0, 2) = XYZ(50, 2)
                IJK(0, 0) = IJK(50, 0)
                IJK(0, 1) = IJK(50, 1)
                IJK(0, 2) = IJK(50, 2)
                f(0) = f(50)
                r(0) = r(50)
                For j = 0 To 1
                    M(0, j) = M(50, j)
                Next j
                
                For i = 1 To 50
                    If EOF(2) Then: Exit For
                    Line Input #2, temp
                    Do Until (Left$(temp, 1) <> ";") And (Left$(temp, 1) <> "%") And (Left$(temp, 1) <> "O") And (Trim(temp) <> "")
                        If EOF(2) Then: Exit For
                        Line Input #2, temp
                        If stopflag Then: GoTo Stopline
                    Loop
                    Call tiqu(temp)
                Next i
            End If
            'Call GT_InitLookAhead(0.00003333, 14400000, 5000000, 1000, 12, 1600)
            'Call GT_InitLookAhead(0.0000016, 14400000, 3240000, 1000, 12, 1600)
            'Call GT_InitLookAhead(0.000001, 10000000, 225000, 1000, 12, 1600)
            'Call guiji
            
            Call process
            firstexe = False
            
            If stopflag Then: GoTo Stopline
            
            For j = 0 To 2
                G2(0, j) = G2(50, j)
            Next j
            XYZ2(0, 0) = XYZ2(50, 0)
            XYZ2(0, 1) = XYZ2(50, 1)
            XYZ2(0, 2) = XYZ2(50, 2)
            IJK2(0, 0) = IJK2(50, 0)
            IJK2(0, 1) = IJK2(50, 1)
            IJK2(0, 2) = IJK2(50, 2)
            F2(0) = F2(50)
            R2(0) = R2(50)
            For j = 0 To 1
                M2(0, j) = M2(50, j)
            Next j
            
            For i = 1 To 50
                For j = 0 To 2
                    G2(i, j) = G(i, j)
                Next j
                XYZ2(i, 0) = XYZ(i, 0)
                XYZ2(i, 1) = XYZ(i, 1)
                XYZ2(i, 2) = XYZ(i, 2)
                IJK2(i, 0) = IJK(i, 0)
                IJK2(i, 1) = IJK(i, 1)
                IJK2(i, 2) = IJK(i, 2)
                F2(i) = f(i)
                R2(i) = r(i)
                For j = 0 To 1
                    M2(i, j) = M(i, j)
                Next j
                If (M2(i, 0) = 130) Or (M2(i, 0) = 102) Then
                    'Call GT_InitLookAhead(0.00003333, 14400000, 5000000, 1000, 12, 1600)
                    'Call GT_InitLookAhead(0.0000016, 14400000, 3240000, 1000, 12, 1600)
                    'Call GT_InitLookAhead(0.000001, 10000000, 225000, 1000, 12, 1600)
                    'Call guiji
                    Call process
                    If stopflag Then: GoTo Stopline
                    StatusBar1.Panels(3).Text = "加工进度:100%"
                    Exit For
                End If
                
            Next i
        Loop
        
Stopline:    Close #2
            'Close #5
    
    temp = ""
    cmdopen.Enabled = True
 
End If
cmdrun.Enabled = True

ReDim G(0), M(0)
ReDim XYZ(0, 0)
ReDim IJK(0, 0)
ReDim f(0)
ReDim r(0)
ReDim G2(0), M2(0)
ReDim XYZ2(0, 0)
ReDim IJK2(0, 0)
ReDim F2(0)
ReDim R2(0)
cmdZanting.Enabled = False
Exit Sub
ERRORline: MsgBox ("加工程序出错!")
End Sub

Private Sub cmdStop_Click()
stopflag = True
Call GT_StpMtn
End Sub

Private Sub cmdZanting_Click()
Static i As Byte
If i = 0 Then
    i = 1
    cmdZanting.Caption = "继续"
  
    Call GT_StpMtn
ElseIf i = 1 Then
    i = 0
    cmdZanting.Caption = "暂停"
   
    Call GT_RestoreMtn
End If
Do Until i = 0
    DoEvents
    If stopflag Then: cmdZanting.Caption = "暂停": Exit Sub
Loop
End Sub

Private Sub Command1_Click()
txtT = CStr(0.000016)
txtAcc_max = CStr(10800000)
txtAcc = CStr(1440000)
txtN = CStr(45)
txtVel = CStr(1000)
End Sub

Private Sub Command2_Click()
GT_ExOpt &H400
End Sub

Private Sub Command4_Click()
Dim px As Double
Dim py As Double
Dim pz As Double
px = (Val(lblX1.Caption)   Val(lblX2.Caption)) / 2
py = (Val(lblY1.Caption)   Val(lblY2.Caption)) / 2
pz = Val(lblz.Caption)
Call GT_SetSynVel(26.6)
Call GT_SetSynAcc(0.8)
Call GT_LnXYZ(px * 1600, py * 1600, pz * 1600)
End Sub

Private Sub Form_Load()
cmdZanting.Enabled = False
cmdrun.Enabled = False
cmdStart.Enabled = False
pbscale = 500
Picture1.Scale (-250, 250)-(250, -250)
offsetx = 0
offsety = 0
stopflag = False
Combo1.ListIndex = 0
picXY.Scale (-250, 250)-(250, -250)
picZX.Scale (-250, 250)-(250, -250)
picYZ.Scale (-250, 250)-(250, -250)
picXY.Visible = False
picZX.Visible = False
picYZ.Visible = False
End Sub

Private Sub Form_Unload(Cancel As Integer)
End
End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Label1 = "X"
Label4 = "Y"
Label8 = CStr(x)
Label9 = CStr(y)
End Sub

Private Sub AF(x, z, y) '三维变换矩阵
'Dim f(3, 3) As Double
Dim X1, Y1, z1 As Double
'Dim ct, gm As double
'Dim cosct, cosgm, sinct, singm As double
'ct = 1.04719755: gm = 1.04719755 'pi/3
'gm = 3.14159 / 3: ct = 3.14159 / 3
'cosct = Cos(ct): sinct = Sin(ct): cosgm = Cos(gm): singm = Sin(gm)
'cosct = 0.5: sinct = 0.866: cosgm = 0.5: singm = 0.866
'f(0, 0) = cosct: f(0, 1) = sinct * singm: f(0, 2) = -sinct * cosgm
'f(1, 0) = 0: f(1, 1) = cosgm: f(1, 2) = singm
'f(2, 0) = sinct: f(2, 1) = -cosct * singm: f(2, 2) = cosct * cosgm
'f(3, 0) = 0: f(3, 1) = 0: f(3, 2) = 0

'f(0, 0) = cosct: f(0, 1) = 0: f(0, 2) = -sinct
'f(1, 0) = sinct * singm: f(1, 1) = cosgm: f(1, 2) = singm * cosct
'f(2, 0) = sinct * cosgm: f(2, 1) = -singm: f(2, 2) = cosct * cosgm
'f(3, 0) = 0: f(3, 1) = 0: f(3, 2) = 0
X1 = x: Y1 = y: z1 = z
'x = x1 * f(0, 0)   y1 * f(1, 0)   z1 * f(2, 0)   f(3, 0)
'y = x1 * f(0, 1)   y1 * f(1, 1)   z1 * f(2, 1)   f(3, 1)
'z = x1 * f(0, 2)   y1 * f(1, 2)   z1 * f(2, 2)   f(3, 2)
x = X1 * 0.5   z1 * 0.866
y = X1 * 0.749956   Y1 * 0.5   z1 * (-0.433)
z = X1 * (-0.433)   Y1 * 0.866   z1 * 0.25
'x = x1 * f(0, 0)   y1 * f(0, 1)   z1 * f(0, 2)
'y = x1 * f(1, 0)   y1 * f(1, 1)   z1 * f(1, 2)
'z = x1 * f(2, 0)   y1 * f(2, 1)   z1 * f(2, 2)
End Sub

Private Function zjlx(Xl1 As Double, Xl2 As Double, Yl1 As Double, Yl2 As Double, r As Double) As Byte '刀补转接类型判别
If Sgn(r) * (Yl2 * Xl1 - Xl2 * Yl1) > 0 Then
    zjlx = 1
ElseIf (Yl2 * Xl1 - Xl2 * Yl1) = 0 Then
    zjlx = 0
ElseIf Sgn(r) * (Yl2 * Xl1 - Xl2 * Yl1) < 0 And (Yl2 * Yl1   Xl2 * Xl1) >= 0 Then
    zjlx = 2
ElseIf Sgn(r) * (Yl2 * Xl1 - Xl2 * Yl1) < 0 And (Yl2 * Yl1   Xl2 * Xl1) < 0 Then
    zjlx = 3
End If
End Function

Private Sub picXY_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Label1 = "X"
Label4 = "Y"
Label8 = CStr(x)
Label9 = CStr(y)
End Sub

Private Sub picYZ_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Label1 = "Y"
Label4 = "Z"
Label8 = CStr(x)
Label9 = CStr(y)
End Sub

Private Sub picZX_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Label1 = "X"
Label4 = "Z"
Label8 = CStr(x)
Label9 = CStr(y)
End Sub


Private Sub Timer1_Timer()
Dim X1 As Long, Y1 As Long, z1 As Long
Dim xp As Double, yp As Double, zp As Double
Call GT_GetAtlPos(3, z1)
Call GT_GetAtlPos(2, Y1)
Call GT_GetAtlPos(1, X1)
xp = X1 / 1600: yp = Y1 / 1600: zp = z1 / 1600
lblXpos.Caption = Format(xp, "0.000")
lblYpos.Caption = Format(yp, "0.000")
lblZpos.Caption = Format(zp, "0.000")
If chkFour.value = 1 Then
    picXY.Line (tempxpos1, tempypos1)-(xp, yp), RGB(255, 0, 0)
    picZX.Line (tempxpos1, tempzpos1)-(xp, zp), RGB(255, 0, 0)
    picYZ.Line (tempypos1, tempzpos1)-(yp, zp), RGB(255, 0, 0)
    tempxpos1 = xp: tempypos1 = yp: tempzpos1 = zp
End If
If Check4.value = 1 Then
    Call AF(xp, yp, zp)
End If
Picture1.Line (tempxpos, tempypos)-(xp, yp), RGB(255, 0, 0)
tempxpos = xp: tempypos = yp: tempzpos = zp
End Sub

Private Sub daobu()
Static Xs1 As Double, Ys1 As Double, Xs2 As Double, Ys2 As Double, Xs3 As Double, Ys3 As Double, Xs4 As Double, Ys4 As Double
Static rdb As Double
Static Xl1 As Double, Yl1 As Double, Yl2 As Double, Xl2 As Double
Static X1 As Double, Y1 As Double, X0 As Double, Y0 As Double
'Static I As Double, j As Double
'Static f As Double
Static X01 As Double, Y01 As Double
'Static R1 As Double, R2 As Double
Static d1 As Double, d2 As Double
Static j As Integer
Static isjianli As Boolean
Static ischexiao As Boolean
Static two As Integer
Static zj As Byte
Dim tempXl1 As Double, tempYl1 As Double


If G(i, 2) = 40 And ischexiao Then
    Call fuzhi(XYZ(i, 0), XYZ(i, 1), i)
    
ElseIf G(i, 2) = 40 Then
    ischexiao = True
    
ElseIf (G(i, 2) = 41 Or G(i, 2) = 42) And isjianli Then
    If G(i, 2) = 41 Then
        rdb = Abs(Val(txtRdao.Text))
    ElseIf G(i, 2) = 42 Then
        rdb = -1 * Abs(Val(txtRdao.Text))
    End If
    If G(i, 0) = 100 Or G(i, 0) = 101 Then
        Xl2 = (XYZ(i, 0) - XYZ(i - 1, 0)) / Sqr((XYZ(i, 0) - XYZ(i - 1, 0)) ^ 2   (XYZ(i, 1) - XYZ(i - 1, 1)) ^ 2)
        Yl2 = (XYZ(i, 1) - XYZ(i - 1, 1)) / Sqr((XYZ(i, 0) - XYZ(i - 1, 0)) ^ 2   (XYZ(i, 1) - XYZ(i - 1, 1)) ^ 2)
        
        Select Case zjlx(Xl1, Xl2, Yl1, Yl2, rdb)
            Case 0
                Xs1 = X1 - rdb * Yl1
                Ys1 = Y1   rdb * Xl1
                Call fuzhi(Xs1, Ys1, i)
            Case 1
                '2-33
                Xs1 = X1   (Xl2 - Xl1) * rdb / (Xl1 * Yl2 - Xl2 * Yl1)
                Ys1 = Y1   (Yl2 - Yl1) * rdb / (Xl1 * Yl2 - Xl2 * Yl1)
                Call fuzhi(Xs1, Ys1, i)
            Case 2
                '2-36
                Xs1 = X1   (Xl2 - Xl1) * rdb / (Xl1 * Yl2 - Xl2 * Yl1)
                Ys1 = Y1   (Yl2 - Yl1) * rdb / (Xl1 * Yl2 - Xl2 * Yl1)
                Call fuzhi(Xs1, Ys1, i)
            Case 3
                '2-44
                Xs1 = X1 - rdb * Yl1   Abs(rdb) * Xl1
                Ys1 = Y1   rdb * Xl1   Abs(rdb) * Yl1
                Call fuzhi(Xs1, Ys1, i)
                '2-45
                Xs2 = X1 - rdb * Yl2 - Abs(rdb) * Xl2
                Ys2 = Y1   rdb * Xl2 - Abs(rdb) * Yl2
                i = i   1
                Call fuzhi(Xs2, Ys2, i)
        End Select
        Xl1 = Xl2: Yl1 = Yl2
    ElseIf G(i, 0) = 102 Or G(i, 0) = 103 Then
        If G(i, 0) = 102 Then
            If r(i) <> 0 Then
                Call yuanxin(XYZ(i - 1, 0), XYZ(i - 1, 1), XYZ(i, 0), XYZ(i, 1), r(i), True)
                Xl2 = (XYZ(i - 1, 1) - arcy) / Abs(r(i))
                Yl2 = -1 * (XYZ(i - 1, 0) - arcx) / Abs(r(i))
            Else
                arcx = XYZ(i - 1, 0)   IJK(i, 0)
                arcy = XYZ(i - 1, 1)   IJK(i, 1)
                Xl2 = (XYZ(i - 1, 1) - arcy) / Sqr(IJK(i, 0) ^ 2   IJK(i, 1) ^ 2)
                Yl2 = -1 * (XYZ(i - 1, 0) - arcx) / Sqr(IJK(i, 0) ^ 2   IJK(i, 1) ^ 2)
            End If
        Else
            If r(i) <> 0 Then
                Call yuanxin(XYZ(i - 1, 0), XYZ(i - 1, 1), XYZ(i, 0), XYZ(i, 1), r(i), False)
                Xl2 = -1 * (XYZ(i - 1, 1) - arcy) / Abs(r(i))
                Yl2 = (XYZ(i - 1, 0) - arcx) / Abs(r(i))
            Else
                arcx = XYZ(i - 1, 0)   IJK(i, 0)
                arcy = XYZ(i - 1, 1)   IJK(i, 1)
                Xl2 = -1 * (XYZ(i - 1, 1) - arcy) / Sqr(IJK(i, 0) ^ 2   IJK(i, 1) ^ 2)
                Yl2 = (XYZ(i - 1, 0) - arcx) / Sqr(IJK(i, 0) ^ 2   IJK(i, 1) ^ 2)
            End If
        End If
        'zj = zjlx(Xl1, Xl2, Yl1, Yl2, rdb)
        Select Case zjlx(Xl1, Xl2, Yl1, Yl2, rdb)
            Case 1
                 '2-48
                Xs1 = X1 - rdb * Yl2
                Ys1 = Y1   rdb * Xl2
                Call fuzhi(Xs1, Ys1, i)
            Case 2
                '2-55
                Xs1 = X1 - rdb * Yl1
                Ys1 = Y1   rdb * Xl1
                Call fuzhi(Xs1, Ys1, i)
                '2-56
                Xs2 = X1   (Xl2 - Xl1) * rdb / (Xl1 * Yl2 - Xl2 * Yl1)
                Ys2 = Y1   (Yl2 - Yl1) * rdb / (Xl1 * Yl2 - Xl2 * Yl1)
                i = i   1
                Call fuzhi(Xs2, Ys2, i)
                '2-57
                Xs3 = X1 - rdb * Yl2
                Ys3 = Y1   rdb * Xl2
                i = i   1
                Call fuzhi(Xs3, Ys3, i)
            Case 3
                '2-60
                Xs1 = X1 - rdb * Yl1
                Ys1 = Y1   rdb * Xl1
                Call fuzhi(Xs1, Ys1, i)
                '2-61
                Xs2 = X1 - rdb * Yl1   Abs(rdb) * Xl1
                Ys2 = Y1   rdb * Xl1   Abs(rdb) * Yl1
                i = i   1
                Call fuzhi(Xs2, Ys2, i)
                '2-62
                Xs3 = X1 - rdb * Yl2 - Abs(rdb) * Xl2
                Ys3 = Y1   rdb * Xl2 - Abs(rdb) * Yl2
                i = i   1
                Call fuzhi(Xs2, Ys2, i)
                '2-63
                Xs4 = X1 - rdb * Yl2
                Ys4 = Y1   rdb * Xl2
                i = i   1
                Call fuzhi(Xs4, Ys4, i)
        End Select
        Xl1 = Xl2: Yl1 = Yl2
        
    End If
    
    
ElseIf (G(i, 2) = 41 Or G(i, 2) = 42) Then
    If G(i, 2) = 41 Then
        rdb = Abs(Val(txtRdao.Text))
    ElseIf G(i, 2) = 42 Then
        rdb = -1 * Abs(Val(txtRdao.Text))
    End If
    
    If two = 0 Then
        Xl1 = (XYZ(i, 0) - XYZ(i - 1, 0)) / Sqr((XYZ(i, 0) - XYZ(i - 1, 0)) ^ 2   (XYZ(i, 1) - XYZ(i - 1, 1)) ^ 2)
        Yl1 = (XYZ(i, 1) - XYZ(i - 1, 1)) / Sqr((XYZ(i, 0) - XYZ(i - 1, 0)) ^ 2   (XYZ(i, 1) - XYZ(i - 1, 1)) ^ 2)
        two = 1
    Else
        two = 1
        isjianli = True
        If G(i, 0) = 100 Or G(i, 0) = 101 Then
            Xl2 = (XYZ(i, 0) - XYZ(i - 1, 0)) / Sqr((XYZ(i, 0) - XYZ(i - 1, 0)) ^ 2   (XYZ(i, 1) - XYZ(i - 1, 1)) ^ 2)
            Yl2 = (XYZ(i, 1) - XYZ(i - 1, 1)) / Sqr((XYZ(i, 0) - XYZ(i - 1, 0)) ^ 2   (XYZ(i, 1) - XYZ(i - 1, 1)) ^ 2)
            isjianli = True
            Select Case zjlx(Xl1, Xl2, Yl1, Yl2, rdb)
                Case 1
                    Xs1 = X1 - rdb * Yl2
                    Ys1 = Y1   rdb * Xl2
                    Call fuzhi(Xs1, Ys1, i)
                Case 2
                    '2-34
                    Xs1 = X1 - rdb * Yl1
                    Ys1 = Y1   rdb * Yl1
                    Call fuzhi(Xs1, Ys1, i)
                    '2-35
                    Xs2 = X1   (Xl2 - Xl1) * rdb / (Xl1 * Yl2 - Xl2 * Yl1)
                    Ys2 = Y1   (Yl2 - Yl1) * rdb / (Xl1 * Yl2 - Xl2 * Yl1)
                    i = i   1
                    Call fuzhi(Xs2, Ys2, i)
                Case 3
                    '2-38
                    Xs1 = X1 - rdb * Yl1
                    Ys1 = Y1   rdb * Xl1
                    Call fuzhi(Xs1, Ys1, i)
                    '2-39
                    Xs2 = X1 - rdb * Yl1   Abs(rdb) * Xl1
                    Ys2 = Y1   rdb * Xl1   Abs(rdb) * Yl1
                    i = i   1
                    Call fuzhi(Xs2, Ys2, i)
                    '2-40
                    Xs3 = X1 - rdb * Yl2 - Abs(rdb) * Xl2
                    Ys3 = Y1   rdb * Xl2 - Abs(rdb) * Yl2
                    i = i   1
                    Call fuzhi(Xs3, Ys3, i)
            End Select
            Xl1 = Xl2: Yl1 = Yl2
        ElseIf G(i, 0) = 102 Or G(i, 0) = 103 Then
            If G(i, 0) = 102 Then
                If r(i) <> 0 Then
                    Call yuanxin(XYZ(i - 1, 0), XYZ(i - 1, 1), XYZ(i, 0), XYZ(i, 1), r(i), True)
                    Xl2 = (XYZ(i - 1, 1) - arcy) / Abs(r(i))
                    Yl2 = -1 * (XYZ(i - 1, 0) - arcx) / Abs(r(i))
                    tempXl1 = (XYZ(i, 1) - arcy) / Abs(r(i))
                    tempYl1 = -1 * (XYZ(i, 1) - arcy) / Abs(r(i))
                Else
                    arcx = XYZ(i - 1, 0)   IJK(i, 0)
                    arcy = XYZ(i - 1, 1)   IJK(i, 1)
                    Xl2 = (XYZ(i - 1, 1) - arcy) / Sqr(IJK(i, 0) ^ 2   IJK(i, 1) ^ 2)
                    Yl2 = -1 * (XYZ(i - 1, 0) - arcx) / Sqr(IJK(i, 0) ^ 2   IJK(i, 1) ^ 2)
                    tempXl1 = (XYZ(i, 1) - arcy) / Sqr(IJK(i, 0) ^ 2   IJK(i, 1) ^ 2)
                    tempYl1 = -1 * (XYZ(i, 0) - arcx) / Sqr(IJK(i, 0) ^ 2   IJK(i, 1) ^ 2)
                End If
            Else
                If r(i) <> 0 Then
                    Call yuanxin(XYZ(i - 1, 0), XYZ(i - 1, 1), XYZ(i, 0), XYZ(i, 1), r(i), False)
                    Xl2 = -1 * (XYZ(i - 1, 1) - arcy) / Abs(r(i))
                    Yl2 = (XYZ(i - 1, 0) - arcx) / Abs(r(i))
                    tempXl1 = -1 * (XYZ(i, 1) - arcy) / Abs(r(i))
                    tempYl1 = (XYZ(i, 0) - arcx) / Abs(r(i))
                Else
                    arcx = XYZ(i - 1, 0)   IJK(i, 0)
                    arcy = XYZ(i - 1, 1)   IJK(i, 1)
                    Xl2 = -1 * (XYZ(i - 1, 1) - arcy) / Sqr(IJK(i, 0) ^ 2   IJK(i, 1) ^ 2)
                    Yl2 = (XYZ(i - 1, 0) - arcx) / Sqr(IJK(i, 0) ^ 2   IJK(i, 1) ^ 2)
                    tempXl1 = -1 * (XYZ(i, 1) - arcy) / Sqr(IJK(i, 0) ^ 2   IJK(i, 1) ^ 2)
                    tempYl1 = (XYZ(i, 0) - arcx) / Sqr(IJK(i, 0) ^ 2   IJK(i, 1) ^ 2)
                End If
            End If
            'zj = zjlx(Xl1, Xl2, Yl1, Yl2, rdb)
            Select Case zjlx(Xl1, Xl2, Yl1, Yl2, rdb)
                Case 1
                     '2-48
                    Xs1 = X1 - rdb * Yl2
                    Ys1 = Y1   rdb * Xl2
                    Call fuzhi(Xs1, Ys1, i)
                Case 2
                    '2-55
                    Xs1 = X1 - rdb * Yl1
                    Ys1 = Y1   rdb * Xl1
                    Call fuzhi(Xs1, Ys1, i)
                    '2-56
                    Xs2 = X1   (Xl2 - Xl1) * rdb / (Xl1 * Yl2 - Xl2 * Yl1)
                    Ys2 = Y1   (Yl2 - Yl1) * rdb / (Xl1 * Yl2 - Xl2 * Yl1)
                    i = i   1
                    Call fuzhi(Xs2, Ys2, i)
                    '2-57
                    Xs3 = X1 - rdb * Yl2
                    Ys3 = Y1   rdb * Xl2
                    i = i   1
                    Call fuzhi(Xs3, Ys3, i)
                Case 3
                    '2-60
                    Xs1 = X1 - rdb * Yl1
                    Ys1 = Y1   rdb * Xl1
                    Call fuzhi(Xs1, Ys1, i)
                    '2-61
                    Xs2 = X1 - rdb * Yl1   Abs(rdb) * Xl1
                    Ys2 = Y1   rdb * Xl1   Abs(rdb) * Yl1
                    i = i   1
                    Call fuzhi(Xs2, Ys2, i)
                    '2-62
                    Xs3 = X1 - rdb * Yl2 - Abs(rdb) * Xl2
                    Ys3 = Y1   rdb * Xl2 - Abs(rdb) * Yl2
                    i = i   1
                    Call fuzhi(Xs2, Ys2, i)
                    '2-63
                    Xs4 = X1 - rdb * Yl2
                    Ys4 = Y1   rdb * Xl2
                    i = i   1
                    Call fuzhi(Xs4, Ys4, i)
            End Select
            Xl1 = tempXl1: Yl1 = tempYl1
            
        End If
    End If
End If


End Sub


Private Sub fuzhi(Xs As Double, Ys As Double, i As Integer)
Dim j As Integer
For j = 0 To 2
    G1(i, j) = G(i, j)
Next j
XYZ1(i, 0) = Xs
XYZ1(i, 1) = Ys
XYZ1(i, 2) = XYZ(i, 2)
IJK1(i, 0) = IJK(i, 0)
IJK1(i, 1) = IJK(i, 1)
IJK1(i, 2) = IJK(i, 2)
F1(i) = f(i)
R1(i) = r(i)
For j = 0 To 1
    M1(i, j) = M(i, j)
Next j
End Sub

标签: vb 数控

实例下载地址

雕铣机数控系统源码(vb运用)

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警