//------------------------------------------------------------------------------ //Callback Name: apply_cb //------------------------------------------------------------------------------ public int apply_cb() { int errorCode = 0; try { //---- Enter your callback code here ----- Session.UndoMarkId markId = Session.GetSession().SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "删除电极"); ElectrodeModel ele = new ElectrodeModel(); NXOpen.Assemblies.Component eleComp = this.selection_Ele.GetSelectedObjects()[0] as NXOpen.Assemblies.Component; Part elePart = eleComp.Prototype as Part; ele.GetModelForPart(elePart); int ok = theUI.NXMessageBox.Show("删除", NXOpen.NXMessageBox.DialogType.Question, elePart.Name + "电极是否删除"); if (ok == 1) { string path = elePart.FullPath; elePart.Close(NXOpen.BasePart.CloseWholeTree.False, NXOpen.BasePart.CloseModified.UseResponses, null); AssmbliesUtils.DeleteComponent(eleComp); LayerUtils.MoveDisplayableObject(ele.EleInfo.EleNumber + 10, LayerUtils.GetAllObjectsOnLayer(ele.EleInfo.EleNumber + 100)); if (File.Exists(path)) { File.Delete(path); } } } 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> /// <returns></returns> public ElectrodeModel GetElectrodeModel() { ElectrodeModel model = new ElectrodeModel(); model.GetModelForPart(part); return(model); }
//------------------------------------------------------------------------------ //Callback Name: apply_cb //------------------------------------------------------------------------------ public int apply_cb() { int errorCode = 0; try { //---- Enter your callback code here ----- NXOpen.Assemblies.Component ct = this.seleComp.GetSelectedObjects()[0] as NXOpen.Assemblies.Component; Part pt = ct.Prototype as Part; string type = AttributeUtils.GetAttrForString(pt, "PartType"); if (type.Equals("Electrode", StringComparison.CurrentCultureIgnoreCase)) { ElectrodeModel model = new ElectrodeModel(); model.GetModelForPart(pt); ReplacePart.ReplaceElectrode(model, this.strEleName.Value.ToUpper()); } else { ReplacePart.Replace(pt, this.strEleName.Value.ToUpper()); } 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); }
//------------------------------------------------------------------------------ //Callback Name: apply_cb //------------------------------------------------------------------------------ public int apply_cb() { int errorCode = 0; try { //---- Enter your callback code here bool anyPartsModified1; NXOpen.PartSaveStatus partSaveStatus1; Session.GetSession().Parts.SaveAll(out anyPartsModified1, out partSaveStatus1); NXOpen.Assemblies.Component eleComp = this.SeleElePart.GetSelectedObjects()[0] as NXOpen.Assemblies.Component; string name = eleComp.Name + "-" + this.StrName.Value.ToUpper(); if (!this.EleDuplicationOfName(name)) { this.StrName.Value = ""; return(0); } ElectrodeModel eleModel = new ElectrodeModel(); eleModel.GetModelForPart(eleComp.Prototype as Part); name = work.WorkpieceDirectoryPath + name + ".prt"; Vector3d movePt = new Vector3d(double_x.Value, double_y.Value, double_z.Value); NXOpen.Assemblies.Component copyComp = AssmbliesUtils.MoveCompCopyPart(eleComp, movePt, work.WorkMatr); AssmbliesUtils.MakeUnique(copyComp, name); ElectrodeInfo newInfo = this.SetEleInfo(eleModel.EleInfo); newInfo.SetAttribute(copyComp.Prototype as Part); } catch (Exception ex) { //---- Enter your exception handling code here ----- errorCode = 1; theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString()); } return(errorCode); }
public static void Create() { Part workPart = Session.GetSession().Parts.Work; string type = AttributeUtils.GetAttrForString(workPart, "PartType"); if (type.Equals("Electrode", StringComparison.CurrentCultureIgnoreCase)) { ElectrodeModel model = new ElectrodeModel(); model.GetModelForPart(workPart); CreateElectrodeCAM cam = new CreateElectrodeCAM(model, "User"); cam.CreateOperName(); cam.CreateOper(); } else { UI.GetUI().NXMessageBox.Show("注意", NXMessageBox.DialogType.Error, "电极不标准"); return; } }
/// <summary> /// 通过WORK找电极 /// </summary> /// <param name="workNum"></param> /// <returns></returns> public static List <ElectrodeModel> FindElectrodeForWork(WorkModel work) { List <ElectrodeModel> models = new List <ElectrodeModel>(); string name = work.MoldInfo.MoldNumber + "-" + work.MoldInfo.WorkpieceNumber; foreach (Part part in Session.GetSession().Parts) { if (part.Name.Length > name.Length) { int number = AttributeUtils.GetAttrForInt(part, "WorkNumber"); string type = AttributeUtils.GetAttrForString(part, "PartType"); if (work.WorkNumber == number && type == "Electrode" && part.Name.Substring(0, name.Length).Equals(name)) { ElectrodeModel model = new ElectrodeModel(); model.GetModelForPart(part); models.Add(model); } } } return(models); }