//------------------------------------------------------------------------------
        //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
 //------------------------------------------------------------------------------
 //This method shows the dialog on the screen
 //------------------------------------------------------------------------------
 public NXOpen.UIStyler.DialogResponse Show()
 {
     try
     {
         UserSingleton user = UserSingleton.Instance();
         if (user.UserSucceed && user.Jurisd.GetElectrodeJurisd())
         {
             Part workPart = theSession.Parts.Work;
             if (!ParentAssmblieInfo.IsWork(workPart))
             {
                 theUI.NXMessageBox.Show("错误", NXMessageBox.DialogType.Error, "请切换到WORK为显示部件!");
                 return(0);
             }
             WorkModel model = new WorkModel(workPart);
             this.matr = model.Info.Matr;
             theDialog.Show();
         }
     }
     catch (Exception ex)
     {
         //---- Enter your exception handling code here -----
         theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
     }
     return(0);
 }
示例#3
0
 public int filter_cb(NXOpen.BlockStyler.UIBlock block, NXOpen.TaggedObject selectedObject)
 {
     if (selectedObject is NXOpen.Assemblies.Component)
     {
         if (ParentAssmblieInfo.IsWork(selectedObject as NXOpen.Assemblies.Component))
         {
             return(NXOpen.UF.UFConstants.UF_UI_SEL_ACCEPT);
         }
     }
     return(NXOpen.UF.UFConstants.UF_UI_SEL_REJECT);
 }
示例#4
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;
     }
 }
示例#5
0
 //------------------------------------------------------------------------------
 //This method shows the dialog on the screen
 //------------------------------------------------------------------------------
 public NXOpen.UIStyler.DialogResponse Show()
 {
     try
     {
         UserSingleton user = UserSingleton.Instance();
         if (user.UserSucceed && user.Jurisd.GetElectrodeJurisd())
         {
             if (!ParentAssmblieInfo.IsWork(workPart))
             {
                 theUI.NXMessageBox.Show("错误", NXMessageBox.DialogType.Error, "请设置WORK为工作部件");
                 return(0);
             }
             theDialog.Show();
         }
     }
     catch (Exception ex)
     {
         //---- Enter your exception handling code here -----
         theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
     }
     return(0);
 }
示例#6
0
        //------------------------------------------------------------------------------
        //Callback Name: update_cb
        //------------------------------------------------------------------------------
        public int update_cb(NXOpen.BlockStyler.UIBlock block)
        {
            try
            {
                if (block == selePart)
                {
                    //---------Enter your code here-----------
                    TaggedObject[] obj = this.selePart.GetLastSelectedObjects();
                    if (obj.Length > 0)
                    {
                        this.seleCt = obj[0] as NXOpen.Assemblies.Component;

                        Part temp = (this.seleCt).Prototype as Part;
                        if (ParentAssmblieInfo.IsWork(temp))
                        {
                            WorkModel wk = new WorkModel(temp);
                            this.group.Show = true;
                            this.workNumber.SetEnumMembers(GetWorkpieceName(wk).ToArray());
                            selectPart = GetWorkPieceForWork(wk);
                        }
                        else
                        {
                            selectPart       = temp;
                            this.group.Show  = false;
                            this.group1.Show = true;
                            this.group2.Show = true;
                        }
                        List <Body> bodys = GetCompBodys(this.seleCt, selectPart);
                        if (bodys.Count > 0)
                        {
                            aoo         = new NXObjectAooearancePoint(bodys.ToArray());
                            this.points = aoo.CreatePoint();
                        }
                        this.selePoint.Enable = true;
                    }
                    else
                    {
                        this.selePoint.Enable = false;
                        selectPart            = null;
                        this.seleCt           = null;
                        DeleteObject.Delete(this.points.ToArray());
                        this.points.Clear();
                        this.selectPt   = null;
                        this.selectFace = null;
                        CsysUtils.SetWcsToAbs();
                    }
                }
                else if (block == addOrModify)
                {
                    //---------Enter your code here-----------
                    if (this.addOrModify.Value)
                    {
                        this.workNumber.Show = true;
                        if (this.points.Count > 0)
                        {
                            DeleteObject.Delete(this.points.ToArray());
                            this.points.Clear();
                        }

                        this.group2.Show = false;
                        this.group1.Show = false;
                    }
                    else
                    {
                        if (selectPart != null)
                        {
                            List <Body> bodys = GetCompBodys(this.seleCt, this.selectPart);
                            if (bodys.Count > 0)
                            {
                                aoo         = new NXObjectAooearancePoint(bodys.ToArray());
                                this.points = aoo.CreatePoint();
                            }
                        }
                        //  this.workNumber.Show = false;
                        this.group1.Show = true;
                        this.group2.Show = true;
                    }
                }
                else if (block == workNumber)
                {
                    //---------Enter your code here-----------
                }
                else if (block == selePoint)
                {
                    //---------Enter your code here-----------
                    if (selePoint.GetSelectedObjects().Length != 0)
                    {
                        TaggedObject obj = selePoint.GetSelectedObjects()[0];
                        //---------Enter your code here-----------
                        if (obj is Point)
                        {
                            this.selectPt = obj as Point;
                        }
                        if (obj is Face)
                        {
                            Face temp = obj as Face;
                            if (this.selectFace != null)
                            {
                                this.selectFace.Unhighlight();
                                if (this.selectFace.Equals(temp))
                                {
                                    this.selectFace = null;
                                }
                                else
                                {
                                    this.selectFace = temp;
                                }
                            }
                            else
                            {
                                this.selectFace = temp;
                            }
                            if (this.selectFace != null)
                            {
                                this.selectFace.Highlight();
                            }
                        }
                        if (selectPt != null)
                        {
                            Point3d temp;
                            if (selectFace != null)
                            {
                                temp = NXObjectAooearancePoint.GetPointToFaceDis(selectPt, selectFace);
                            }
                            else
                            {
                                temp = selectPt.Coordinates;
                            }
                            CsysUtils.SetWcsOfCentePoint(temp);
                        }
                    }
                }
                else if (block == button_X)
                {
                    //---------Enter your code here-----------
                    CsysUtils.RotateWcs(WCS.Axis.XAxis, 90);
                }
                else if (block == button_Y)
                {
                    //---------Enter your code here-----------
                    CsysUtils.RotateWcs(WCS.Axis.YAxis, 90);
                }
                else if (block == button_Z)
                {
                    //---------Enter your code here-----------
                    CsysUtils.RotateWcs(WCS.Axis.ZAxis, 90);
                }
            }
            catch (Exception ex)
            {
                //---- Enter your exception handling code here -----
                theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
            }
            return(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);
 }