private static NXOpen.CAM.NCGroup GetNCGroup()
        {
            Part workPart = Session.GetSession().Parts.Work;

            NXOpen.CAM.NCGroup parent = (NXOpen.CAM.NCGroup)workPart.CAMSetup.CAMGroupCollection.FindObject("AAA");
            return(parent);
        }
示例#2
0
        private static bool IsNC(NXOpen.CAM.NCGroup ncGroup)
        {
            try
            {
                int type;
                int subtype;
                theUfSession.Obj.AskTypeAndSubtype(ncGroup.Tag, out type, out subtype);

                //比對是否為Program群組
                if (type != UFConstants.UF_machining_task_type)
                {
                    return(false);
                }
                //過濾PROGRAM
                if (ncGroup.Name == "PROGRAM")
                {
                    return(false);
                }
            }
            catch (System.Exception ex)
            {
                return(false);
            }
            return(true);
        }
        /// <summary>
        /// 计算刀路
        /// </summary>
        public void SetGenerateToolPath()
        {
            Session theSession = Session.GetSession();
            Part    workPart   = theSession.Parts.Work;

            theSession.ApplicationSwitchImmediate("UG_APP_MANUFACTURING");
            NXOpen.CAM.NCGroup nCGroup1 = (NXOpen.CAM.NCGroup)workPart.CAMSetup.CAMGroupCollection.FindObject("AAA");
            workPart.CAMSetup.GenerateToolPath(new CAMObject[1] {
                nCGroup1
            });
            EleModel.PartTag.Save(BasePart.SaveComponents.False, BasePart.CloseAfterSave.False);
        }
示例#4
0
文件: CaxOper.cs 项目: chiumimy/cax
 /// <summary>
 /// 取得Operation父層名稱
 /// </summary>
 /// <param name="operTag"></param>
 /// <param name="operProgramName"></param>
 /// <returns></returns>
 public static bool AskOperProgramNameFromTag(Tag operTag, out string operProgramName)
 {
     operProgramName = "";
     try
     {
         Tag bb;
         theUfSession.Oper.AskProgramGroup(operTag, out bb);
         NXOpen.CAM.NCGroup gg = (NXOpen.CAM.NCGroup)NXObjectManager.Get(bb);
         operProgramName = gg.Name;
     }
     catch (System.Exception ex)
     {
         return(false);
     }
     return(true);
 }
        private static NXOpen.CAM.NCGroup GetNCGroup()
        {
            Part workPart = Session.GetSession().Parts.Work;

            NXOpen.UI theUI = NXOpen.UI.GetUI();
            try
            {
                NXOpen.CAM.NCGroup parent = (NXOpen.CAM.NCGroup)workPart.CAMSetup.CAMGroupCollection.FindObject("AAA");
                return(parent);
            }
            catch
            {
                theUI.NXMessageBox.Show("错误", NXMessageBox.DialogType.Error, "无法找到  AAA");
            }
            return(null);
        }
示例#6
0
        private void comboBoxNCgroup_SelectedIndexChanged(object sender, EventArgs e)
        {
            //清空superGrid資料
            OperPanel.Rows.Clear();
            //取得comboBox資料
            CurrentNCGroup = comboBoxNCgroup.Text;
            //取得選擇的NC
            foreach (NXOpen.CAM.NCGroup ncGroup in NCGroupAry)
            {
                if (CurrentNCGroup != ncGroup.Name)
                {
                    continue;
                }
                SelectNCGroup = ncGroup;
            }

            //取得Group下的所有OP
            OperationObj = SelectNCGroup.GetMembers();

            #region 填值到SuperGridOperPanel

            GridRow row = new GridRow();
            foreach (KeyValuePair <string, string> kvp in DicNCData)
            {
                if (CurrentNCGroup != kvp.Key)
                {
                    continue;
                }

                string[] splitOperName = kvp.Value.Split(',');

                for (int i = 0; i < splitOperName.Length; i++)
                {
                    //CheckBox1 aaa = new CheckBox1();


                    row = new GridRow(false, splitOperName[i], "");

                    //OperPanel.Columns["挑選"].EditorType = typeof(CheckBox1);
                    OperPanel.Rows.Add(row);
                }
            }

            #endregion
        }
        private static NCGroupModel GetNcGroupModelOfName(OperationNameModel model, ElectrodeCAM cam)
        {
            Part         workPart = Session.GetSession().Parts.Work;
            NCGroupModel group    = new NCGroupModel()
            {
                GeometryGroup = cam.FindGeometry("WORKPIECE"),
                MethodGroup   = cam.MethodGroup.Find(a => a.Name.ToUpper().Equals("CU")),
                ToolGroup     = cam.FindTool(model.ToolName)
            };
            NCGroup temp = cam.FindProgram(model.ProgramName);

            if (temp == null)
            {
                NXOpen.CAM.NCGroup nCGroup1 = (NXOpen.CAM.NCGroup)workPart.CAMSetup.CAMGroupCollection.FindObject("AAA");
                NXOpen.CAM.NCGroup nCGroup2 = workPart.CAMSetup.CAMGroupCollection.CreateProgram(nCGroup1, "electrode", "AAA_1", NXOpen.CAM.NCGroupCollection.UseDefaultName.True, model.ProgramName);
                group.ProgramGroup = nCGroup2;
            }
            else
            {
                group.ProgramGroup = temp;
            }
            return(group);
        }
