//------------------------------------------------------------------------------ //Callback Name: apply_cb //------------------------------------------------------------------------------ public int apply_cb() { int errorCode = 0; try { //---- Enter your callback code here ----- NXOpen.Assemblies.Component workCom = selection_Work.GetSelectedObjects()[0] as NXOpen.Assemblies.Component; WorkModel work = new WorkModel(workCom.Prototype as Part); InterferenceElectrodeBuilder builder = new InterferenceElectrodeBuilder(workCom, work); List <string> err = builder.InterferenceBulider(); if (err.Count != 0) { theUI.NXMessageBox.Show("错误", NXMessageBox.DialogType.Error, "错误!"); ClassItem.Print(err.ToArray()); } else { theUI.NXMessageBox.Show("提示", NXMessageBox.DialogType.Error, "电极正确!"); } AttributeUtils.AttributeOperation("Interference", true, work.PartTag); } catch (Exception ex) { //---- Enter your exception handling code here ----- errorCode = 1; theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString()); } return(errorCode); }
/// <summary> /// 替换工件 /// </summary> /// <param name="ct"></param> private void AlterWorkpiece(NXOpen.Assemblies.Component ct, UserModel user) { MoldInfo mold; if (!ParentAssmblieInfo.IsParent(ct)) { mold = new MoldInfo() { MoldNumber = this.strMoldNumber.Value.ToUpper(), WorkpieceNumber = this.strWorkpieceNumber.Value.ToUpper(), EditionNumber = this.strEditionNumber.Value.ToUpper() }; } else { mold = MoldInfo.GetAttribute(ct); mold.MoldNumber = this.strMoldNumber.Value; mold.WorkpieceNumber = this.strWorkpieceNumber.Value; mold.EditionNumber = this.strEditionNumber.Value; } WorkPieceInfo wk = new WorkPieceInfo(mold, user); string newName = mold.MoldNumber + "-" + mold.WorkpieceNumber + "-" + mold.EditionNumber; Part pt = ct.Prototype as Part; ReplaceOther ot = new ReplaceOther(pt, wk); List <string> err = ot.Alter(newName); if (err.Count > 0) { ClassItem.Print(err.ToArray()); } }
private void buttOk_Click(object sender, EventArgs e) { Part workPart = Session.GetSession().Parts.Work; List <string> err = new List <string>(); for (int i = 0; i < listView.Items.Count; i++) { if (listView.Items[i].Checked) { string workName = listView.Items[i].SubItems[1].Text.ToString(); foreach (WorkModel wm in this.asmColl.GetWorks()) { if (wm.AssembleName.Equals(workName, StringComparison.CurrentCultureIgnoreCase)) { try { WorkDrawingBuilder builder = new WorkDrawingBuilder(wm); builder.CreateDrawing(); } catch (Exception ex) { err.Add(workName + ex.Message + " 无法找到主工件,请检查工件属性!"); } } } } } ClassItem.theSession.ApplicationSwitchImmediate("UG_APP_MODELING"); PartUtils.SetPartDisplay(workPart); if (err.Count > 0) { ClassItem.Print(err.ToArray()); } this.Close(); }
private void butOK_Click(object sender, EventArgs e) { List <string> err = new List <string>(); if (this.fileSave.Equals("")) { this.fileSave = file.GetSaveFilePath(); } if (this.fileSave.Equals("")) { ClassItem.MessageBox("请选择保存文件位置", NXMessageBox.DialogType.Error); return; } foreach (CreateElectrodeCAMBuilder cb in this.camBd) { if (cb.Template.Type == ElectrodeTemplate.User) { err.AddRange(cb.CreateUserOperation()); } else { err.AddRange(cb.CreateOperation()); } cb.SetGenerateToolPath(this.checkBoxIsGenerate.Checked); err.AddRange(cb.ExportFile(this.fileSave, true)); elePart.Remove(cb.Pt); } if (err.Count > 0) { ClassItem.Print(err.ToArray()); } this.Close(); }
private void butOK_Click(object sender, EventArgs e) { List <string> err = new List <string>(); string ftp = @"\\10.221.167.49\cmm_cyc_root\"; for (int i = 0; i < listViewEleInfo.Items.Count; i++) { if (listViewEleInfo.Items[i].Checked) { string oldPath = this.elePart[i].FullPath; string newPath = ftp + GetEleNameForCMM(this.elePart[i]) + ".prt"; try { File.Copy(oldPath, newPath, true); } catch (Exception ex) { err.Add(ex.Message); } } } if (err.Count != 0) { ClassItem.Print(err.ToArray()); } this.Close(); }
/// <summary> /// 获取特征 /// </summary> /// <param name="pt"></param> /// <param name="type"></param> private CreateElectrodeCAMBuilder GetBuilder(Part pt, ElectrodeTemplate type) { CreateElectrodeCAMBuilder cm = camBd.Find(a => a.Pt.Equals(pt)); if (cm != null) { try { cm.CreateOperationNameModel(type); return(cm); } catch (Exception ex) { ClassItem.Print(pt.Name + "无法加载模板 " + ex.Message); } } else { try { CreateElectrodeCAMBuilder cc = new CreateElectrodeCAMBuilder(pt, model); cc.CreateOperationNameModel(type); return(cc); } catch (Exception ex) { ClassItem.Print(pt.Name + "无法加载模板 " + ex.Message); } } return(null); }
private void AlterEle(NXOpen.Assemblies.Component ct) { Part workPart = theSession.Parts.Work; Part pt = ct.Prototype as Part; ElectrodeNameInfo newNameInfo = new ElectrodeNameInfo() { EleEditionNumber = this.strEleEditionNumber.Value.ToUpper(), EleName = this.strEleName.Value + this.strEleName1.Value.ToUpper(), }; newNameInfo.EleNumber = newNameInfo.GetEleNumber(newNameInfo.EleName); ReplaceElectrode el = new ReplaceElectrode(pt, newNameInfo); Part newPart = null; List <string> err = el.AlterEle(out newPart); if (newPart != null) { err.AddRange(el.AlterEleDra()); List <NXObject> objs = AskEleAllInstance(newPart); if (objs.Count > 0) { newNameInfo.SetAttribute(objs.ToArray()); } } PartUtils.SetPartDisplay(workPart); if (err.Count > 0) { ClassItem.Print(err.ToArray()); } }
private static bool PartIsAsm(out List <ProgramModel> groups) { Session theSession = Session.GetSession(); NXOpen.UI theUI = NXOpen.UI.GetUI(); groups = new List <ProgramModel>(); if (!theSession.ApplicationName.Equals("UG_APP_MANUFACTURING", StringComparison.CurrentCultureIgnoreCase)) { theUI.NXMessageBox.Show("错误", NXMessageBox.DialogType.Error, "请切换到加工模块"); return(false); } group = GetNCGroup(); if (group == null) { theUI.NXMessageBox.Show("错误", NXMessageBox.DialogType.Error, "没法找到AAA程序组"); return(false); } ProgramModel model = new ProgramModel(group); if (model.OperData.Count > 0) { theUI.NXMessageBox.Show("错误", NXMessageBox.DialogType.Error, "程序组错误"); return(false); } foreach (NCGroup np in model.GetProgram()) { if (np.GetMembers().Length > 0) { ProgramModel nc = new ProgramModel(np); if (!nc.IsOperation() || !nc.Estimate) { theUI.NXMessageBox.Show("错误", NXMessageBox.DialogType.Error, np.Name + "错误"); return(false); } else { groups.Add(nc); } } } List <string> err = new List <string>(); foreach (ProgramModel pm in groups) { err.AddRange(pm.Gouged()); } if (err.Count > 0) { int ok = theUI.NXMessageBox.Show("错误", NXMessageBox.DialogType.Question, "程序过切!"); if (ok == 2) { ClassItem.Print(err.ToArray()); return(false); } } return(true); }
//------------------------------------------------------------------------------ //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; Part workPart = theSession.Parts.Work; if (ct != null) { List <string> err = new List <string>(); bool isBorrow; if (this.enum0.ValueAsString == "借用电极") { isBorrow = true; } else { isBorrow = false; } MoldInfo old = MoldInfo.GetAttribute(ct); MoldInfo mold = new MoldInfo() { MoldNumber = this.MoldNumber.WideValue.ToUpper(), WorkpieceNumber = this.PartNumber.WideValue.ToUpper(), ClientName = this.ClientNumber.WideValue.ToUpper(), EditionNumber = this.EditionNumber.WideValue.ToUpper(), MoldType = old.MoldType }; ParentAssmblieInfo info = new ParentAssmblieInfo(mold, user.CreatorUser); WorkCollection wkColl = asmColl.GetWorkCollection(old); err.AddRange(AlterWork(wkColl.Work, info)); err.AddRange(AlterEdm(wkColl.EdmModel, info)); err.AddRange(AlterElectrode(wkColl.Electrodes, info, isBorrow)); PartUtils.SetPartDisplay(workPart); ASMModel asm = new ASMModel(workPart); if (asm.Info.MoldInfo.Equals(old)) { err.AddRange(AlterAsm(asm, info)); } 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); }
/// <summary> /// 替换工件 /// </summary> /// <param name="ct"></param> private void AlterWork(NXOpen.Assemblies.Component ct, UserModel user) { int workNumber = this.intWorkNumber.Value; string newName = info.MoldInfo.MoldNumber + "-" + info.MoldInfo.WorkpieceNumber + "-WORK" + workNumber.ToString();; WorkInfo workInfo = new WorkInfo(info.MoldInfo, user, workNumber, (info as WorkInfo).Matr); Part pt = ct.Prototype as Part; ReplaceOther ot = new ReplaceOther(pt, workInfo); List <string> err = ot.Alter(newName); if (err.Count > 0) { ClassItem.Print(err.ToArray()); } }
//------------------------------------------------------------------------------ //Callback Name: apply_cb //------------------------------------------------------------------------------ public int apply_cb() { int errorCode = 0; try { //---- Enter your callback code here ----- List <Body> toolBodys = new List <Body>(); List <Body> eleBodys = new List <Body>(); Matrix4 mat = new Matrix4(); mat.Identity(); Matrix4 inv = mat.GetInversMatrix(); CartesianCoordinateSystem csys = BoundingBoxUtils.CreateCoordinateSystem(mat, inv); List <string> errs = new List <string>(); foreach (TaggedObject tt in this.Selection.GetSelectedObjects()) { Body ttBody = tt as Body; if (ttBody.Prototype != null) { ttBody = ttBody.Prototype as Body; } foreach (TaggedObject t0 in this.Selection1.GetSelectedObjects()) { Body toBody = t0 as Body; if (toBody.Prototype != null) { toBody = toBody.Prototype as Body; } if (!toBody.Equals(ttBody)) { List <string> err = new List <string>(); ComputeDischargeFace cf = new ComputeDischargeFace(toBody, ttBody, mat, csys); cf.GetBodyInfoForInterference(true, out err); errs.AddRange(err); } } } if (errs.Count > 0) { ClassItem.Print(errs.ToArray()); } } catch (Exception ex) { //---- Enter your exception handling code here ----- errorCode = 1; theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString()); } return(errorCode); }
/// <summary> /// 创建特征 /// </summary> /// <param name="mold"></param> private void CreateBulder(MoldInfo mold, string directoryPath) { UserSingleton user = UserSingleton.Instance(); if (user.UserSucceed && user.Jurisd.GetElectrodeJurisd()) { AbstractCreateAssmbile asm = new AsmCreateAssmbile(mold, user.CreatorUser, workPart); List <string> err = asm.CreatePart(directoryPath); err.AddRange(asm.LoadAssmbile()); if (err.Count != 0) { ClassItem.Print(err.ToArray()); } } }
public static void CreateUserOper() { UserSingleton user = UserSingleton.Instance(); if (user.UserSucceed && user.Jurisd.GetCAMJurisd()) { Part workPart = Session.GetSession().Parts.Work; CreateElectrodeCAMBuilder cam = new CreateElectrodeCAMBuilder(workPart, user.CreatorUser); cam.CreateOperationNameModel(ElectrodeTemplate.User); List <string> err = cam.CreateUserOperation(); if (err.Count > 0) { ClassItem.Print(err.ToArray()); } } }
private void butOpen_Click(object sender, EventArgs e) { UFSession theUFSession = UFSession.GetUFSession(); Session theSession = Session.GetSession(); ClassItem.StatusMessge("选择电极文件"); List <string> elePath = new List <string>(); if (elePart.Count == 0) { elePath = file.CopyFile(); } else { string fileName = Path.GetDirectoryName(elePart[0].FullPath) + "\\"; elePath = file.AddFile(fileName); } List <string> errd = new List <string>(); if (elePath.Count > 0) { foreach (string st in elePath) { Tag partTag; UFPart.LoadStatus err; try { theUFSession.Part.Open(st, out partTag, out err); elePart.Add(NXObjectManager.Get(partTag) as Part); } catch (NXException ex) { errd.Add(st + " " + ex.Message); } } if (errd.Count != 0) { ClassItem.Print(errd.ToArray()); } SetEleInfo(); DispSeleteEle(); this.butTemplate.Enabled = true; } }
public bool CreateInterferenceBody() { List <string> info = new List <string>(); foreach (ElectrodeModel ele in eles) { Interference eleInter = new Interference(ele, this.work, this.assemble.Workpieces); List <string> temp = eleInter.InterferenceOfBody(); info.AddRange(temp); } if (info.Count > 0) { foreach (string str in info) { ClassItem.Print(str); } return(false); } return(true); }
private void buttOK_Click(object sender, EventArgs e) { preveiw.DelePattern(); if (comboBox_eleType.Text == null || comboBox_eleType.Text == "") { NXOpen.UI.GetUI().NXMessageBox.Show("错误!", NXMessageBox.DialogType.Error, "请选择电极类型!"); return; } ElectrodeAllInfo all = GetEleInfo(); GetERNumber(all.Pitch); CreateElectrode create = new CreateElectrode(all, parent, condition, this.checkBox1.Checked); List <string> err = create.CreateBuider(); condition.Work.SetInterference(false); Session.GetSession().Parts.Work.ModelingViews.WorkView.Regenerate(); this.Close(); if (err.Count > 0) { ClassItem.Print(err.ToArray()); } }
//------------------------------------------------------------------------------ //Callback Name: apply_cb //------------------------------------------------------------------------------ public int apply_cb() { int errorCode = 0; try { //---- Enter your callback code here ----- if (this.seleEdm.GetSelectedObjects().Length > 0) { Part workPart = theSession.Parts.Work; NXOpen.Assemblies.Component ct = this.seleEdm.GetSelectedObjects()[0] as NXOpen.Assemblies.Component; Part edmPart = ct.Prototype as Part; List <string> err = new List <string>(); if (partPaths.Count > 0) { List <WorkpieceModel> workpiece = CreateBulder(edmPart, partPaths, out err); if (workpiece.Count != 0) { err.AddRange(this.Load(workpiece, edmPart)); } } if (err.Count != 0) { ClassItem.Print(err.ToArray()); } PartUtils.SetPartDisplay(workPart); 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); }
private void buttOk_Click(object sender, EventArgs e) { UserSingleton user = UserSingleton.Instance(); List <string> err = new List <string>(); if (user.UserSucceed && user.Jurisd.GetElectrodeJurisd()) { List <ElectrodeModel> eleModels = asmColl.GetElectrodes(); for (int i = 0; i < listView.Items.Count; i++) { if (listView.Items[i].Checked) { string eleName = listView.Items[i].SubItems[2].Text.ToString(); List <ElectrodeModel> models = eleModels.FindAll(a => a.Info.AllInfo.Name.EleName.Equals(eleName, StringComparison.CurrentCultureIgnoreCase)); if (models.Count > 0) { try { ElectrodeDrawingModel dra = new ElectrodeDrawingModel(models, asm.PartTag, user.CreatorUser); ElectrodeDrawingBuilder builder = new ElectrodeDrawingBuilder(dra, asm); builder.CreateBulider(); } catch (NXException ex) { err.Add(eleName + "电极出图错误!" + ex.Message); } } } } PartUtils.SetPartDisplay(asm.PartTag); Session.GetSession().ApplicationSwitchImmediate("UG_APP_MODELING"); if (err.Count > 0) { ClassItem.Print(err.ToArray()); } } this.Close(); }
//------------------------------------------------------------------------------ //This method shows the dialog on the screen //------------------------------------------------------------------------------ public NXOpen.UIStyler.DialogResponse Show() { try { Part workPart = theSession.Parts.Work; string type = AttributeUtils.GetAttrForString(workPart, "PartType"); if (type != "ASM") { theUI.NXMessageBox.Show("错误", NXMessageBox.DialogType.Error, "请切换ASM档为工作部件!"); return(0); } MoldInfoModel mold = new MoldInfoModel(workPart); assemble = AssembleSingleton.Instance().GetAssemble(mold.MoldNumber + "-" + mold.WorkpieceNumber); theDialog.Show(); if (err.Count != 0) { bool anyPartsModified; PartSaveStatus saveStatus; Part part = null; if ((part = ReplacePart.Replace(assemble.Asm, moldInfo)) != null) { moldInfo.SetAttribute(part); theSession.Parts.SaveAll(out anyPartsModified, out saveStatus); err.Add("修改" + assemble.Asm.AssembleName + "成功!"); } foreach (string st in err) { ClassItem.Print(st); } } } 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); }