private void OK_Click(object sender, EventArgs e) { try { if (Variables.SelDimensionAry.Length != 0) { int value; if (DiCount.Text == "" || !int.TryParse(DiCount.Text, out value)) { MessageBox.Show("尺寸數量不正確,請指定正整數"); return; } foreach (KeyValuePair <NXObject, string> kvp in Variables.DicSelDimension) { //改變標註尺寸顏色 CaxME.SetDimensionColor(kvp.Key, 186); //塞屬性 kvp.Key.SetAttribute(CaxME.DimenAttr.FixDimension, "1"); kvp.Key.SetAttribute(CaxME.DimenAttr.DiCount, DiCount.Text); } DiCount.Text = "1"; } if (Variables.CleanDimensionAry.Length != 0) { NXObject[] SheetObj = CaxME.FindObjectsInView(Variables.drawingSheet1.View.Tag).ToArray(); foreach (NXObject i in Variables.CleanDimensionAry) { //恢復原始顏色 CaxME.SetDimensionColor(i, 125); //取得泡泡資訊 string BallonNum = ""; try { BallonNum = i.GetStringAttribute(CaxME.DimenAttr.BallonNum); } catch (System.Exception ex) { BallonNum = ""; } if (BallonNum != "") { CaxME.DeleteFixBallon(BallonNum, SheetObj); } i.DeleteAllAttributesByType(NXObject.AttributeType.String); } } MessageBox.Show("設定完成!"); } catch (System.Exception ex) { MessageBox.Show("執行失敗,請聯繫開發工程師"); this.Close(); return; } }
private bool JudgmentBalloon(GridRow row) { string oldBalloon = ""; try { oldBalloon = ((NXObject)row.Cells["Dimension"].Value).GetStringAttribute(CaxME.DimenAttr.BallonNum); if (oldBalloon == row.Cells["自定泡泡號"].Value.ToString()) { return(false); } NXOpen.Drawings.DrawingSheet drawingSheet1 = (NXOpen.Drawings.DrawingSheet)workPart.DrawingSheets.FindObject(row.Cells["尺寸位置"].Value.ToString()); NXObject[] SheetObj = CaxME.FindObjectsInView(drawingSheet1.View.Tag).ToArray(); CaxME.DeleteFixBallon(oldBalloon, SheetObj); workPart.Views.Refresh(); } catch (System.Exception ex) { oldBalloon = ""; } return(true); }