try { int total = int.Parse(tBox_PGNum.Text);//取得输入的数量 string begin_str = tBox_BeginChar.Text; int begin = int.Parse(Regex.Match(begin_str, @"d+[^d]*$").ToString());//取得输入开始字符的最后一组数字 begin_str = begin_str.Substring(0, begin_str.LastIndexOf(begin.ToString()));//取得要生成程式组前段字符 for (int i = begin; i < total + begin; i++) { thePart.CAMSetup.CAMGroupCollection.CreateProgram((NXOpen.CAM.NCGroup)m_UI.SelectionManager.GetSelectedObject(0), "mill_contour", "PROGRAM", NXOpen.CAM.NCGroupCollection.UseDefaultName.False, begin_str + i); } Lbl_waring.Text = "程序组已创建"; } catch (NXException ex)//引用 NXOPEN.Utilities { m_UI.NXMessageBox.Show("error!", NXMessageBox.DialogType.Error, ex.Message); }