示例#8
0
 /// <summary>
 /// 计算刀路
 /// </summary>
 public bool SetGenerateToolPath(bool isGenerate)
 {
     if (isGenerate && cam.IsCompute)
     {
         Session theSession = Session.GetSession();
         Part    workPart   = theSession.Parts.Work;
         try
         {
             theSession.ApplicationSwitchImmediate("UG_APP_MANUFACTURING");
             NXOpen.CAM.NCGroup nCGroup1 = (NXOpen.CAM.NCGroup)workPart.CAMSetup.CAMGroupCollection.FindObject("AAA");
             workPart.CAMSetup.GenerateToolPath(new CAMObject[1] {
                 nCGroup1
             });
             pt.Save(BasePart.SaveComponents.False, BasePart.CloseAfterSave.False);
             return(true);
         }
         catch
         {
             return(false);
         }
     }
     return(false);
 }
示例#9
0
        /// <summary>
        /// 取得NCGroupMessage
        /// </summary>
        /// <param name="nCGroup"></param>
        /// <returns></returns>
        public static string AskNCGroupMessage(NXOpen.CAM.NCGroup nCGroup)
        {
            string NCGroupMessage = "";

            try
            {
                NXOpen.CAM.ProgramOrderGroupBuilder programOrderGroupBuilder1;
                programOrderGroupBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateProgramOrderGroupBuilder(nCGroup);
                TaggedObject taggedObject1;
                taggedObject1 = programOrderGroupBuilder1.StartUdeSet.UdeList.FindItem(0);
                NXOpen.CAM.Ude          ude1 = (NXOpen.CAM.Ude)taggedObject1;
                NXOpen.CAM.UdeParameter udeParameter1;
                udeParameter1  = ude1.GetParameter("operator_message");
                NCGroupMessage = udeParameter1.StringValue;
                programOrderGroupBuilder1.Destroy();

                return(NCGroupMessage);
            }
            catch (System.Exception ex)
            {
                return(NCGroupMessage);
            }
        }
        private void comboBoxNCgroup_SelectedIndexChanged(object sender, EventArgs e)
        {
            PostPanel.Rows.Clear();
            //清空superGrid資料&機台資訊
            OperPanel.Rows.Clear();
            MachineNo.Text = "";
            //取得comboBox資料
            CurrentNCGroup = comboBoxNCgroup.Text;

            #region 建立NC資料夾
            string Is_Local = "";
            Is_Local = Environment.GetEnvironmentVariable("UGII_ENV_FILE");
            if (Is_Local != null)
            {
                //CaxPublic.GetAllPath("TE", displayPart.FullPath, out sPartInfo, ref cMETE_Download_Upload_Path);
                //if (!cMETE_Download_Upload_Path.Local_Folder_CAM.Contains("Oper1"))
                //{
                //    NCFolderPath = string.Format(@"{0}\{1}_{2}", cMETE_Download_Upload_Path.Local_Folder_CAM, CurrentNCGroup, "NC");
                //}
                //else
                //{
                //    NCFolderPath = string.Format(@"{0}\{1}_{2}", Path.GetDirectoryName(displayPart.FullPath), CurrentNCGroup, "NC");
                //}
                if (displayPart.FullPath.Contains("D:\\Globaltek\\Task"))
                {
                    CaxPublic.GetAllPath("TE", displayPart.FullPath, out sPartInfo, ref cMETE_Download_Upload_Path);
                    NCFolderPath = string.Format(@"{0}\{1}_{2}", cMETE_Download_Upload_Path.Local_Folder_CAM, CurrentNCGroup, "NC");
                }
                else
                {
                    NCFolderPath = string.Format(@"{0}\{1}_{2}", System.IO.Path.GetDirectoryName(displayPart.FullPath), CurrentNCGroup, "NC");
                }
            }
            else
            {
                NCFolderPath = string.Format(@"{0}\{1}_{2}", Path.GetDirectoryName(displayPart.FullPath), CurrentNCGroup, "NC");
            }


            if (!Directory.Exists(NCFolderPath))
            {
                System.IO.Directory.CreateDirectory(NCFolderPath);
            }
            #endregion

            //取得選擇的NC
            foreach (NXOpen.CAM.NCGroup ncGroup in NCGroupAry)
            {
                if (CurrentNCGroup == ncGroup.Name)
                {
                    SelectNCGroup = ncGroup;
                }
            }

            //取得Group下的所有OP
            OperationObj = SelectNCGroup.GetMembers();

            #region 填值到SuperGridOperPanel
            GridRow gridRow = new GridRow();
            foreach (KeyValuePair <string, string> kvp in DicNCData)
            {
                if (CurrentNCGroup != kvp.Key)
                {
                    continue;
                }
                string[] splitOperName = kvp.Value.Split(',');

                for (int i = 0; i < splitOperName.Length; i++)
                {
                    gridRow = new GridRow(false, splitOperName[i], "");
                    OperPanel.Rows.Add(gridRow);
                }
            }
            #endregion

            //填機台到MachineNo欄位並取得對應後處理器
            try
            {
                this.MachineNo.Text = PostProcessorDlg.SelectNCGroup.GetStringAttribute("MachineNo");
            }
            catch (Exception exception)
            {
                this.MachineNo.Text = "";
            }
            if (this.MachineNo.Text == "")
            {
                gridRow = new GridRow("");
                PostProcessorDlg.PostPanel.Rows.Add(gridRow);
                for (int k = 0; k < (int)PostProcessorDlg.TemplatePostData.Length; k++)
                {
                    if (k > 6)
                    {
                        string templatePostData = PostProcessorDlg.TemplatePostData[k];
                        char[] chrArray         = new char[] { ',' };
                        gridRow = new GridRow(templatePostData.Split(chrArray)[0]);
                        PostProcessorDlg.PostPanel.Rows.Add(gridRow);
                    }
                }
            }
            else
            {
                gridRow = new GridRow("");
                PostProcessorDlg.PostPanel.Rows.Add(gridRow);
                ISession      session    = MyHibernateHelper.SessionFactory.OpenSession();
                List <string> strs       = new List <string>();
                string[]      strArrays1 = this.MachineNo.Text.Split(new char[] { ',' });
                int           num        = 0;
                while (num < (int)strArrays1.Length)
                {
                    string        str          = strArrays1[num];
                    Sys_MachineNo sysMachineNo = session.QueryOver <Sys_MachineNo>().Where((Sys_MachineNo x) => x.machineNo == str).SingleOrDefault <Sys_MachineNo>();
                    if (sysMachineNo.postprocessor != null)
                    {
                        string[] strArrays2 = sysMachineNo.postprocessor.Split(new char[] { ',' });
                        for (int l = 0; l < (int)strArrays2.Length; l++)
                        {
                            string str1 = strArrays2[l];
                            if (!strs.Contains(str1))
                            {
                                strs.Add(str1);
                            }
                        }
                        num++;
                    }
                    else
                    {
                        for (int m = 0; m < (int)PostProcessorDlg.TemplatePostData.Length; m++)
                        {
                            if (m > 6)
                            {
                                string templatePostData1 = PostProcessorDlg.TemplatePostData[m];
                                char[] chrArray1         = new char[] { ',' };
                                gridRow = new GridRow(templatePostData1.Split(chrArray1)[0]);
                                PostProcessorDlg.PostPanel.Rows.Add(gridRow);
                            }
                        }
                        break;
                    }
                }
                foreach (string str2 in strs)
                {
                    gridRow = new GridRow(str2);
                    PostProcessorDlg.PostPanel.Rows.Add(gridRow);
                }
            }

            /*
             * try
             * {
             *  MachineNo.Text = SelectNCGroup.GetStringAttribute("MachineNo");
             *  //postprocessor = SelectNCGroup.GetStringAttribute("postprocessor");
             * }
             * catch (System.Exception ex)
             * {
             *  MachineNo.Text = "";
             *  postprocessor = "";
             * }
             *
             * if (postprocessor != "")
             * {
             *  string[] splitPostProcessor = postprocessor.Split(',');
             *  string empty = "";
             *  row = new GridRow(empty);
             *  PostPanel.Rows.Add(row);
             *  for (int i = 0; i < splitPostProcessor.Length; i++)
             *  {
             *      row = new GridRow(splitPostProcessor[i]);
             *      PostPanel.Rows.Add(row);
             *  }
             #region 在ShopDoc中有指定機台並且有後處理
             *  if (splitPostProcessor.Length == 1)
             *  {
             *      //如果只有一個後處理,則自動對應
             *      for (int i = 0; i < OperPanel.Rows.Count;i++ )
             *      {
             *          OperPanel.GetCell(i, 2).Value = splitPostProcessor[0];
             *      }
             *  }
             #endregion
             * }
             * else
             * {
             #region 在ShopDoc中沒指定機台or有指定機台但沒有後處理,則顯示全部後處理
             *  string empty = "";
             *  row = new GridRow(empty);
             *  PostPanel.Rows.Add(row);
             *  for (int i = 0; i < TemplatePostData.Length; i++)
             *  {
             *      if (i > 6)
             *      {
             *          string PostName = TemplatePostData[i].Split(',')[0];
             *          row = new GridRow(PostName);
             *          PostPanel.Rows.Add(row);
             *      }
             *  }
             #endregion
             * }
             */
        }
