예제 #1
0
        //------------------------------------------------------------------------------
        //Callback Name: filter_cb
        //------------------------------------------------------------------------------
        public int filter_cb(NXOpen.BlockStyler.UIBlock block, NXOpen.TaggedObject selectedObject)
        {
            Part part = (selectedObject as NXOpen.Assemblies.Component).Prototype as Part;

            if (part != null)
            {
                if (!WorkModel.IsWork(part))
                {
                    return(UFConstants.UF_UI_SEL_REJECT);
                }
            }
            return(NXOpen.UF.UFConstants.UF_UI_SEL_ACCEPT);
        }
 public void Show()
 {
     if (user.UserSucceed && user.Jurisd.GetElectrodeJurisd())
     {
         Session.UndoMarkId markId;
         markId = Session.GetSession().SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "基准台");
         if (!WorkModel.IsWork(workPart))
         {
             NXOpen.UI.GetUI().NXMessageBox.Show("错误", NXMessageBox.DialogType.Error, "请设置WORK为工作部件");
             return;
         }
         WorkModel work      = new WorkModel(workPart);
         Matrix4   mat       = (work.Info).Matr;
         Part      workpiece = work.GetHostWorkpiece();
         if (workpiece == null)
         {
             NXOpen.UI.GetUI().NXMessageBox.Show("错误", NXMessageBox.DialogType.Error, "无法找到主件");
             return;
         }
         List <Body> headBodys = SelectObject();
         if (headBodys == null || headBodys.Count == 0)
         {
             return;
         }
         ElectrodeCreateCondition condition = new ElectrodeCreateCondition(expAndMatr, headBodys, work, workpiece);
         if (expAndMatr.Matr.AnalyeBackOffFace())
         {
             int ok = NXOpen.UI.GetUI().NXMessageBox.Show("错误", NXMessageBox.DialogType.Question, "电极有倒扣!");
             if (ok != 1)
             {
                 return;
             }
         }
         ParentAssmblieInfo parent = new ParentAssmblieInfo(work.Info.MoldInfo, user.CreatorUser);
         ShowForm(condition, parent, work);
     }
 }
예제 #3
0
        //------------------------------------------------------------------------------
        //Callback Name: apply_cb
        //------------------------------------------------------------------------------
        public int apply_cb()
        {
            int errorCode = 0;

            try
            {
                //---- Enter your callback code here -----

                if (this.selectPart != null)
                {
                    CoordinateSystem wcs  = workPart.WCS.CoordinateSystem;
                    Matrix4          matr = new Matrix4();
                    matr.Identity();
                    Part          temp = this.seleCt.Prototype as Part;
                    List <string> err  = new List <string>();
                    if (WorkModel.IsWork(temp))
                    {
                        WorkModel wm = new WorkModel(temp);
                        if (!this.addOrModify.Value)
                        {
                            matr.TransformToCsys(wcs, ref matr);
                            if (!this.AlterWork(wm, matr))
                            {
                                theUI.NXMessageBox.Show("错误", NXMessageBox.DialogType.Error, "修改设定坐标错误!");
                            }
                        }
                        else
                        {
                            AddWorkBuilder add           = new AddWorkBuilder(asmModel, this.seleCt);
                            string         workpieceName = this.GetWorkpieceNumber(this.workNumber.ValueAsString, wm);
                            if (wm.Info.MoldInfo.WorkpieceNumber.Equals(workpieceName, StringComparison.CurrentCultureIgnoreCase))
                            {
                                err.AddRange(add.CopWork(user.CreatorUser));
                            }
                            else
                            {
                                err.AddRange(add.CopOtherWork(user.CreatorUser, this.workNumber.ValueAsString));
                            }
                        }
                    }
                    else
                    {
                        if (!this.addOrModify.Value)
                        {
                            matr.TransformToCsys(wcs, ref matr);
                        }
                        else
                        {
                            matr = GetParentWorkMatr(seleCt);
                        }

                        AddWorkBuilder add = new AddWorkBuilder(asmModel, this.seleCt.Parent.Parent);
                        err.AddRange(add.CreateWork(user.CreatorUser, this.seleCt, matr));
                    }
                    if (err.Count > 0)
                    {
                        ClassItem.Print(err.ToArray());
                    }
                    if (points.Count != 0)
                    {
                        DeleteObject.Delete(this.points.ToArray());
                    }
                    CsysUtils.SetWcsToAbs();
                    bool anyPartsModified1;
                    NXOpen.PartSaveStatus partSaveStatus1;
                    Session.GetSession().Parts.SaveAll(out anyPartsModified1, out partSaveStatus1);
                }
            }
            catch (Exception ex)
            {
                //---- Enter your exception handling code here -----
                errorCode = 1;
                theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
            }
            return(errorCode);
        }