예제 #1
0
        //------------------------------------------------------------------------------
        //Callback Name: apply_cb
        //------------------------------------------------------------------------------
        public int apply_cb()
        {
            int errorCode = 0;

            try
            {
                //---- Enter your callback code here -----
                NXOpen.Assemblies.Component ct = seleComp.GetSelectedObjects()[0] as NXOpen.Assemblies.Component;
                if (ParentAssmblieInfo.IsElectrode(ct))
                {
                    AlterEle(ct);
                }
                else if (ParentAssmblieInfo.IsWork(ct))
                {
                    AlterWork(ct, user.CreatorUser);
                }
                else if (ParentAssmblieInfo.IsWorkpiece(ct) || !ParentAssmblieInfo.IsParent(ct))
                {
                    AlterWorkpiece(ct, user.CreatorUser);
                }

                bool           anyPartsModified;
                PartSaveStatus saveStatus;
                theSession.Parts.SaveAll(out anyPartsModified, out saveStatus);
            }
            catch (Exception ex)
            {
                //---- Enter your exception handling code here -----
                errorCode = 1;
                theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
            }
            return(errorCode);
        }
예제 #2
0
 //------------------------------------------------------------------------------
 //Callback Name: filter_cb
 //------------------------------------------------------------------------------
 public int filter_cb(NXOpen.BlockStyler.UIBlock block, NXOpen.TaggedObject selectedObject)
 {
     NXOpen.Assemblies.Component ct = (selectedObject as NXOpen.Assemblies.Component);
     if (ct != null)
     {
         if (!ParentAssmblieInfo.IsElectrode(ct))
         {
             return(UFConstants.UF_UI_SEL_REJECT);
         }
     }
     return(NXOpen.UF.UFConstants.UF_UI_SEL_ACCEPT);
 }
예제 #3
0
 /// <summary>
 /// 获取电极号
 /// </summary>
 /// <returns></returns>
 public string GetEleName()
 {
     if (ParentAssmblieInfo.IsElectrode(this.pt))
     {
         ElectrodeNameInfo name = ElectrodeNameInfo.GetAttribute(this.pt);
         if (pt.Name.Equals(name.EleName, StringComparison.CurrentCultureIgnoreCase))
         {
             return(name.EleName);
         }
     }
     return(pt.Name);
 }
예제 #4
0
 //------------------------------------------------------------------------------
 //Callback Name: filter_cb
 //------------------------------------------------------------------------------
 public int filter_cb(NXOpen.BlockStyler.UIBlock block, NXOpen.TaggedObject selectedObject)
 {
     NXOpen.Assemblies.Component ct = selectedObject as NXOpen.Assemblies.Component;
     if (ct != null)
     {
         if (ParentAssmblieInfo.IsElectrode(ct) || ParentAssmblieInfo.IsWorkpiece(ct) || !ParentAssmblieInfo.IsParent(ct) || ParentAssmblieInfo.IsWork(ct))
         {
             return(NXOpen.UF.UFConstants.UF_UI_SEL_ACCEPT);
         }
     }
     return(NXOpen.UF.UFConstants.UF_UI_SEL_FAILURE);
 }
예제 #5
0
        /// <summary>
        /// 获取电极Component
        /// </summary>
        /// <returns></returns>
        public List <NXOpen.Assemblies.Component> GetElectrodeComponent()
        {
            List <NXOpen.Assemblies.Component> eleCt = new List <NXOpen.Assemblies.Component>();

            foreach (NXOpen.Assemblies.Component ct in this.workCt.GetChildren())
            {
                if (ParentAssmblieInfo.IsElectrode(ct))
                {
                    eleCt.Add(ct);
                }
            }
            return(eleCt);
        }
예제 #6
0
        /// <summary>
        ///获取有电极程序模板的电极
        /// </summary>
        /// <returns></returns>
        private List <Part> GetElePartForCamInfo()
        {
            List <Part> elePart = new List <Part>();

            Session theSession = Session.GetSession();

            foreach (Part pt in theSession.Parts)
            {
                if (ParentAssmblieInfo.IsElectrode(pt))
                {
                    elePart.Add(pt);
                }
            }
            return(elePart);
        }
예제 #7
0
        private void Initialize()
        {
            Part workPart = Session.GetSession().Parts.Work;

            if (ParentAssmblieInfo.IsElectrode(workPart))
            {
                this.listBoxPostName.SelectedIndex = 4;
            }
            foreach (ProgramModel np in models)
            {
                groups.Add(np.ProgramGroup);
                ListViewItem lv = new ListViewItem();
                lv.SubItems.Add(np.ProgramGroup.Name);
                lv.Checked = true;
                listViewProgram.Items.Add(lv);
            }
        }
예제 #8
0
        /// <summary>
        ///获取有电极程序模板的电极
        /// </summary>
        /// <returns></returns>
        private List <Part> GetElePartForCamInfo()
        {
            List <Part> elePart = new List <Part>();

            Session theSession = Session.GetSession();

            foreach (Part pt in theSession.Parts)
            {
                if (ParentAssmblieInfo.IsElectrode(pt))
                {
                    ElectrodeCAMInfo cam = ElectrodeCAMInfo.GetAttribute(pt);
                    if (cam.CamTemplate == null || cam.CamTemplate != "")
                    {
                        elePart.Add(pt);
                    }
                }
            }
            return(elePart);
        }
예제 #9
0
 /// <summary>
 /// 获取间隙
 /// </summary>
 /// <returns></returns>
 public ElectrodeGapValueInfo GetGapValueInfo()
 {
     if (ParentAssmblieInfo.IsElectrode(this.pt))
     {
         return(ElectrodeGapValueInfo.GetAttribute(this.pt));
     }
     else
     {
         return(new ElectrodeGapValueInfo()
         {
             CrudeInter = 0,
             CrudeNum = 0,
             DuringInter = 0,
             DuringNum = 0,
             FineInter = 0,
             FineNum = 0
         });
     }
 }