示例#11
0
        private void comboBoxNCgroup_SelectedIndexChanged(object sender, EventArgs e)
        {
            //清空listView資料
            listView1.Items.Clear();
            listView3.Items.Clear();
            listView4.Items.Clear();
            listView5.Items.Clear();
            //取得comboBox資料
            CurrentNCGroup = comboBoxNCgroup.Text;

            //取得選擇的NC
            foreach (NXOpen.CAM.NCGroup ncGroup in NCGroupAry)
            {
                if (CurrentNCGroup != ncGroup.Name)
                {
                    continue;
                }
                NCGroupMessage = CaxOper.AskNCGroupMessage(ncGroup);
                SelectNCGroup  = ncGroup;
            }

            //當選擇海德漢控制器時,修改檔頭檔尾
            NewGroupName = "O" + Regex.Replace(CurrentNCGroup, "[^0-9]", "") + "0";



            if (chb_Heidenhain.Checked == true)
            {
                for (int i = 0; i < cControlerConfig.Controler.Count; i++)
                {
                    if (cControlerConfig.Controler[i].CompanyName == chb_Heidenhain.Text)
                    {
                        if (cControlerConfig.Controler[i].MasterValue1 != "")
                        {
                            listView3.Items.Add(cControlerConfig.Controler[i].MasterValue1);
                        }
                        if (cControlerConfig.Controler[i].MasterValue2 != "")
                        {
                            listView4.Items.Add(cControlerConfig.Controler[i].MasterValue2);
                        }
                        if (cControlerConfig.Controler[i].MasterValue3 != "")
                        {
                            listView4.Items.Add(cControlerConfig.Controler[i].MasterValue3);
                        }
                        break;
                    }
                }

                listView3.Items[0].Text = listView3.Items[0].Text.Replace("[NCGroupName]", NewGroupName);
                listView3.Items.Add(";(" + NCGroupMessage + ")");
                listView4.Items[1].Text = listView4.Items[1].Text.Replace("[NCGroupName]", NewGroupName);
            }
            else if (chb_Fanuc.Checked == true)
            {
                for (int i = 0; i < cControlerConfig.Controler.Count; i++)
                {
                    if (cControlerConfig.Controler[i].CompanyName == chb_Fanuc.Text)
                    {
                        if (cControlerConfig.Controler[i].MasterValue1 != "")
                        {
                            ListViewItem tempViewItem = new ListViewItem(cControlerConfig.Controler[i].MasterValue1);
                            listView3.Items.Add(tempViewItem);
                        }
                        if (cControlerConfig.Controler[i].MasterValue2 != "")
                        {
                            ListViewItem tempViewItem = new ListViewItem(cControlerConfig.Controler[i].MasterValue2);
                            listView4.Items.Add(tempViewItem);
                        }
                        if (cControlerConfig.Controler[i].MasterValue3 != "")
                        {
                            ListViewItem tempViewItem = new ListViewItem(cControlerConfig.Controler[i].MasterValue3);
                            listView4.Items.Add(tempViewItem);
                        }
                        break;
                    }
                }
                listView3.Items.Add(NewGroupName + "(" + NCGroupMessage + ")");
            }

            //取得Group下的所有OP
            OperObjAry = SelectNCGroup.GetMembers();

            #region 填值到ListView5

            foreach (KeyValuePair <string, string> kvp in DicNCData)
            {
                if (CurrentNCGroup != kvp.Key)
                {
                    continue;
                }

                string[] splitOperName = kvp.Value.Split(',');

                for (int i = 0; i < splitOperName.Length; i++)
                {
                    ListViewItem tempViewItem = new ListViewItem(splitOperName[i]);
                    ListViewItem.ListViewSubItem tempViewSubItem = new ListViewItem.ListViewSubItem();
                    foreach (CAMObject tempOper in OperObjAry)
                    {
                        if (splitOperName[i] == tempOper.Name)
                        {
                            tempViewSubItem = new ListViewItem.ListViewSubItem(tempViewItem, CaxOper.AskOperToolNumber((NXOpen.CAM.Operation)tempOper));
                        }
                    }

                    tempViewItem.SubItems.Add(tempViewSubItem);
                    listView5.Items.Add(tempViewItem);
                }
            }

            #endregion
        }