public form1(NXOpen.Annotations.Dimension fengbihuan,NXOpen.Annotations.Dimension[] zeng,NXOpen.Annotations.Dimension[] jian) { InitializeComponent(); fengbi = fengbihuan; zenghuan = zeng; jianhuan = jian; }
public form1(NXOpen.Annotations.Dimension[] zeng, NXOpen.Annotations.Dimension[] jian,NXOpen.Annotations.Dimension fengbihuan,string up,string down) { InitializeComponent(); zenghuan = zeng; jianhuan = jian; inup = up; indown = down; fengbi = fengbihuan; }
public form1(NXOpen.Annotations.Dimension[] zeng, NXOpen.Annotations.Dimension[] jian, NXOpen.Annotations.Dimension fengbihuan, double up, double down) { InitializeComponent(); zenghuan = zeng; jianhuan = jian; inupdou = up; indowndou = down; fengbi = fengbihuan; }
public void drawfengbi(NXOpen.Annotations.Dimension fengbi) { double[] fengbiinfo = null; fengbiinfo = thepubfun.getspec(fengbi); q = Convert.ToInt32((fengbiinfo[0] + 100)); System.Drawing.Point pt1 = new System.Drawing.Point(100,50); System.Drawing.Point pt2 = new System.Drawing.Point(q,50); Graphics drawfb = panel1.CreateGraphics(); drawfb.DrawLine(thepen, pt1, pt2); drawduanxian(pt1,pt2); }
//这个函数是进行尺寸链校核计算的主方法 public bool countcircle(NXOpen.Annotations.Dimension[] zeng, NXOpen.Annotations.Dimension[] jian, out double a, out double b) { double zengmax = 0;//所有增环的最大尺寸之和 double zengmin = 0;//所有增环的最小尺寸之和 double jianmax = 0;//所有减环的最大尺寸之和 double jianmin = 0;//所有减环的最小尺寸之和 double clsmax = 0;//封闭环最大尺寸 double clsmin = 0;//封闭环最小尺寸 a = 0;//最大上公差 b = 0;//最小下公差 double aclsmax = 0;//所有 增环最大尺寸减去所有减环最小极限尺寸 double aclsmin = 0;//所有增环最小尺寸减去所有减环最大尺寸 foreach (NXOpen.Annotations.Dimension zenghuan in zeng) { zengmax = getspec(zenghuan)[0] + getspec(zenghuan)[1] + zengmax; zengmin = getspec(zenghuan)[0] + getspec(zenghuan)[2] + zengmin; } foreach (NXOpen.Annotations.Dimension jianhuan in jian) { jianmax = getspec(jianhuan)[0] + getspec(jianhuan)[1] + jianmax; jianmin = getspec(jianhuan)[0] + getspec(jianhuan)[2] + jianmin; } //clsmax = getspec(fengbi)[0] + getspec(fengbi)[1]; //clsmin = getspec(fengbi)[0] + getspec(fengbi)[2]; aclsmax = zengmax - jianmin; aclsmin = zengmin - jianmax; a = aclsmax; b = aclsmin; //a = aclsmax - getspec(fengbi)[0]; //a = aclsmax - getspec(fengbi)[0]; //b = getspec(fengbi)[0] - aclsmin; //b = aclsmin - getspec(fengbi)[0]; //b = aclsmin - getspec(fengbi)[0]; //if (aclsmax >= clsmax && aclsmin <= clsmin) //{ // return true; //} //else //{ // return false; //} if (b <= 0) { return false; } else { return true; } }
public void drawzenghuan(NXOpen.Annotations.Dimension[] zenghuan) { double[] zenghuaninfo = null; int m = 100; System.Drawing.Point pt1 = new System.Drawing.Point(100, 50);//这是起始点,从这里开始画,对应于封闭环 System.Drawing.Point pt2 = new System.Drawing.Point(); foreach (NXOpen.Annotations.Dimension dim in zenghuan) { zenghuaninfo = thepubfun.getspec(dim); pt2 = new System.Drawing.Point(Convert.ToInt32((zenghuaninfo[0] + m)), 50); Graphics drawfb = panel1.CreateGraphics(); drawfb.DrawLine(thepen, pt1, pt2); drawduanxian(pt1, pt2); m = Convert.ToInt32((zenghuaninfo[0] + m)); pt1 = pt2; } }
//返回一个尺寸的名义值和上下公差,第一个值是名义值,第二个是上公差,第三个是下公差 public double[] getspec(NXOpen.Annotations.Dimension dim) { string[] a; string[] b; double maindim = 0; double low = 0; double up = 0; double[] final = { 0, 0, 0 }; dim.GetDimensionText(out a, out b); maindim = double.Parse(a[0]); up = dim.UpperMetricToleranceValue; low = dim.LowerMetricToleranceValue; final[0] = maindim; final[1] = up; final[2] = low; return final; }
public static double GetDimensionValue(NXOpen.Annotations.Dimension dimension) { try { string[] mainTextLines; string[] dualTextLines; dimension.GetDimensionText(out mainTextLines, out dualTextLines); if (mainTextLines.Length > 0) { //这里可能包含特殊字符,从中得到连续数字 string num = GetNumberFromString(mainTextLines[0]); return System.Convert.ToDouble(num); } else { return 0; } } catch/* (System.Exception ex)*/ { throw new Exception("读取尺寸值失败,请手动指定尺寸值"); } }
//这个函数是进行尺寸链校核计算的主方法 public bool countcircle(NXOpen.Annotations.Dimension fengbi,NXOpen.Annotations.Dimension[] zeng, NXOpen.Annotations.Dimension[] jian, out double a, out double b) { double zengmax = 0;//所有增环的最大尺寸之和 double zengmin = 0;//所有增环的最小尺寸之和 double jianmax = 0;//所有减环的最大尺寸之和 double jianmin = 0;//所有减环的最小尺寸之和 double clsmax = 0;//封闭环最大尺寸 double clsmin = 0;//封闭环最小尺寸 a = 0;//最大上公差 b = 0;//最小下公差 double aclsmax = 0;//所有 增环最大尺寸减去所有减环最小极限尺寸 double aclsmin = 0;//所有增环最小尺寸减去所有减环最大尺寸 foreach (NXOpen.Annotations.Dimension zenghuan in zeng) { zengmax = getspec(zenghuan)[0] + getspec(zenghuan)[1] + zengmax; zengmin = getspec(zenghuan)[0] + getspec(zenghuan)[2] + zengmin; } foreach (NXOpen.Annotations.Dimension jianhuan in jian) { jianmax = getspec(jianhuan)[0] + getspec(jianhuan)[1] + jianmax; jianmin = getspec(jianhuan)[0] + getspec(jianhuan)[2] + jianmin; } clsmax = getspec(fengbi)[0] + getspec(fengbi)[1]; clsmin = getspec(fengbi)[0] + getspec(fengbi)[2]; aclsmax = zengmax - jianmin; aclsmin = zengmin - jianmax; decimal aa = Convert.ToDecimal(aclsmax) - Convert.ToDecimal(getspec(fengbi)[0]); decimal bb = Convert.ToDecimal(aclsmin) - Convert.ToDecimal(getspec(fengbi)[0]); a = Convert.ToDouble(aa); b = Convert.ToDouble(bb); if (aclsmax <= clsmax && aclsmin >= clsmin) { return true; } else { return false; } //double num = 0.0; //double num2 = 0.0; //double num3 = 0.0; //double num4 = 0.0; //double num5 = 0.0; //double num6 = 0.0; //a = 0.0; //b = 0.0; //double num7 = 0.0; //double num8 = 0.0; //foreach (NXOpen.Annotations.Dimension dimension in zeng) //{ // num = (this.getspec(dimension)[0] + this.getspec(dimension)[1]) + num; // num2 = (this.getspec(dimension)[0] + this.getspec(dimension)[2]) + num2; //} //foreach (NXOpen.Annotations.Dimension dimension2 in jian) //{ // num3 = (this.getspec(dimension2)[0] + this.getspec(dimension2)[1]) + num3; // num4 = (this.getspec(dimension2)[0] + this.getspec(dimension2)[2]) + num4; //} //num5 = this.getspec(fengbi)[0] + this.getspec(fengbi)[1]; //num6 = this.getspec(fengbi)[0] + this.getspec(fengbi)[2]; //num7 = num - num4; //num8 = num2 - num3; //decimal num9 = Convert.ToDecimal(num7) - Convert.ToDecimal(this.getspec(fengbi)[0]); //decimal num10 = Convert.ToDecimal(num8) - Convert.ToDecimal(this.getspec(fengbi)[0]); //a = Convert.ToDouble(num9); //b = Convert.ToDouble(num10); //return ((num7 >= num5) && (num8 <= num6)); }
//------------------------------------------------------------------------------ //Callback Name: filter_cb //------------------------------------------------------------------------------ public int filter_cb(NXOpen.BlockStyler.UIBlock block, NXOpen.TaggedObject selectedObject) { if (block == selection0) { try { NXOpen.Annotations.Dimension d = (NXOpen.Annotations.Dimension)selectedObject; } catch { return (NXOpen.UF.UFConstants.UF_UI_SEL_REJECT); } } return (NXOpen.UF.UFConstants.UF_UI_SEL_ACCEPT); }
public int update_cb(NXOpen.BlockStyler.UIBlock block) { try { if (block == selection0) { //��ѯ���� FindTol(); } else if (block == enum0) { FindTol(); } else if (block == doubleup) { } else if (block == doubledown) { } else if (block == double0) { //�ֶ�����ʱ���Զ���ѯ���� double dim = double0.GetProperties().GetDouble("Value"); FindTol(dim); } else if (block == enum01) { string table = enum01.GetProperties().GetEnumAsString("Value"); if (table == "��1") { label0.GetProperties().SetLogical("Show", true); label01.GetProperties().SetLogical("Show", false); } else if (table == "��4") { label0.GetProperties().SetLogical("Show", false); label01.GetProperties().SetLogical("Show", true); } } else if (block == label0) { } else if (block == label01) { } else if (block == list_box0) { } } catch (Exception ex) { theUI.NXMessageBox.Show("��ʾ", NXMessageBox.DialogType.Error, ex.ToString()); } return 0; }
//------------------------------------------------------------------------------ //Callback Name: keyboardFocusNotify_cb //------------------------------------------------------------------------------ public void keyboardFocusNotify_cb(NXOpen.BlockStyler.UIBlock block, bool focus) { try { } catch (Exception ex) { theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString()); } }
//这个drawdim是用来在多工序间进行校核的时候 public void drawdim(double inupdou, double indowndou,NXOpen.Annotations.Dimension fengbi, System.Drawing.Point pt1, System.Drawing.Point pt2) { Graphics drawstr = panel1.CreateGraphics(); double[] fengbiinfo = null; fengbiinfo = thepubfun.getspec(fengbi); decimal fengbiinfo1 = 0; decimal fengbiinfo2 = 0; fengbiinfo1 =Convert.ToDecimal(inupdou) - Convert.ToDecimal( fengbiinfo[0]); fengbiinfo2 =Convert.ToDecimal( indowndou) - Convert.ToDecimal(fengbiinfo[0]); //fengbiinfo[1] = fengbiinfo1; //fengbiinfo[2] = fengbiinfo2; System.Drawing.Point strpoint = new System.Drawing.Point(); strpoint.X = Convert.ToInt32((pt1.X + pt2.X) / 2.2); strpoint.Y = (pt1.Y - 20); drawstr.DrawString(fengbiinfo[0].ToString(), new Font("Verdana", 10), new SolidBrush(Color.Black), strpoint); System.Drawing.Point upstrpoint = new System.Drawing.Point(); upstrpoint.X = strpoint.X + 25; upstrpoint.Y = strpoint.Y; drawstr.DrawString(fengbiinfo1.ToString() , new Font("Verdana", 5), new SolidBrush(Color.Black), upstrpoint); System.Drawing.Point downstrpoint = new System.Drawing.Point(); downstrpoint.X = strpoint.X + 22; downstrpoint.Y = strpoint.Y + 10; drawstr.DrawString(fengbiinfo2.ToString(), new Font("Verdana", 5), new SolidBrush(Color.Black), downstrpoint); }
//这个方法用来设定一个尺寸的上下公差 public void settoldown(NXOpen.Annotations.Dimension dim, double down) { //dim.UpperMetricToleranceValue = up; dim.LowerMetricToleranceValue = down; }
public static void GetTolerance(NXOpen.Annotations.Dimension dim, out double up, out double low) { //目前未考虑精度 try { up = 0; low = 0; Object tol = ReflectFun(dim, "GetTolerance"); NXOpen.Annotations.LinearTolerance lint = (NXOpen.Annotations.LinearTolerance)tol; NXOpen.Annotations.ToleranceType oldtype = lint.ToleranceType; // ReflectSetProperty(tol, "ToleranceType", NXOpen.Annotations.ToleranceType.BilateralTwoLines); //ReflectFun(dim, "SetTolerance", tol); Type type = tol.GetType(); NXOpen.Annotations.Value v_up = new NXOpen.Annotations.Value(); NXOpen.Annotations.Value v_low = new NXOpen.Annotations.Value(); if (type.Name == "LinearTolerance") { if (lint.ToleranceType == NXOpen.Annotations.ToleranceType.BilateralOneLine) { //v_low = (NXOpen.Annotations.Value)ReflectFun(tol, "GetLowerToleranceMm"); v_up = (NXOpen.Annotations.Value)ReflectFun(tol, "GetUpperToleranceMm"); v_low = v_up; up = v_up.ItemValue; low = v_low.ItemValue*(-1); } else if (lint.ToleranceType == NXOpen.Annotations.ToleranceType.UnilateralBelow) { up = 0; v_low = (NXOpen.Annotations.Value)ReflectFun(tol, "GetLowerToleranceMm"); low = v_low.ItemValue; } else if(lint.ToleranceType == NXOpen.Annotations.ToleranceType.UnilateralAbove) { low = 0; v_up = (NXOpen.Annotations.Value)ReflectFun(tol, "GetUpperToleranceMm"); up = v_up.ItemValue; } else if (lint.ToleranceType == NXOpen.Annotations.ToleranceType.BilateralTwoLines) { v_low = (NXOpen.Annotations.Value)ReflectFun(tol, "GetLowerToleranceMm"); v_up = (NXOpen.Annotations.Value)ReflectFun(tol, "GetUpperToleranceMm"); up = v_up.ItemValue; low = v_low.ItemValue; } } else { v_low = (NXOpen.Annotations.Value)ReflectFun(tol, "GetLowerToleranceDegrees"); v_up = (NXOpen.Annotations.Value)ReflectFun(tol, "GetUpperToleranceDegrees"); } ReflectSetProperty(tol, "ToleranceType", oldtype); ReflectFun(dim, "SetTolerance", tol); } catch (System.Exception ex) { UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Warning, ex.Message); up = 0; low = 0; } }
//返回一个尺寸的名义值和上下公差,第一个值是名义值,第二个是上公差,第三个是下公差 public double[] getspec(NXOpen.Annotations.Dimension dim) { string[] a; string[] b; double maindim = 0; double low = 0; double up = 0; double[] final = { 0, 0, 0 }; maindim = GetDimensionValue(dim); GetTolerance(dim,out up,out low); final[0] = maindim; final[1] = up; final[2] = low; return final; }
//------------------------------------------------------------------------------ //Callback Name: update_cb //------------------------------------------------------------------------------ public int update_cb( NXOpen.BlockStyler.UIBlock block) { try { if(block == face_select0) { //---------Enter your code here----------- } else if(block == toggle0) { //---------Enter your code here----------- } else if(block == colorPicker0) { //---------Enter your code here----------- } } catch (Exception ex) { //---- Enter your exception handling code here ----- theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString()); } return 0; }
public void SurfaceFinishFunction(string a, string d, object StandardType, object FinishType, Point3d point1, Face obj, NXOpen.Point point,Point testpoint) { //生成粗糙度符号 NXOpen.Annotations.SurfaceFinish nullAnnotations_SurfaceFinish = null; NXOpen.Annotations.SurfaceFinishBuilder surfaceFinishBuilder1; surfaceFinishBuilder1 = workPart.PmiManager.PmiAttributes.CreateSurfaceFinishBuilder(nullAnnotations_SurfaceFinish); surfaceFinishBuilder1.Origin.Anchor = NXOpen.Annotations.OriginBuilder.AlignmentPosition.MidCenter; surfaceFinishBuilder1.Origin.Plane.PlaneMethod = NXOpen.Annotations.PlaneBuilder.PlaneMethodType.ModelView; surfaceFinishBuilder1.Origin.Plane.PlaneMethod = NXOpen.Annotations.PlaneBuilder.PlaneMethodType.ModelView; surfaceFinishBuilder1.Origin.SetInferRelativeToGeometry(true); surfaceFinishBuilder1.Origin.SetInferRelativeToGeometry(true); NXOpen.Annotations.LeaderData leaderData1; leaderData1 = workPart.Annotations.CreateLeaderData(); leaderData1.Arrowhead = NXOpen.Annotations.LeaderData.ArrowheadType.FilledArrow; surfaceFinishBuilder1.Leader.Leaders.Append(leaderData1); leaderData1.StubSide = NXOpen.Annotations.LeaderSide.Inferred; surfaceFinishBuilder1.Title = "Surface Finish"; surfaceFinishBuilder1.A1 = a;// "Ra 0.025";//粗糙度 surfaceFinishBuilder1.F1 = ""; surfaceFinishBuilder1.Angle = 0.0; surfaceFinishBuilder1.D = d;// "=";//放置符号 surfaceFinishBuilder1.Standard = (NXOpen.Annotations.SurfaceFinishBuilder.StandardType)StandardType;//.Iso;//标准 surfaceFinishBuilder1.Finish = (NXOpen.Annotations.SurfaceFinishBuilder.FinishType)FinishType;//.MaterialRemovalRequired;//材料移除 surfaceFinishBuilder1.Origin.SetInferRelativeToGeometry(true); surfaceFinishBuilder1.Origin.SetInferRelativeToGeometry(true); NXOpen.Annotations.Annotation.AssociativeOriginData assocOrigin1; assocOrigin1.OriginType = NXOpen.Annotations.AssociativeOriginType.Drag; NXOpen.View nullView = null; assocOrigin1.View = nullView; assocOrigin1.ViewOfGeometry = nullView; NXOpen.Point nullPoint = testpoint; assocOrigin1.PointOnGeometry = nullPoint; assocOrigin1.VertAnnotation = null; assocOrigin1.VertAlignmentPosition = NXOpen.Annotations.AlignmentPosition.TopLeft; assocOrigin1.HorizAnnotation = null; assocOrigin1.HorizAlignmentPosition = NXOpen.Annotations.AlignmentPosition.TopLeft; assocOrigin1.AlignedAnnotation = null; assocOrigin1.DimensionLine = 0; assocOrigin1.AssociatedView = nullView; assocOrigin1.AssociatedPoint = nullPoint; assocOrigin1.OffsetAnnotation = null; assocOrigin1.OffsetAlignmentPosition = NXOpen.Annotations.AlignmentPosition.TopLeft; assocOrigin1.XOffsetFactor = 0.0; assocOrigin1.YOffsetFactor = 0.0; assocOrigin1.StackAlignmentPosition = NXOpen.Annotations.StackAlignmentPosition.Above; surfaceFinishBuilder1.Origin.SetAssociativeOrigin(assocOrigin1); //Point p=null; //try //{ // p.SetCoordinates(point1); //} //catch (Exception ex) //{ // UI.GetUI().NXMessageBox.Show("error",NXMessageBox.DialogType.Error,ex.ToString()); //} surfaceFinishBuilder1.Origin.Origin.SetValue(null, nullView, point1); if (point!=null) { Point3d point2 = point.Coordinates;//折线点 leaderData1.Leader.SetValue(point, workPart.ModelingViews.WorkView, point2);//折线 } surfaceFinishBuilder1.Origin.SetInferRelativeToGeometry(true); bool added1; added1 = surfaceFinishBuilder1.AssociatedObjects.Objects.Add(obj);//关联对象 NXObject nXObject1; nXObject1 = surfaceFinishBuilder1.Commit(); surfaceFinishBuilder1.Destroy(); }
//返回一个尺寸的名义值和上下公差,第一个值是名义值,第二个是上公差,第三个是下公差 public string[] getspec(NXOpen.Annotations.Dimension dim) { string[] a; string[] b; string maindim = null; double low = 0; double up = 0; string[] final = {"","",""}; maindim = GetDimensionValue(dim); GetTolerance(dim, out up, out low); final[0] = maindim; final[1] = up.ToString(); final[2] = low.ToString(); return final; }
public void drawjianhuan(NXOpen.Annotations.Dimension[] jianhuan) { double[] jianhuaninfo = null; int m = 0; System.Drawing.Point pt1 = new System.Drawing.Point(q, 50);//这是起始点,从这里开始画,对应于封闭环 System.Drawing.Point pt2 = new System.Drawing.Point(); foreach (NXOpen.Annotations.Dimension dim in jianhuan) { jianhuaninfo = thepubfun.getspec(dim); //pt2 = new System.Drawing.Point(Convert.ToInt32((jianhuaninfo[0] + q)) + m, 50); pt2.Y = pt1.Y; pt2.X = pt1.X + Convert.ToInt32(jianhuaninfo[0]); Graphics drawfb = panel1.CreateGraphics(); drawfb.DrawLine(new Pen(Color.Red,2), pt1, pt2); drawduanxian(pt1, pt2); m = Convert.ToInt32((jianhuaninfo[0] + q)) + m; drawdim(dim, pt1, pt2); pt1 = pt2; } }
public void SetDimensionTolerance(NXOpen.Annotations.Dimension dimension, double upper, double lower) { Session theSession = Session.GetSession(); Part workPart = theSession.Parts.Work; Part displayPart = theSession.Parts.Display; NXOpen.Session.UndoMarkId markId1; markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start"); NXOpen.Annotations.Value lowerToleranceMm1; lowerToleranceMm1.ItemValue = lower; Expression nullExpression = null; lowerToleranceMm1.ValueExpression = nullExpression; lowerToleranceMm1.ValuePrecision = 3; NXOpen.Annotations.Value upperToleranceMm1; upperToleranceMm1.ItemValue = upper; upperToleranceMm1.ValueExpression = nullExpression; upperToleranceMm1.ValuePrecision = 3; Object tol = ReflectFun(dimension, "GetTolerance"); Type type = tol.GetType(); if (type.Name == "LinearTolerance") { ReflectFun(tol, "SetLowerToleranceMm", lowerToleranceMm1); ReflectFun(tol, "SetUpperToleranceMm", upperToleranceMm1); } else { ReflectFun(tol, "SetLowerToleranceDegrees", lowerToleranceMm1); ReflectFun(tol, "SetUpperToleranceDegrees", upperToleranceMm1); } //设置公差类型 if (upper + lower == 0) { ReflectSetProperty(tol, "ToleranceType", NXOpen.Annotations.ToleranceType.BilateralOneLine); } else if (lower == 0) { ReflectSetProperty(tol, "ToleranceType", NXOpen.Annotations.ToleranceType.UnilateralAbove); } else if (upper == 0) { ReflectSetProperty(tol, "ToleranceType", NXOpen.Annotations.ToleranceType.UnilateralBelow); } else { ReflectSetProperty(tol, "ToleranceType", NXOpen.Annotations.ToleranceType.BilateralTwoLines); } ReflectFun(dimension, "SetTolerance", tol); //设置公差的显示大小 NXOpen.Annotations.LetteringPreferences letteringPreferences1; letteringPreferences1 = dimension.GetLetteringPreferences(); NXOpen.Annotations.Lettering toleranceText1 = letteringPreferences1.GetDimensionText(); if (upper + lower != 0) toleranceText1.Size = 0.57 * toleranceText1.Size; letteringPreferences1.SetToleranceText(toleranceText1); dimension.SetLetteringPreferences(letteringPreferences1); int nErrs2 = theSession.UpdateManager.DoUpdate(markId1); }
//------------------------------------------------------------------------------ //Callback Name: update_cb //------------------------------------------------------------------------------ public int update_cb(NXOpen.BlockStyler.UIBlock block) { try { if (block == bodySelect0) { } else if (block == super_section0) { } else if (block == axis0) { } else if (block == toggle0) { } else if (block == toggle01) { } else if (block == button01) { // if (!isShowResult) // { // //markid = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Test"); // //��תĸ�� // TaggedObject[] obs1 = super_section0.GetProperties().GetTaggedObjectVector("SelectedObjects"); // if (obs1.GetLength(0) == 0) // { // // theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Warning, "��ѡ���תĸ�ߣ�"); // return 1; // } // //��ת�� // TaggedObject[] obs2 = axis0.GetProperties().GetTaggedObjectVector("SelectedObjects"); // if (obs2.GetLength(0) == 0) // { // // theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Warning, "��ѡ���ת�ᣡ"); // return 1; // } // //Ҫ����� // TaggedObject[] obs3 = bodySelect0.GetProperties().GetTaggedObjectVector("SelectedObjects"); // if (obs3.GetLength(0) == 0) // { // // theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Warning, "��ѡ��Ŀ���壡"); // return 1; // } // Section section = (Section)obs1[0]; // Axis axis = (Axis)obs2[0]; // Body body = (Body)obs3[0]; // /*NXOpen.Features.Revolve */revolve = NXFun.Revolve(section, axis); //// Body[] bodys = revolve.GetBodies(); //// //// //���� //// NXFun.TrimBody(body, bodys[0]); // isShowResult = true; // int nErrs = theSession.UpdateManager.DoUpdate(markid); // } // else // { // //theSession.UndoToMark(markid, "TEST"); // NXFun.DeleteObject(revolve); // } } else if (block == list_box0) { } } catch (Exception ex) { theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString()); } return 0; }
//这个方法用来设定一个尺寸的上下公差 public void settolup(NXOpen.Annotations.Dimension dim, double up) { //dim.LowerMetricToleranceValue = up; dim.UpperMetricToleranceValue = up; }
//------------------------------------------------------------------------------ //Callback Name: keyboardFocusNotify_cb //This callback is executed when block which can receive keyboard entry, receives the focus. //------------------------------------------------------------------------------ public void keyboardFocusNotify_cb(NXOpen.BlockStyler.UIBlock block, bool focus) { try { //---- Enter your callback code here ----- } catch (Exception ex) { //---- Enter your exception handling code here ----- theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString()); } }
//------------------------------------------------------------------------------ //Callback Name: filter_cb //------------------------------------------------------------------------------ public int filter_cb(NXOpen.BlockStyler.UIBlock block, NXOpen.TaggedObject selectedObject) { return(NXOpen.UF.UFConstants.UF_UI_SEL_ACCEPT); }
//------------------------------------------------------------------------------ //Callback Name: update_cb //------------------------------------------------------------------------------ public int update_cb( NXOpen.BlockStyler.UIBlock block) { try { if(block == enum0) { //---------Enter your code here----------- } else if(block == newviewname) { //---------Enter your code here----------- } else if(block == ifcro) { //---------Enter your code here----------- } else if(block == cro) { //---------Enter your code here----------- } else if(block == realanno) { //---------Enter your code here----------- } else if(block == iflabel) { //---------Enter your code here----------- } else if(block == selection01) { //---------Enter your code here----------- } else if(block == point0) { //---------Enter your code here----------- } else if(block == dic) { //---------Enter your code here----------- } else if(block == str) { //---------Enter your code here----------- } else if(block == button0) { //---------Enter your code here----------- } } catch (Exception ex) { //---- Enter your exception handling code here ----- theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString()); } return 0; }
//------------------------------------------------------------------------------ //Callback Name: update_cb //------------------------------------------------------------------------------ public int update_cb( NXOpen.BlockStyler.UIBlock block) { try { if(block == enum0) { string type = enum0.GetProperties().GetEnumAsString("Value"); if (type == "A3") { list_box0.GetProperties().SetStrings("ListItems", stringA3); } else if(type == "A4") { list_box0.GetProperties().SetStrings("ListItems", stringA4); } else if(type == "����") { list_box0.GetProperties().SetStrings("ListItems", stringOther); } } else if(block == list_box0) { } else if(block == label0) { } else if(block == list_box02) { } else if(block == string0) { } else if(block == list_box01) { } } catch (Exception ex) { theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString()); } return 0; }
//这个是正常的画线函数 public void drawdim(NXOpen.Annotations.Dimension dim, System.Drawing.Point pt1, System.Drawing.Point pt2) { Graphics drawstr = panel1.CreateGraphics(); double[] info = thepubfun.getspec(dim); System.Drawing.Point strpoint = new System.Drawing.Point(); strpoint.X = Convert.ToInt32((pt1.X + pt2.X) / 2.2); strpoint.Y = (pt1.Y - 20); drawstr.DrawString(info[0].ToString(), new Font("Verdana", 10), new SolidBrush(Color.Black), strpoint); System.Drawing.Point upstrpoint = new System.Drawing.Point(); upstrpoint.X = strpoint.X + 25; upstrpoint.Y = strpoint.Y; drawstr.DrawString(info[1].ToString(), new Font("Verdana", 5), new SolidBrush(Color.Black), upstrpoint); System.Drawing.Point downstrpoint = new System.Drawing.Point(); downstrpoint.X = strpoint.X + 22; downstrpoint.Y = strpoint.Y + 10; drawstr.DrawString(info[2].ToString(), new Font("Verdana", 5), new SolidBrush(Color.Black), downstrpoint); }