//------------------------------------------------------------------------------ //Treelist specific callbacks //------------------------------------------------------------------------------ //public void OnExpandCallback(NXOpen.BlockStyler.Tree tree, NXOpen.BlockStyler.Node node) //{ //} //public void OnInsertColumnCallback(NXOpen.BlockStyler.Tree tree, NXOpen.BlockStyler.Node node, int columnID) //{ //} //public void OnInsertNodecallback(NXOpen.BlockStyler.Tree tree, NXOpen.BlockStyler.Node node) //{ //} //public void OnDeleteNodecallback(NXOpen.BlockStyler.Tree tree, NXOpen.BlockStyler.Node node) //{ //} //public void OnPreSelectcallback(NXOpen.BlockStyler.Tree tree, NXOpen.BlockStyler.Node node, int columnID, bool Selected) //{ //} public void OnSelectcallback(NXOpen.BlockStyler.Tree tree, NXOpen.BlockStyler.Node node, int columnID, bool Selected) { Part workPart = theSession.Parts.Work; foreach (Body by in workPart.Bodies) { by.Blank(); } if (this.seleInfo.Count != 0) { foreach (MoldQuote.Model.IDisplayObject mn in this.seleInfo) { mn.Highlight(false); } this.seleInfo.Clear(); } foreach (Node nd in tree.GetSelectedNodes()) { MoldQuote.Model.IDisplayObject mn = FindNameInfo(nd); if (mn != null) { this.seleInfo.Add(mn); mn.Highlight(true); } } }
//------------------------------------------------------------------------------ //Callback Name: apply_cb //------------------------------------------------------------------------------ public int apply_cb() { int errorCode = 0; try { //---- Enter your callback code here ----- List <string> newFileName = new List <string>(); if (file.Path == "") { theUI.NXMessageBox.Show("错误", NXMessageBox.DialogType.Error, "请指定文件位置"); return(1); } foreach (Node node in treeElectrode.GetSelectedNodes()) { ElectrodeModel model = assemble.Electrodes.Find(a => node.Equals(a.Node)); if (model != null) { ExportFile path = new ExportFile(model); string temp = path.NewFile(file.Path); newFileName.Add(temp); model.PartTag.Close(BasePart.CloseWholeTree.False, BasePart.CloseModified.CloseModified, null); Part newPart = PartUtils.OpenPartFile(temp); PartUtils.SetPartDisplay(newPart); if (this.toggleShops.Value && IsPartProgram(newPart)) { PartPost elePost = new PartPost(newPart); List <NCGroup> groups = elePost.GetGroup(); CreatePostExcel excel = new CreatePostExcel(groups, newPart); excel.CreateExcel(); string[] name = elePost.GetElectrodePostName(groups); foreach (string str in name) { elePost.Post(str, groups.ToArray()); } } newPart.Save(BasePart.SaveComponents.True, BasePart.CloseAfterSave.False); } } foreach (Part part in theSession.Parts)//关闭其他 { string type = AttributeUtils.GetAttrForString(part, "PartType"); if (!type.Equals("Electrode", StringComparison.CurrentCultureIgnoreCase)) { part.Close(BasePart.CloseWholeTree.False, BasePart.CloseModified.CloseModified, null); } } } catch (Exception ex) { //---- Enter your exception handling code here ----- errorCode = 1; theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString()); } return(errorCode); }