//------------------------------------------------------------------------------ //Callback Name: apply_cb //------------------------------------------------------------------------------ public int apply_cb() { int errorCode = 0; try { //---- Enter your callback code here ----- Part workPart = theSession.Parts.Work; CoordinateSystem wcs = workPart.WCS.CoordinateSystem; Matrix4 matr = new Matrix4(); matr.Identity(); matr.TransformToCsys(wcs, ref matr); string number = this.workNumber.ValueAsString.Substring(4); if (addOrModify.Value) { AddWorkBuilder.CreateWork(matr, Convert.ToInt32(number), asmPart); } else { AddWorkBuilder.AlterMatr(matr, Convert.ToInt32(number), asmPart); } CartesianCoordinateSystem csys = workPart.WCS.Save(); csys.Name = this.workNumber.ValueAsString; csys.Layer = 200; csys.Color = 186; PartUtils.SetPartDisplay(asmPart); CsysUtils.SetWcsToAbs(); DeleteObject.Delete(this.points.ToArray()); 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); }
//------------------------------------------------------------------------------ //Callback Name: dialogShown_cb //This callback is executed just before the dialog launch. Thus any value set //here will take precedence and dialog will be launched showing that value. //------------------------------------------------------------------------------ public void dialogShown_cb() { try { //---- Enter your callback code here ----- addOrModify.Value = true; this.numbers = AddWorkBuilder.GetWorkNumber(asmPart); numbers.Sort(); string[] members = { "WORK" + (numbers[numbers.Count - 1] + 1).ToString() }; workNumber.Enable = false; workNumber.SetEnumMembers(members); } catch (Exception ex) { //---- Enter your exception handling code here ----- theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString()); } }
//------------------------------------------------------------------------------ //This method shows the dialog on the screen //------------------------------------------------------------------------------ public NXOpen.UIStyler.DialogResponse Show() { try { workPart = theSession.Parts.Work; string type = AttributeUtils.GetAttrForString(workPart, "PartType"); if (type != "ASM") { theUI.NXMessageBox.Show("错误", NXMessageBox.DialogType.Error, "请切换ASM档为工作部件!"); return(0); } builder = new AddWorkBuilder(workPart); theDialog.Show(); } catch (Exception ex) { //---- Enter your exception handling code here ----- theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString()); } return(0); }
//------------------------------------------------------------------------------ //Callback Name: apply_cb //------------------------------------------------------------------------------ public int apply_cb() { int errorCode = 0; try { //---- Enter your callback code here ----- NXOpen.Assemblies.Component seleCt = this.seleWork.GetSelectedObjects()[0] as NXOpen.Assemblies.Component; if (seleCt != null) { Session.UndoMarkId markId; markId = Session.GetSession().SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "复制电极"); List <string> err = new List <string>(); AddWorkBuilder add = new AddWorkBuilder(asmModel, seleCt); Part pt = GetWorkForName(this.eumWorkName.ValueAsString); if (pt != null) { err.AddRange(add.CopyElectrodeToWork(pt)); } else { err.Add("无法找到WORK!"); } if (err.Count > 0) { ClassItem.Print(err.ToArray()); } } } catch (Exception ex) { //---- Enter your exception handling code here ----- errorCode = 1; theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString()); } return(errorCode); }
//------------------------------------------------------------------------------ //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); }