예제 #10
0
 /// <summary>
 /// 设置对话框显示
 /// </summary>
 private void SetDisp(NXOpen.Assemblies.Component ct)
 {
     if (ParentAssmblieInfo.IsElectrode(ct))
     {
         this.groupEle.Show = true;
         info = ElectrodeInfo.GetAttribute(ct);
         //this.strMoldNumber.Show = false;
         // this.strWorkpieceNumber.Show = false;
         // this.strEditionNumber.Show = false;
         this.groupWorkpiece.Show = false;
         this.groupWork.Show      = false;
         ElectrodeInfo eleInfo = info as ElectrodeInfo;
         string        temp    = info.MoldInfo.MoldNumber + "-" + info.MoldInfo.WorkpieceNumber;
         this.strEleName.Value          = temp;
         this.strEleName1.Value         = eleInfo.AllInfo.Name.EleName.Substring(temp.Length, eleInfo.AllInfo.Name.EleName.Length - temp.Length);
         this.strEleEditionNumber.Value = eleInfo.AllInfo.Name.EleEditionNumber;
     }
     else if (ParentAssmblieInfo.IsWorkpiece(ct))
     {
         info = WorkPieceInfo.GetAttribute(ct);
         this.groupWorkpiece.Show      = true;
         this.groupEle.Show            = false;
         this.groupWork.Show           = false;
         this.strMoldNumber.Value      = info.MoldInfo.MoldNumber;
         this.strWorkpieceNumber.Value = info.MoldInfo.WorkpieceNumber;
         this.strEditionNumber.Value   = info.MoldInfo.EditionNumber;
     }
     else if (ParentAssmblieInfo.IsWork(ct))
     {
         info = WorkInfo.GetAttribute(ct);
         this.groupWork.Show      = true;
         this.groupEle.Show       = false;
         this.groupWorkpiece.Show = false;
         this.intWorkNumber.Value = (info as WorkInfo).WorkNumber;
     }
     else if (!ParentAssmblieInfo.IsParent(ct))
     {
         this.groupWorkpiece.Show      = true;
         this.groupEle.Show            = false;
         this.strWorkpieceNumber.Value = ct.Name;
     }
 }
        /// <summary>
        /// 设置电极信息
        /// </summary>
        private void SetEleInfo()
        {
            DataTable table;

            try
            {
                table = ElectrodeAllInfo.CreateDataTable();
            }
            catch (Exception ex)
            {
                ClassItem.WriteLogFile("创建表列错误!" + ex.Message);
                return;
            }
            foreach (Part pt in elePart)
            {
                if (ParentAssmblieInfo.IsElectrode(pt))
                {
                    ElectrodeModel em = new ElectrodeModel(pt);
                    try
                    {
                        em.Info.AllInfo.CreateDataRow(ref table);
                    }
                    catch (Exception ex)
                    {
                        ClassItem.WriteLogFile(em.AssembleName + "          创建行错误!" + ex.Message);
                    }
                }
                else if (!ParentAssmblieInfo.IsParent(pt))
                {
                    DataRow row = table.NewRow();
                    row["EleName"] = pt.Name;
                    table.Rows.Add(row);
                }
            }
            dataGridViewEle.DataSource = table;
        }
        public static AbstractElectrodeCAM CreateCAM(Part pt, UserModel user)
        {
            AbstractElectrodeCAM cam = null;

            if (ParentAssmblieInfo.IsElectrode(pt))
            {
                ElectrodeModel        em  = new ElectrodeModel(pt);
                ElectrodeGapValueInfo gap = em.Info.AllInfo.GapValue;
                if ((gap.ERNum[0] != 0 || gap.ERNum[1] != 0) && (gap.FineInter != 0 && gap.FineNum != 0) &&
                    (gap.CrudeInter != 0 && gap.CrudeNum == 0))
                {
                    try
                    {
                        cam = new ErAndEfElectrodeCAM(em, user);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
                else if (((gap.FineInter != 0 && gap.FineNum != 0) && (gap.CrudeInter != 0 && gap.CrudeNum != 0)) ||
                         ((gap.FineInter != 0 && gap.FineNum != 0) && (gap.DuringInter != 0 && gap.DuringNum != 0)) ||
                         ((gap.CrudeInter != 0 && gap.CrudeNum != 0) && (gap.DuringInter != 0 && gap.DuringNum != 0)))
                {
                    try
                    {
                        cam = new ManyInterElectrodeCAM(em, user);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
                else if (((gap.FineInter != 0 && gap.FineNum != 0) && (gap.CrudeInter == 0 && gap.CrudeNum == 0) && (gap.DuringNum == 0 && gap.DuringNum == 0)) ||
                         ((gap.FineInter == 0 && gap.FineNum == 0) && (gap.CrudeInter != 0 && gap.CrudeNum != 0) && (gap.DuringNum == 0 && gap.DuringNum == 0)) ||
                         ((gap.FineInter == 0 && gap.FineNum == 0) && (gap.CrudeInter == 0 && gap.CrudeNum == 0) && (gap.DuringNum != 0 && gap.DuringNum != 0)))
                {
                    try
                    {
                        cam = new OnlyInterElectrodeCAM(em, user);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }

                else
                {
                    try
                    {
                        cam = new NonStandardElectrodeCAM(pt, user);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
            else
            {
                try
                {
                    cam = new NonStandardElectrodeCAM(pt, user);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(cam);
        }