//计时器,多线程执行全选宏操作 private void timer1_Tick(object sender, EventArgs e) { try { if (((Timer)sender).Tag.ToString() == "全选") { timer1.Stop(); ObjectsInView = NXFun.GetSelectObjects(); NXFun.RemoveAllSelect(); timer1.Interval = 1000; timer1.Tag = "取消全选"; timer1.Start(); } else if (((Timer)sender).Tag.ToString() == "取消全选") { timer1.Stop(); //遍历尺寸 List <NXOpen.Annotations.Dimension> dims = NXFun.GetDimensionInCurrentView(ObjectsInView); List <NXOpen.Annotations.BaseFcf> fcfs = NXFun.GetBaseFcfInCurrentView(ObjectsInView); LabelDimMap.Clear(); foreach (NXOpen.Annotations.Dimension dim in dims) { DimInfor diminfor = NXFun.GetDimInfor(dim); //存入Dictionary LabelDimMap.Add(diminfor.id, diminfor); } LabelFcfMap.Clear(); foreach (NXOpen.Annotations.BaseFcf fcf in fcfs) { DimInfor diminfor = NXFun.GetFcfInfor(fcf); LabelFcfMap.Add(diminfor.id, diminfor); } //转存到 LabelDimList LabelDimList.Clear(); foreach (int k in LabelDimMap.Keys) { foreach (DimInfor diminfor in LabelDimMap[k]) { LabelDimList.Add(diminfor); } } //转存到 LabelFcfList LabelFcfList.Clear(); foreach (int k in LabelFcfMap.Keys) { foreach (DimInfor diminfor in LabelFcfMap[k]) { LabelFcfList.Add(diminfor); } } //刷新显示 RefreshDisplay(); SetStatusLabel("查询结束!", 2); } } catch (System.Exception ex) { NXFun.MessageBox(ex.Message); } }
private void button_remove_Click(object sender, EventArgs e) { //得到选中 NXObject[] obs; NXFun.GetSelectObjects(out obs); Part workpart = theSession.Parts.Work; workpart.Views.WorkView.Fit(); foreach (NXOpen.Drawings.DraftingView draftingview in workpart.DraftingViews) { foreach (NXObject ob in obs) { try { //在所有视图中都尝试改变线型 if (NXFun.isFindInView(draftingview, ob)) { NXFun.SetViewCurveWidth(draftingview, (NXOpen.DisplayableObject)ob, NXOpen.ViewDependentDisplayManager.Width.Normal); } } catch/* (System.Exception ex)*/ { } } } NXFun.RemoveAllSelect(); }
private void button_add_Click(object sender, EventArgs e) { try { //得到选中 NXObject[] obs; NXFun.GetSelectObjects(out obs); Part workpart = theSession.Parts.Work; workpart.Views.WorkView.Fit(); foreach (NXOpen.Drawings.DraftingView draftingview in workpart.DraftingViews) { foreach (NXObject ob in obs) { try { //在视图中都尝试改变线型 if (NXFun.isFindInView(draftingview, ob)) { NXFun.SetViewCurveWidth(draftingview, (NXOpen.DisplayableObject)ob, NXOpen.ViewDependentDisplayManager.Width.Thick); } } catch/*(System.Exception ex)*/ { } } } NXFun.RemoveAllSelect(); } catch (Exception ex) { UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message); } }
private void timer1_Tick(object sender, EventArgs e) { try { //监控状态指示的小东东,嘻嘻 count = (++count) % 3; string star = "\\"; switch (count) { case 0: star = "-"; break; case 1: star = "\\"; break; case 2: star = "/"; break; } //得到选中的东东 NXObject[] nxobs; int num = NXFun.GetSelectObjects(out nxobs); label1.Text = star + " 请选择加工面 (" + System.Convert.ToString(num) + ")"; string[] obs = new string[num]; for (int i = 0; i < num; i++) { if (isShowFullType) { obs[i] = nxobs[i].GetType().FullName; } else { obs[i] = nxobs[i].ToString(); } } //检测有无改变 if (!NXFun.isArrayEqual(ob_list, obs)) { listBox1.Items.Clear(); foreach (string str in obs) { listBox1.Items.Add(str); } } ob_list = obs; } catch (System.Exception ex) { UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message); } }
private void button_read_Click(object sender, EventArgs e) { NXObject[] nxobs = NXFun.GetSelectObjects(); if (nxobs.Length == 0) { MessageBox.Show("没有在NX选中东东哦!"); } else //查询 { AttrList.Clear(); if ((Control.ModifierKeys & Keys.Control) == Keys.Control) { //得到sheet 做二维图表需要设置隐藏属性 NXOpen.Drawings.DrawingSheet[] ds = theSession.Parts.Work.DrawingSheets.ToArray(); if (ds.Length != 0) { obj = ds[0]; } else { obj = nxobs[0]; } } else { obj = nxobs[0]; } s_Attr s_attr; NXObject.AttributeInformation[] ais = obj.GetAttributeTitlesByType(NXObject.AttributeType.String); for (int i = 0; i < ais.Length; i++) { s_attr.title = ais[i].Title; s_attr.s_value = obj.GetStringAttribute(s_attr.title); s_attr.type = "string"; s_attr.i_value = 0; AttrList.Add(s_attr); } ais = obj.GetAttributeTitlesByType(NXObject.AttributeType.Integer); for (int i = 0; i < ais.Length; i++) { s_attr.title = ais[i].Title; s_attr.i_value = obj.GetIntegerAttribute(s_attr.title); s_attr.type = "int"; s_attr.s_value = ""; AttrList.Add(s_attr); } RefreshDisplay(); } }