//------------------------------------------------------------------------// // Convierte la entidad <Segment> de is2Graph a su tipo equivalente de ACAD. /// <summary> /// /// </summary> /// <param name="S"></param> /// <returns></returns> public static UFCurve.Line ToNx(is2GraphObject.SegmentType S) { UFCurve.Line L = new UFCurve.Line(); L.start_point = ToNx(S.StartPoint); L.end_point = ToNx(S.EndPoint); return(L); }
public Tag DrawLine(Point startPoint, Point endPoint) { UFCurve.Line line = new UFCurve.Line(); line.start_point = startPoint.ToArray(); line.end_point = endPoint.ToArray(); Tag sketchPart; theSession.Curve.CreateLine(ref line, out sketchPart); return(sketchPart); }
public static void SetPointsToLine(ref UFCurve.Line line, double[] l_endpt1, double[] l_endpt2) { line.start_point = new double[3]; line.start_point[0] = l_endpt1[0]; line.start_point[1] = l_endpt1[1]; line.start_point[2] = l_endpt1[2]; line.end_point = new double[3]; line.end_point[0] = l_endpt2[0]; line.end_point[1] = l_endpt2[1]; line.end_point[2] = l_endpt2[2]; }
public int Execute() { Tag UFPart; string part_name = "EX_Modl_CreateExtruded"; int units = 2; string name; theUfSession.Part.New(part_name, units, out UFPart); theUfSession.Part.AskPartName(UFPart, out name); w.WriteLine("Loaded: " + name); double[] l1_endpt1 = { -1.4476606170268, 2.3788333712953, 0.0 }; double[] l1_endpt2 = { 1.5471310496399, 2.2539419253757, 0.0 }; double[] l2_endpt1 = { -1.4476606170268, 1.2548103580189, 0.0 }; double[] l2_endpt2 = { 1.5471310496399, 1.3797018039385, 0.0 }; double[] l3_endpt1 = { -1.4710981170268, 1.8168218646571, 0.0 }; double[] l3_endpt2 = { 1.5289018829732, 1.8168218646571, 0.0 }; double[] direction = { 0.0, 0.0, 1.0 }; double[] ref_pt = new double[3]; double arc1_start_ang = (PI / 180) * 87.611984536731; double arc1_end_ang = (PI / 180) * 272.38801546327; double arc1_rad = 0.5625; double arc2_start_ang = (PI / 180) * 272.38801546327; double arc2_end_ang = (PI / 180) * 447.61198453673; double arc2_rad = 0.4375; string taper_angle = "0.0"; string[] limit1 = { "1.0", "1.25" }; int i, count = 4; Tag[] objarray = new Tag[5]; Tag wcs_tag, matrix_tag; Tag[] loop_list, features; UFCurve.Line line1 = new UFCurve.Line(); UFCurve.Line line2 = new UFCurve.Line(); UFCurve.Line line3 = new UFCurve.Line(); UFCurve.Arc arc1 = new UFCurve.Arc(); UFCurve.Arc arc2 = new UFCurve.Arc(); line1.start_point = new double[3]; line1.start_point[0] = l1_endpt1[0]; line1.start_point[1] = l1_endpt1[1]; line1.start_point[2] = l1_endpt1[2]; line1.end_point = new double[3]; line1.end_point[0] = l1_endpt2[0]; line1.end_point[1] = l1_endpt2[1]; line1.end_point[2] = l1_endpt2[2]; line2.start_point = new double[3]; line2.start_point[0] = l2_endpt1[0]; line2.start_point[1] = l2_endpt1[1]; line2.start_point[2] = l2_endpt1[2]; line2.end_point = new double[3]; line2.end_point[0] = l2_endpt2[0]; line2.end_point[1] = l2_endpt2[1]; line2.end_point[2] = l2_endpt2[2]; line3.start_point = new double[3]; line3.start_point[0] = l3_endpt1[0]; line3.start_point[1] = l3_endpt1[1]; line3.start_point[2] = l3_endpt1[2]; line3.end_point = new double[3]; line3.end_point[0] = l3_endpt2[0]; line3.end_point[1] = l3_endpt2[1]; line3.end_point[2] = l3_endpt2[2]; arc1.start_angle = arc1_start_ang; arc1.end_angle = arc1_end_ang; arc1.arc_center = new double[3]; arc1.arc_center[0] = l3_endpt1[0]; arc1.arc_center[1] = l3_endpt1[1]; arc1.arc_center[2] = l3_endpt1[2]; arc1.radius = arc1_rad; arc2.start_angle = arc2_start_ang; arc2.end_angle = arc2_end_ang; arc2.arc_center = new double[3]; arc2.arc_center[0] = l3_endpt2[0]; arc2.arc_center[1] = l3_endpt2[1]; arc2.arc_center[2] = l3_endpt2[2]; arc2.radius = arc2_rad; theUfSession.Curve.CreateLine(ref line1, out objarray[0]); theUfSession.Curve.CreateLine(ref line2, out objarray[1]); theUfSession.Curve.CreateLine(ref line3, out objarray[4]); theUfSession.Csys.AskWcs(out wcs_tag); theUfSession.Csys.AskMatrixOfObject(wcs_tag, out matrix_tag); arc1.matrix_tag = matrix_tag; arc2.matrix_tag = matrix_tag; theUfSession.Curve.CreateArc(ref arc1, out objarray[2]); theUfSession.Curve.CreateArc(ref arc2, out objarray[3]); //Create loop list ArrayList arr_loop_list = new ArrayList(); for (i = 0; i < count; i++) { arr_loop_list.Add(objarray[i]); } loop_list = (Tag [])arr_loop_list.ToArray(typeof(Tag)); // while sending parameters to this function the order was // loop_list, taper_angle, limit1, ref_pt, FeatureSigns.Nullsign, direction, out features // as above .. there were some compilation problem due to function prototype match. // Atul changed the order as follows in order to compile it successfully. // loop_list, taper_angle, limit1, ref_pt, direction, FeatureSigns.Nullsign, out features theUfSession.Modl.CreateExtruded(loop_list, taper_angle, limit1, ref_pt, direction, FeatureSigns.Nullsign, out features); theUfSession.Part.Save(); return(0); }
public int Execute() { Tag part; string part_name = "EX_Curve_CreateFillet"; int units = 2; string name; theUfSession.Part.New(part_name, units, out part); theUfSession.Part.AskPartName(part, out name); w.WriteLine("Loaded: " + name); double[] center = new double[3]; double radius; int[] trim_opts = new int[3]; int[] arc_opts = { 0, 0, 0 }; UFCurve.Line line_coords1 = new UFCurve.Line(); line_coords1.start_point = new double[3]; line_coords1.start_point[0] = 1.2; line_coords1.start_point[1] = 0.2; line_coords1.start_point[2] = 0.0; line_coords1.end_point = new double[3]; line_coords1.end_point[0] = -0.5; line_coords1.end_point[1] = 2.5; line_coords1.end_point[2] = 0.0; UFCurve.Line line_coords2 = new UFCurve.Line(); line_coords2.start_point = new double[3]; line_coords2.start_point[0] = 3.2; line_coords2.start_point[1] = 2.25; line_coords2.start_point[2] = 0.0; line_coords2.end_point = new double[3]; line_coords2.end_point[0] = 2.5; line_coords2.end_point[1] = 3.5; line_coords2.end_point[2] = 0.0; UFCurve.Arc arc_coords1 = new UFCurve.Arc(); arc_coords1.matrix_tag = Tag.Null; arc_coords1.start_angle = 238 * DEGRA; arc_coords1.end_angle = 357 * DEGRA; arc_coords1.arc_center = new double[3]; arc_coords1.arc_center[0] = 0.22; arc_coords1.arc_center[1] = 4.3; arc_coords1.arc_center[2] = 0.0; arc_coords1.radius = 2.0; UFCurve.Arc arc_coords2 = new UFCurve.Arc(); arc_coords2.matrix_tag = Tag.Null; arc_coords2.start_angle = 82 * DEGRA; arc_coords2.end_angle = 175 * DEGRA; arc_coords2.arc_center = new double[3]; arc_coords2.arc_center[0] = 3.0; arc_coords2.arc_center[1] = 0.43; arc_coords2.arc_center[2] = 0.0; arc_coords2.radius = 2.0; Tag line1, line2, arc1, arc2; Tag[] curve_objs = new Tag[3]; Tag fillet_obj1, fillet_obj2, wcs_tag, matrix_tag; /* create 2 lines */ theUfSession.Curve.CreateLine(ref line_coords1, out line1); theUfSession.Curve.CreateLine(ref line_coords2, out line2); /* create 2 arcs */ theUfSession.Csys.AskWcs(out wcs_tag); theUfSession.Csys.AskMatrixOfObject(wcs_tag, out matrix_tag); arc_coords1.matrix_tag = matrix_tag; arc_coords2.matrix_tag = matrix_tag; theUfSession.Curve.CreateArc(ref arc_coords1, out arc1); theUfSession.Curve.CreateArc(ref arc_coords2, out arc2); /*create fillet between "arc1" and "line1"*/ curve_objs[0] = arc1; curve_objs[1] = line1; center[0] = 0.0; center[1] = 2.1; center[2] = 0.0; radius = .25; trim_opts[0] = 1; /*trim first UFCurve*/ trim_opts[1] = 1; /*trim second UFCurve*/ theUfSession.Curve.CreateFillet(UF_CURVE_2_CURVE, curve_objs, center, radius, trim_opts, arc_opts, out fillet_obj1); /*create fillet between "line1" and "arc2"*/ curve_objs[0] = line1; curve_objs[1] = arc2; center[0] = 0.8; center[1] = 1.0; center[2] = 0.0; radius = .25; trim_opts[0] = 1; /*trim first UFCurve*/ trim_opts[1] = 1; /*trim second UFCurve*/ theUfSession.Curve.CreateFillet(UF_CURVE_2_CURVE, curve_objs, center, radius, trim_opts, arc_opts, out fillet_obj2); theUfSession.Part.Save(); return(0); }
private void createBolt(staple config) { List<NXOpen.Point> points = new List<Point>() { new NXOpen.Point(0, 0), new Point(0, config.D / 2 ), new Point(0, config.D / 2 ), new Point(config.l2, config.D / 2 ), new Point(config.l2, config.d1 / 2 ), new Point(config.L - config.l - config.l1, config.d / 2 ), // 4 new Point(config.L - config.l - config.l1, config.D / 2 ), new Point(config.L - config.l, config.D / 2), new Point(config.L - config.l, config.d / 2), new Point(config.L, config.d / 2), new Point(config.L, 0), new Point(0, 0) }; List<UFCurve.Line> lines = new List<UFCurve.Line>(); Tag[] objarray1 = new Tag[points.Count - 1]; for (int i = 1; i < points.Count; i++) { UFCurve.Line line = new UFCurve.Line(); line.start_point = new double[3] { points[i - 1].x, points[i - 1].y, points[i - 1].z }; line.end_point = new double[3] { points[i].x, points[i].y, points[i].z }; lines.Add(line); ufSession.Curve.CreateLine(ref line, out objarray1[i - 1]); Tag[] features1; ufSession.Modl.CreateRevolved(objarray1, new string[2] { "0", "360" }, new double[3] { 0.00, 0.00, 0.00 }, new double[3] { 1.00, 0.00, 0.00 }, FeatureSigns.Nullsign, out features1); ; Tag feat = features1[0]; Tag cyl_tag, obj_id_camf, blend1; Tag[] Edge_array_cyl, face_array; int ecount; ufSession.Modl.AskFeatBody(feat, out cyl_tag); ufSession.Modl.AskBodyEdges(cyl_tag, out Edge_array_cyl); ufSession.Modl.AskListCount(Edge_array_cyl, out ecount); ArrayList main_1_blend = new ArrayList(); ArrayList main_1_blend_sub = new ArrayList(); ArrayList main_2_blend = new ArrayList(); ArrayList main_2_blend_sub = new ArrayList(); ArrayList main_3_blend = new ArrayList(); for (int ii = 0; ii < ecount; ii++) Tag edge; ufSession.Modl.AskListItem(Edge_array_cyl, ii, out edge); if (ii == 0 || ii == 7) { main_1_blend.Add(edge); } if (ii == 1 || ii == 2) { main_1_blend_sub.Add(edge); } if (ii == 3 || ii == 4) { main_2_blend.Add(edge); } if (ii == 5) { main_2_blend_sub.Add(edge); } if (ii == 6) { main_3_blend.Add(edge); } } ufSession.Modl.CreateBlend((config.l2 / 2).ToString(), (Tag[])main_1_blend.ToArray(typeof(Tag)), 0, 0, 0, 0.0, out blend1); ufSession.Modl.CreateBlend((config.R2).ToString(), (Tag[])main_1_blend_sub.ToArray(typeof(Tag)), 0, 0, 0, 0.0, out blend1); ufSession.Modl.CreateBlend((config.R3).ToString(), (Tag[])main_2_blend.ToArray(typeof(Tag)), 0, 0, 0, 0.0, out blend1); ufSession.Modl.CreateBlend((config.R1).ToString(), (Tag[])main_2_blend_sub.ToArray(typeof(Tag)), 0, 0, 0, 0.0, out blend1); ufSession.Modl.CreateChamfer(3, "1", "1", "45", (Tag[])main_3_blend.ToArray(typeof(Tag)), out obj_id_camf); 101. }
public int Execute() { Tag UFPart; string part_name = "EX_Curve_ProjCurves"; int units = 2; string name; theUfSession.Part.New(part_name, units, out UFPart); theUfSession.Part.AskPartName(UFPart, out name); w.WriteLine("Loaded: " + name); int num_faces, i, num_proj_curves; double[] origin = { 0.0, 0.0, 0.0 }; Tag block_tag; Tag[] curves_to_proj = new Tag[1]; Tag proj_curve_feature; Tag[] proj_curves; Tag defining_feature, defining_target, defining_curve; String[] edge_lens = { "300.0", "25.0", "150.0" }; UFCurve.Line line_data = new UFCurve.Line(); UFCurve.Proj proj_data = new UFCurve.Proj(); Tag[] face_list; theUfSession.Modl.CreateBlock1(FeatureSigns.Nullsign, origin, edge_lens, out block_tag); line_data.start_point = new double[3]; line_data.start_point[0] = 25.0; line_data.start_point[1] = 50.0; line_data.start_point[2] = 25.0; line_data.end_point = new double[3]; line_data.end_point[0] = 275.0; line_data.end_point[1] = 50.0; line_data.end_point[2] = 125.0; theUfSession.Curve.CreateLine(ref line_data, out curves_to_proj[0]); Console.WriteLine("curves to project tag = {0}\n", curves_to_proj[0]); theUfSession.Modl.AskFeatFaces(block_tag, out face_list); theUfSession.Modl.AskListCount(face_list, out num_faces); proj_data.proj_type = 3; proj_data.proj_vec = new Double[3]; proj_data.proj_vec[0] = 0.0; proj_data.proj_vec[1] = 1.0; proj_data.proj_vec[2] = 0.0; proj_data.multiplicity = 2; theUfSession.Curve.CreateProjCurves(1, curves_to_proj, face_list.Length, face_list, 3, ref proj_data, out proj_curve_feature); w.WriteLine("proj UFCurve feature tag = {0}\n", proj_curve_feature); theUfSession.Curve.AskProjCurves(proj_curve_feature, out num_proj_curves, out proj_curves); for (i = 0; i < num_proj_curves; i++) { theUfSession.Curve.AskProjCurveParents(proj_curves[i], out defining_feature, out defining_target, out defining_curve); w.WriteLine("proj_curves[{0}]\n", i); w.WriteLine(" belongs to feature tag = {0}\n", defining_feature); w.WriteLine(" was projected onto tag = {0}\n", defining_target); w.WriteLine(" was generated by UFCurve tag = {0}\n", defining_curve); } theUfSession.Part.Save(); return(0); }
public static int Main(String[] args) { int retValue = 0; theForm = new Form(); theForm.Show(); Tag UFPart1; string name1 = "model_4k_1"; int units1 = 1; try { theUfSession = UFSession.GetUFSession(); //Session theUfSession = Session.GetSession(); theUfSession.Part.New(name1, units1, out UFPart1); double[] l1_endpt1 = { 0, 2.5, 0.00 }; double[] l1_endpt2 = { 200, 2.5, 0.00 }; double[] l2_endpt1 = { 200, 2.5, 0.00 }; double[] l2_endpt2 = { 200, 30.5, 0.00 }; double[] l3_endpt1 = { 200, 30.5, 0.00 }; double[] l3_endpt2 = { 0, 30.5, 0.00 }; double[] l4_endpt1 = { 0, 30.5, 0.00 }; double[] l4_endpt2 = { 0, 2.5, 0.00 }; UFCurve.Line line1 = new UFCurve.Line(); UFCurve.Line line2 = new UFCurve.Line(); UFCurve.Line line3 = new UFCurve.Line(); UFCurve.Line line4 = new UFCurve.Line(); line1.start_point = new double[3]; line1.start_point[0] = l1_endpt1[0]; line1.start_point[1] = l1_endpt1[1]; line1.start_point[2] = l1_endpt1[2]; line1.end_point = new double[3]; line1.end_point[0] = l1_endpt2[0]; line1.end_point[1] = l1_endpt2[1]; line1.end_point[2] = l1_endpt2[2]; line2.start_point = new double[3]; line2.start_point[0] = l2_endpt1[0]; line2.start_point[1] = l2_endpt1[1]; line2.start_point[2] = l2_endpt1[2]; line2.end_point = new double[3]; line2.end_point[0] = l2_endpt2[0]; line2.end_point[1] = l2_endpt2[1]; line2.end_point[2] = l2_endpt2[2]; line3.start_point = new double[3]; line3.start_point[0] = l3_endpt1[0]; line3.start_point[1] = l3_endpt1[1]; line3.start_point[2] = l3_endpt1[2]; line3.end_point = new double[3]; line3.end_point[0] = l3_endpt2[0]; line3.end_point[1] = l3_endpt2[1]; line3.end_point[2] = l3_endpt2[2]; line4.start_point = new double[3]; line4.start_point[0] = l4_endpt1[0]; line4.start_point[1] = l4_endpt1[1]; line4.start_point[2] = l4_endpt1[2]; line4.end_point = new double[3]; line4.end_point[0] = l4_endpt2[0]; line4.end_point[1] = l4_endpt2[1]; line4.end_point[2] = l4_endpt2[2]; Tag[] objarray1 = new Tag[7]; theUfSession.Curve.CreateLine(ref line1, out objarray1[0]); theUfSession.Curve.CreateLine(ref line2, out objarray1[1]); theUfSession.Curve.CreateLine(ref line3, out objarray1[2]); theUfSession.Curve.CreateLine(ref line4, out objarray1[3]); double[] ref_pt1 = new double[3]; ref_pt1[0] = 0.00; ref_pt1[1] = 0.00; ref_pt1[2] = 0.00; double[] direction1 = { 1.00, 0.00, 0.00 }; string[] limit1 = { "0", "360" }; Tag[] features1; theUfSession.Modl.CreateRevolved(objarray1, limit1, ref_pt1, direction1, FeatureSigns.Nullsign, out features1); //выдавливание double[] direction4 = { 0.0, 0.0, 1.0 }; //Переменная задающая значения направления выдавливания ось CZ double[] ref_pt4 = new double[3]; //Требуемая, но не используемая переменная string taper_angle4 = "0.0"; //Переменная, определяющая значение уклона при выдавливании string[] limit4 = { "-10", "3" }; int i4, count4 = 6; // Переменная счетчик и число объектов в эскизе Tag[] objarray4 = new Tag[7]; // Массив объектов из 7 элементов. Заполняется указателями на элементы эскиза выдавливания при их построении(линии и дуги) Tag wcs_tag1, matrix_tag1, wcs_tag2, matrix_tag2, wcs_tag3, matrix_tag3, wcs_tag4, matrix_tag4; //Переменные wcs_tag1 – для записи указателя на текущую систему координат; matrix_tag1 – для записи идентификатора матрицысвязанного с объектом и т.д. Tag[] features4; //features4 – переменная для записи указателя на объект, получившийся в результате операции выдавливания double[] arc1_centerpt1 = { 35, -50, 30.5 }; //Переменная содержащая значения координат центра дуги 1{x,y,z} double arc1_start_ang1 = 0; //Переменная содержащая значение угла начала дуги 1 (в радианах) double arc1_end_ang1 = 3.14159265358979324 * 2; //Переменная содержащая значение угла конца дуги 1 (в радианах) double arc1_rad1 = 5; //Переменная содержащая значение радиуса дуги 1 (в радианах) UFCurve.Arc arc1 = new UFCurve.Arc(); //Создание структуры NX соответствующей дуге 1 //Установка параметров дуги 1 arc1.start_angle = arc1_start_ang1; //Начальный угол arc1.end_angle = arc1_end_ang1; //Конечный угол arc1.arc_center = new double[3]; //Центр дуги 1 arc1.arc_center[0] = arc1_centerpt1[0]; //Координата центра дуги 1 по X arc1.arc_center[1] = arc1_centerpt1[1]; //Координата центра дуги 1 по Y arc1.arc_center[2] = arc1_centerpt1[2]; //Координата центра дуги 1 по Z arc1.radius = arc1_rad1; //Радиус дуги 1 theUfSession.Csys.AskWcs(out wcs_tag1); //Получения указателя на активную систему координат theUfSession.Csys.AskMatrixOfObject(wcs_tag1, out matrix_tag1); //Получение идентификатора матрицы, связанного с объектом,указатель на который содержится в wcs_tag1 arc1.matrix_tag = matrix_tag1; //Определение указателя матрицы дуги 1 /*----------------------------------------------------------*/ /***********************Аналогично дуге 1********************/ double[] arc2_centerpt2 = { 35, 50, 30.5 }; double arc2_start_ang2 = 0; double arc2_end_ang2 = 3.14159265358979324 * 2; double arc2_rad2 = 5; UFCurve.Arc arc2 = new UFCurve.Arc(); arc2.start_angle = arc2_start_ang2; arc2.end_angle = arc2_end_ang2; arc2.arc_center = new double[3]; arc2.arc_center[0] = arc2_centerpt2[0]; arc2.arc_center[1] = arc2_centerpt2[1]; arc2.arc_center[2] = arc2_centerpt2[2]; arc2.radius = arc2_rad2; theUfSession.Csys.AskWcs(out wcs_tag2); theUfSession.Csys.AskMatrixOfObject(wcs_tag2, out matrix_tag2); arc2.matrix_tag = matrix_tag2; /*----------------------------------------------------------*/ /***********************Аналогично дуге 1********************/ double[] arc3_centerpt3 = { 35, -50, 30.5 }; double arc3_start_ang3 = -3.14159265358979324; double arc3_end_ang3 = 0; double arc3_rad3 = 15; UFCurve.Arc arc3 = new UFCurve.Arc(); arc3.start_angle = arc3_start_ang3; arc3.end_angle = arc3_end_ang3; arc3.arc_center = new double[3]; arc3.arc_center[0] = arc3_centerpt3[0]; arc3.arc_center[1] = arc3_centerpt3[1]; arc3.arc_center[2] = arc3_centerpt3[2]; arc3.radius = arc3_rad3; theUfSession.Csys.AskWcs(out wcs_tag3); theUfSession.Csys.AskMatrixOfObject(wcs_tag3, out matrix_tag3); arc3.matrix_tag = matrix_tag3; /*----------------------------------------------------------*/ /***********************Аналогично дуге 1********************/ double[] arc4_centerpt4 = { 35, 50, 30.5 }; double arc4_start_ang4 = 0; double arc4_end_ang4 = 3.14159265358979324; double arc4_rad4 = 15; UFCurve.Arc arc4 = new UFCurve.Arc(); arc4.start_angle = arc4_start_ang4; arc4.end_angle = arc4_end_ang4; arc4.arc_center = new double[3]; arc4.arc_center[0] = arc4_centerpt4[0]; arc4.arc_center[1] = arc4_centerpt4[1]; arc4.arc_center[2] = arc4_centerpt4[2]; arc4.radius = arc4_rad4; theUfSession.Csys.AskWcs(out wcs_tag4); theUfSession.Csys.AskMatrixOfObject(wcs_tag4, out matrix_tag4); arc4.matrix_tag = matrix_tag4; /*----------------------------------------------------------*/ //Определение переменных содержащих координаты начальной и конечной точек отрезков 1 и 2 double[] l1_endpt1_1 = { 20, -50, 30.5 }; //Координаты начальной точки отрезка 1 double[] l1_endpt2_1 = { 20, 50, 30.5 }; //Координаты конечной точки отрезка 1 double[] l2_endpt1_1 = { 50, 50, 30.5 }; //Координаты начальной точки отрезка 2 double[] l2_endpt2_1 = { 50, -50, 30.5 }; //Координаты конечной точки отрезка 2 UFCurve.Line line1_1 = new UFCurve.Line(); //Создание переменной объекта отрезок 1 UFCurve.Line line2_1 = new UFCurve.Line(); //Создание переменной объекта отрезок 2 //Задание параметров отрезков line1_1.start_point = new double[3]; line1_1.start_point[0] = l1_endpt1_1[0]; //Координата Х начальной точки отрезка 1 line1_1.start_point[1] = l1_endpt1_1[1]; //Координата Y начальной точки отрезка 1 line1_1.start_point[2] = l1_endpt1_1[2]; //Координата Z начальной точки отрезка 1 line1_1.end_point = new double[3]; line1_1.end_point[0] = l1_endpt2_1[0]; //Координата Х конечной точки отрезка 1 line1_1.end_point[1] = l1_endpt2_1[1]; //Координата Y конечной точки отрезка 1 line1_1.end_point[2] = l1_endpt2_1[2]; //Координата Z конечной точки отрезка 1 line2_1.start_point = new double[3]; line2_1.start_point[0] = l2_endpt1_1[0]; //Координата Х начальной точки отрезка 2 line2_1.start_point[1] = l2_endpt1_1[1]; //Координата Y начальной точки отрезка 2 line2_1.start_point[2] = l2_endpt1_1[2]; //Координата Z начальной точки отрезка 2 line2_1.end_point = new double[3]; line2_1.end_point[0] = l2_endpt2_1[0]; //Координата Х конечной точки отрезка 2 line2_1.end_point[1] = l2_endpt2_1[1]; //Координата Y конечной точки отрезка 2 line2_1.end_point[2] = l2_endpt2_1[2]; //Координата Z конечной точки отрезка 2 theUfSession.Curve.CreateArc(ref arc1 /*объект дуга 1*/, out objarray4[0] /*указатель на созданный объект дуга 1 – 0-й элемент * * массива объектов выдавливания*/); //Построение дуги 1 theUfSession.Curve.CreateLine(ref line1_1, out objarray4[1]); //Построение отрезка 1 theUfSession.Curve.CreateLine(ref line2_1, out objarray4[2]); //Построение отрезка 2 theUfSession.Curve.CreateArc(ref arc2, out objarray4[3]); //Построение дуги 2 theUfSession.Curve.CreateArc(ref arc3, out objarray4[4]); //Построение дуги 3 theUfSession.Curve.CreateArc(ref arc4, out objarray4[5]); //Построение дуги 4 //Создание операции выдавливания theUfSession.Modl.CreateExtruded( objarray4 /*Массив объектов выдавливания*/, taper_angle4 /*Угол уклона*/, limit4 /*Начало и конец выдавливания*/, ref_pt4 /*Пустой параметр*/, direction4 /*Направление выдавливания*/, FeatureSigns.Positive /*Буревая операция (ОБЕДИНЕНИЕ)*/, out features4 /*Выходной параметр - указатель на результат * * операции*/); //вторая опора double[] direction5 = { 0.0, 0.0, 1.0 }; //Переменная задающая значения направления выдавливания ось CZ double[] ref_pt5 = new double[3]; //Требуемая, но не используемая переменная string taper_angle5 = "0.0"; //Переменная, определяющая значение уклона при выдавливании string[] limit5 = { "-10", "3" }; int i5, count5 = 6; // Переменная счетчик и число объектов в эскизе Tag[] objarray5 = new Tag[7]; // Массив объектов из 7 элементов. Заполняется указателями на элементы эскиза выдавливания при их построении(линии и дуги) Tag wcs_tag1_1, matrix_tag1_1, wcs_tag2_1, matrix_tag2_1, wcs_tag3_1, matrix_tag3_1, wcs_tag4_1, matrix_tag4_1; //Переменные wcs_tag1 – для записи указателя на текущую систему координат; matrix_tag1 – для записи идентификатора матрицысвязанного с объектом и т.д. Tag[] features5; //features4 – переменная для записи указателя на объект, получившийся в результате операции выдавливания double[] arc1_centerpt1_1 = { 165, -50, 30.5 }; //Переменная содержащая значения координат центра дуги 1{x,y,z} double arc1_start_ang1_1 = 0; //Переменная содержащая значение угла начала дуги 1 (в радианах) double arc1_end_ang1_1 = 3.14159265358979324 * 2; //Переменная содержащая значение угла конца дуги 1 (в радианах) double arc1_rad1_1 = 5; //Переменная содержащая значение радиуса дуги 1 (в радианах) UFCurve.Arc arc1_1 = new UFCurve.Arc(); //Создание структуры NX соответствующей дуге 1 //Установка параметров дуги 1 arc1_1.start_angle = arc1_start_ang1_1; //Начальный угол arc1_1.end_angle = arc1_end_ang1_1; //Конечный угол arc1_1.arc_center = new double[3]; //Центр дуги 1 arc1_1.arc_center[0] = arc1_centerpt1_1[0]; //Координата центра дуги 1 по X arc1_1.arc_center[1] = arc1_centerpt1_1[1]; //Координата центра дуги 1 по Y arc1_1.arc_center[2] = arc1_centerpt1_1[2]; //Координата центра дуги 1 по Z arc1_1.radius = arc1_rad1_1; //Радиус дуги 1 theUfSession.Csys.AskWcs(out wcs_tag1_1); //Получения указателя на активную систему координат theUfSession.Csys.AskMatrixOfObject(wcs_tag1_1, out matrix_tag1_1); //Получение идентификатора матрицы, связанного с объектом,указатель на который содержится в wcs_tag1 arc1_1.matrix_tag = matrix_tag1_1; //Определение указателя матрицы дуги 1 /*----------------------------------------------------------*/ /***********************Аналогично дуге 1********************/ double[] arc2_centerpt2_1 = { 165, 50, 30.5 }; double arc2_start_ang2_1 = 0; double arc2_end_ang2_1 = 3.14159265358979324 * 2; double arc2_rad2_1 = 5; UFCurve.Arc arc2_1 = new UFCurve.Arc(); arc2_1.start_angle = arc2_start_ang2_1; arc2_1.end_angle = arc2_end_ang2_1; arc2_1.arc_center = new double[3]; arc2_1.arc_center[0] = arc2_centerpt2_1[0]; arc2_1.arc_center[1] = arc2_centerpt2_1[1]; arc2_1.arc_center[2] = arc2_centerpt2_1[2]; arc2_1.radius = arc2_rad2_1; theUfSession.Csys.AskWcs(out wcs_tag2_1); theUfSession.Csys.AskMatrixOfObject(wcs_tag2_1, out matrix_tag2_1); arc2_1.matrix_tag = matrix_tag2_1; /*----------------------------------------------------------*/ /***********************Аналогично дуге 1********************/ double[] arc3_centerpt3_1 = { 165, -50, 30.5 }; double arc3_start_ang3_1 = -3.14159265358979324; double arc3_end_ang3_1 = 0; double arc3_rad3_1 = 15; UFCurve.Arc arc3_1 = new UFCurve.Arc(); arc3_1.start_angle = arc3_start_ang3_1; arc3_1.end_angle = arc3_end_ang3_1; arc3_1.arc_center = new double[3]; arc3_1.arc_center[0] = arc3_centerpt3_1[0]; arc3_1.arc_center[1] = arc3_centerpt3_1[1]; arc3_1.arc_center[2] = arc3_centerpt3_1[2]; arc3_1.radius = arc3_rad3_1; theUfSession.Csys.AskWcs(out wcs_tag3_1); theUfSession.Csys.AskMatrixOfObject(wcs_tag3_1, out matrix_tag3_1); arc3_1.matrix_tag = matrix_tag3_1; /*----------------------------------------------------------*/ /***********************Аналогично дуге 1********************/ double[] arc4_centerpt4_1 = { 165, 50, 30.5 }; double arc4_start_ang4_1 = 0; double arc4_end_ang4_1 = 3.14159265358979324; double arc4_rad4_1 = 15; UFCurve.Arc arc4_1 = new UFCurve.Arc(); arc4_1.start_angle = arc4_start_ang4_1; arc4_1.end_angle = arc4_end_ang4_1; arc4_1.arc_center = new double[3]; arc4_1.arc_center[0] = arc4_centerpt4_1[0]; arc4_1.arc_center[1] = arc4_centerpt4_1[1]; arc4_1.arc_center[2] = arc4_centerpt4_1[2]; arc4_1.radius = arc4_rad4_1; theUfSession.Csys.AskWcs(out wcs_tag4_1); theUfSession.Csys.AskMatrixOfObject(wcs_tag4_1, out matrix_tag4_1); arc4_1.matrix_tag = matrix_tag4_1; /*----------------------------------------------------------*/ //Определение переменных содержащих координаты начальной и конечной точек отрезков 1 и 2 double[] l1_endpt1_12 = { 150, -50, 30.5 }; //Координаты начальной точки отрезка 1 double[] l1_endpt2_12 = { 150, 50, 30.5 }; //Координаты конечной точки отрезка 1 double[] l2_endpt1_12 = { 180, 50, 30.5 }; //Координаты начальной точки отрезка 2 double[] l2_endpt2_12 = { 180, -50, 30.5 }; //Координаты конечной точки отрезка 2 UFCurve.Line line1_12 = new UFCurve.Line(); //Создание переменной объекта отрезок 1 UFCurve.Line line2_12 = new UFCurve.Line(); //Создание переменной объекта отрезок 2 //Задание параметров отрезков line1_12.start_point = new double[3]; line1_12.start_point[0] = l1_endpt1_12[0]; //Координата Х начальной точки отрезка 1 line1_12.start_point[1] = l1_endpt1_12[1]; //Координата Y начальной точки отрезка 1 line1_12.start_point[2] = l1_endpt1_12[2]; //Координата Z начальной точки отрезка 1 line1_12.end_point = new double[3]; line1_12.end_point[0] = l1_endpt2_12[0]; //Координата Х конечной точки отрезка 1 line1_12.end_point[1] = l1_endpt2_12[1]; //Координата Y конечной точки отрезка 1 line1_12.end_point[2] = l1_endpt2_12[2]; //Координата Z конечной точки отрезка 1 line2_12.start_point = new double[3]; line2_12.start_point[0] = l2_endpt1_12[0]; //Координата Х начальной точки отрезка 2 line2_12.start_point[1] = l2_endpt1_12[1]; //Координата Y начальной точки отрезка 2 line2_12.start_point[2] = l2_endpt1_12[2]; //Координата Z начальной точки отрезка 2 line2_12.end_point = new double[3]; line2_12.end_point[0] = l2_endpt2_12[0]; //Координата Х конечной точки отрезка 2 line2_12.end_point[1] = l2_endpt2_12[1]; //Координата Y конечной точки отрезка 2 line2_12.end_point[2] = l2_endpt2_12[2]; //Координата Z конечной точки отрезка 2 theUfSession.Curve.CreateArc(ref arc1_1 /*объект дуга 1*/, out objarray5[0] /*указатель на созданный объект дуга 1 – 0-й элемент * * массива объектов выдавливания*/); //Построение дуги 1 theUfSession.Curve.CreateLine(ref line1_12, out objarray5[1]); //Построение отрезка 1 theUfSession.Curve.CreateLine(ref line2_12, out objarray5[2]); //Построение отрезка 2 theUfSession.Curve.CreateArc(ref arc2_1, out objarray5[3]); //Построение дуги 2 theUfSession.Curve.CreateArc(ref arc3_1, out objarray5[4]); //Построение дуги 3 theUfSession.Curve.CreateArc(ref arc4_1, out objarray5[5]); //Построение дуги 4 //Создание операции выдавливания theUfSession.Modl.CreateExtruded( objarray5 /*Массив объектов выдавливания*/, taper_angle5 /*Угол уклона*/, limit5 /*Начало и конец выдавливания*/, ref_pt5 /*Пустой параметр*/, direction5 /*Направление выдавливания*/, FeatureSigns.Positive /*Буревая операция (ОБЕДИНЕНИЕ)*/, out features5 /*Выходной параметр - указатель на результат * * операции*/); theUfSession.Part.Save(); } catch (NXOpen.NXException ex) { } return(retValue); }
public static void MakeFingerPin(double d, double d1, double H, double h) { try { string name1 = "model_136"; int units1 = 1; Tag UFPart1; theUfSession = UFSession.GetUFSession(); theUfSession.Part.New(name1, units1, out UFPart1); double[] l1_endpt1 = { 0, 0, 0.0 }; double[] l1_endpt2 = { 0, d / 2, 0.0 }; double[] l2_endpt1 = { 0, d / 2, 0.0 }; double[] l2_endpt2 = { H - h, d / 2, 0.0 }; double[] l3_endpt1 = { H - h, d / 2, 0.0 }; double[] l3_endpt2 = { H - h, d / 2 - d1 / 2, 0.0 }; double[] l4_endpt1 = { H - h, d / 2 - d1 / 2, 0.0 }; double[] l4_endpt2 = { H, d / 2 - d1 / 2, 0.0 }; double[] l5_endpt1 = { H, d / 2 - d1 / 2, 0.0 }; double[] l5_endpt2 = { H, 0, 0.0 }; double[] l6_endpt1 = { H, 0, 0.0 }; double[] l6_endpt2 = { 0, 0, 0.0 }; UFCurve.Line line1 = new UFCurve.Line(); UFCurve.Line line2 = new UFCurve.Line(); UFCurve.Line line3 = new UFCurve.Line(); UFCurve.Line line4 = new UFCurve.Line(); UFCurve.Line line5 = new UFCurve.Line(); UFCurve.Line line6 = new UFCurve.Line(); SetPointsToLine(ref line1, l1_endpt1, l1_endpt2); SetPointsToLine(ref line2, l2_endpt1, l2_endpt2); SetPointsToLine(ref line3, l3_endpt1, l3_endpt2); SetPointsToLine(ref line4, l4_endpt1, l4_endpt2); SetPointsToLine(ref line5, l5_endpt1, l5_endpt2); SetPointsToLine(ref line6, l6_endpt1, l6_endpt2); Tag[] objarray1 = new Tag[9]; theUfSession.Curve.CreateLine(ref line1, out objarray1[0]); theUfSession.Curve.CreateLine(ref line2, out objarray1[1]); theUfSession.Curve.CreateLine(ref line3, out objarray1[2]); theUfSession.Curve.CreateLine(ref line4, out objarray1[3]); theUfSession.Curve.CreateLine(ref line5, out objarray1[4]); theUfSession.Curve.CreateLine(ref line6, out objarray1[5]); double[] ref_pt1 = new double[3]; ref_pt1[0] = 0.00; ref_pt1[1] = 0.00; ref_pt1[2] = 0.00; double[] direction1 = { 1.00, 0.00, 0.00 }; string[] limit1 = { "0", "360" }; Tag[] features1; theUfSession.Modl.CreateRevolved(objarray1, limit1, ref_pt1, direction1, FeatureSigns.Nullsign, out features1); Tag feat = features1[0]; Tag cyl_tag, obj_id_camf, blend1, s_face, c_face; Tag[] Edge_array_cyl, list1, list2; int ecount; //анализ ребер рассматриваемой детали theUfSession.Modl.AskFeatBody(feat, out cyl_tag); theUfSession.Modl.AskBodyEdges(cyl_tag, out Edge_array_cyl); theUfSession.Modl.AskListCount(Edge_array_cyl, out ecount); ArrayList arr_list1 = new ArrayList(); ArrayList arr_list2 = new ArrayList();//фаски for (int ii = 0; ii < ecount; ii++) { Tag edge; theUfSession.Modl.AskListItem(Edge_array_cyl, ii, out edge); if (ii == 2) { arr_list2.Add(edge); } if (ii == 3) { arr_list1.Add(edge); } } list1 = (Tag[])arr_list1.ToArray(typeof(Tag)); list2 = (Tag[])arr_list2.ToArray(typeof(Tag)); //фаска string offset1 = "1"; string offset2 = "1"; string offset11 = "0.5"; string offset21 = "0.5"; string ang = "45"; theUfSession.Modl.CreateChamfer(3, offset1, offset2, ang, list1, out obj_id_camf); theUfSession.Modl.CreateChamfer(3, offset11, offset21, ang, list2, out obj_id_camf); } catch (NXException ex) { } }
public static void MakeHandle(double L, double L1, double d1, double d2, double l) { try { string name1 = "model_56"; int units1 = 1; Tag UFPart1; theUfSession = UFSession.GetUFSession(); theUfSession.Part.New(name1, units1, out UFPart1); double[] l1_endpt1 = { 0, d2 / 2, 0.0 }; double[] l1_endpt2 = { L - L1 - l, d2 / 2, 0.0 }; double[] l2_endpt1 = { L - L1 - l, d2 / 2, 0.0 }; double[] l2_endpt2 = { L - L1 - l, d1 / 2, 0.0 }; double[] l3_endpt1 = { L - L1 - l, d1 / 2, 0.0 }; double[] l3_endpt2 = { L - l, d1 / 2, 0.0 }; double[] l4_endpt1 = { L - l, d1 / 2, 0.0 }; double[] l4_endpt2 = { L - l, d2 / 2, 0.0 }; double[] l5_endpt1 = { L - l, d2 / 2, 0.0 }; double[] l5_endpt2 = { L, d2 / 2, 0.0 }; double[] l6_endpt1 = { L, d2 / 2, 0.0 }; double[] l6_endpt2 = { L, 0, 0.0 }; double[] l7_endpt1 = { L, 0, 0.0 }; double[] l7_endpt2 = { 0, 0, 0.0 }; double[] l8_endpt1 = { 0, 0, 0.0 }; double[] l8_endpt2 = { 0, d2 / 2, 0.0 }; UFCurve.Line line1 = new UFCurve.Line(); UFCurve.Line line2 = new UFCurve.Line(); UFCurve.Line line3 = new UFCurve.Line(); UFCurve.Line line4 = new UFCurve.Line(); UFCurve.Line line5 = new UFCurve.Line(); UFCurve.Line line6 = new UFCurve.Line(); UFCurve.Line line7 = new UFCurve.Line(); UFCurve.Line line8 = new UFCurve.Line(); SetPointsToLine(ref line1, l1_endpt1, l1_endpt2); SetPointsToLine(ref line2, l2_endpt1, l2_endpt2); SetPointsToLine(ref line3, l3_endpt1, l3_endpt2); SetPointsToLine(ref line4, l4_endpt1, l4_endpt2); SetPointsToLine(ref line5, l5_endpt1, l5_endpt2); SetPointsToLine(ref line6, l6_endpt1, l6_endpt2); SetPointsToLine(ref line7, l7_endpt1, l7_endpt2); SetPointsToLine(ref line8, l8_endpt1, l8_endpt2); Tag[] objarray1 = new Tag[9]; theUfSession.Curve.CreateLine(ref line1, out objarray1[0]); theUfSession.Curve.CreateLine(ref line2, out objarray1[1]); theUfSession.Curve.CreateLine(ref line3, out objarray1[2]); theUfSession.Curve.CreateLine(ref line4, out objarray1[3]); theUfSession.Curve.CreateLine(ref line5, out objarray1[4]); theUfSession.Curve.CreateLine(ref line6, out objarray1[5]); theUfSession.Curve.CreateLine(ref line7, out objarray1[6]); theUfSession.Curve.CreateLine(ref line8, out objarray1[7]); double[] ref_pt1 = new double[3]; ref_pt1[0] = 0.00; ref_pt1[1] = 0.00; ref_pt1[2] = 0.00; double[] direction1 = { 1.00, 0.00, 0.00 }; string[] limit1 = { "0", "360" }; Tag[] features1; theUfSession.Modl.CreateRevolved(objarray1, limit1, ref_pt1, direction1, FeatureSigns.Nullsign, out features1); theUfSession.Part.Save(); } catch (NXException ex) { } }
public static int Main(string[] args) { int retValue = 0; theForm = new Form(); theForm.Show(); //описание переменных Tag UFPart1; string name1 = "model_k"; int units1 = 1; try { theUfSession = UFSession.GetUFSession(); //Session theUfSession = Session.GetSession(); theUfSession.Part.New(name1, units1, out UFPart1); //создание новой детали //описание переменных, соотв. конечным точкам отрезков эскиза double[] l1_endpt1 = { 0, 5, 0.00 }; double[] l1_endpt2 = { 2, 5, 0.00 }; double[] l2_endpt1 = { 2, 5, 0.00 }; double[] l2_endpt2 = { 2, 32.5, 0.00 }; double[] l3_endpt1 = { 2, 32.5, 0.00 }; double[] l3_endpt2 = { -18, 32.5, 0.00 }; double[] l4_endpt1 = { -18, 32.5, 0.00 }; double[] l4_endpt2 = { -18, 30.5, 0.00 }; double[] l5_endpt1 = { -18, 30.5, 0.00 }; double[] l5_endpt2 = { 0, 30.5, 0.00 }; double[] l6_endpt1 = { 0, 30.5, 0.00 }; double[] l6_endpt2 = { 0, 5, 0.00 }; //Создание новых структур UFCurve.Line line1 = new UFCurve.Line(); UFCurve.Line line2 = new UFCurve.Line(); UFCurve.Line line3 = new UFCurve.Line(); UFCurve.Line line4 = new UFCurve.Line(); UFCurve.Line line5 = new UFCurve.Line(); UFCurve.Line line6 = new UFCurve.Line(); //Конечные точки отрезков line1.start_point = new double[3]; line1.start_point[0] = l1_endpt1[0]; line1.start_point[1] = l1_endpt1[1]; line1.start_point[2] = l1_endpt1[2]; line1.end_point = new double[3]; line1.end_point[0] = l1_endpt2[0]; line1.end_point[1] = l1_endpt2[1]; line1.end_point[2] = l1_endpt2[2]; line2.start_point = new double[3]; line2.start_point[0] = l2_endpt1[0]; line2.start_point[1] = l2_endpt1[1]; line2.start_point[2] = l2_endpt1[2]; line2.end_point = new double[3]; line2.end_point[0] = l2_endpt2[0]; line2.end_point[1] = l2_endpt2[1]; line2.end_point[2] = l2_endpt2[2]; line3.start_point = new double[3]; line3.start_point[0] = l3_endpt1[0]; line3.start_point[1] = l3_endpt1[1]; line3.start_point[2] = l3_endpt1[2]; line3.end_point = new double[3]; line3.end_point[0] = l3_endpt2[0]; line3.end_point[1] = l3_endpt2[1]; line3.end_point[2] = l3_endpt2[2]; line4.start_point = new double[3]; line4.start_point[0] = l4_endpt1[0]; line4.start_point[1] = l4_endpt1[1]; line4.start_point[2] = l4_endpt1[2]; line4.end_point = new double[3]; line4.end_point[0] = l4_endpt2[0]; line4.end_point[1] = l4_endpt2[1]; line4.end_point[2] = l4_endpt2[2]; line5.start_point = new double[3]; line5.start_point[0] = l5_endpt1[0]; line5.start_point[1] = l5_endpt1[1]; line5.start_point[2] = l5_endpt1[2]; line5.end_point = new double[3]; line5.end_point[0] = l5_endpt2[0]; line5.end_point[1] = l5_endpt2[1]; line5.end_point[2] = l5_endpt2[2]; line6.start_point = new double[3]; line6.start_point[0] = l6_endpt1[0]; line6.start_point[1] = l6_endpt1[1]; line6.start_point[2] = l6_endpt1[2]; line6.end_point = new double[3]; line6.end_point[0] = l6_endpt2[0]; line6.end_point[1] = l6_endpt2[1]; line6.end_point[2] = l6_endpt2[2]; //Создание отрезков в 3D пространстве Tag[] objarray1 = new Tag[7]; theUfSession.Curve.CreateLine(ref line1, out objarray1[0]); theUfSession.Curve.CreateLine(ref line2, out objarray1[1]); theUfSession.Curve.CreateLine(ref line3, out objarray1[2]); theUfSession.Curve.CreateLine(ref line4, out objarray1[3]); theUfSession.Curve.CreateLine(ref line5, out objarray1[4]); theUfSession.Curve.CreateLine(ref line6, out objarray1[5]); double[] ref_pt1 = new double[3]; ref_pt1[0] = 0.00; ref_pt1[1] = 0.00; ref_pt1[2] = 0.00; double[] direction1 = { 1.00, 0.00, 0.00 }; string[] limit1 = { "0", "360" }; Tag[] features1; //Операция вращения theUfSession.Modl.CreateRevolved(objarray1, limit1, ref_pt1, direction1, FeatureSigns.Nullsign, out features1); theUfSession.Part.Save(); Tag feat = features1[0]; Tag cyl_tag, obj_id_camf, blend1; Tag[] Edge_array_cyl, list1, list2; int ecount; theUfSession.Modl.AskFeatBody(feat, out cyl_tag); theUfSession.Modl.AskBodyEdges(cyl_tag, out Edge_array_cyl); theUfSession.Modl.AskListCount(Edge_array_cyl, out ecount); ArrayList arr_list1 = new ArrayList(); ArrayList arr_list2 = new ArrayList(); for (int ii = 0; ii < ecount; ii++) { Tag edge; theUfSession.Modl.AskListItem(Edge_array_cyl, ii, out edge); if ((ii == 1) || (ii == 2)) { arr_list1.Add(edge); } if (ii == 0) { arr_list2.Add(edge); } } list1 = (Tag[])arr_list1.ToArray(typeof(Tag)); list2 = (Tag[])arr_list2.ToArray(typeof(Tag)); //скругление int allow_smooth = 0; int allow_cliff = 0; int allow_notch = 0; double vrb_tol = 0.0; theUfSession.Modl.CreateBlend("3", list2, allow_smooth, allow_cliff, allow_notch, vrb_tol, out blend1); //фаска string offset1 = "1"; string offset2 = "1"; string ang = "45"; theUfSession.Modl.CreateChamfer(3, offset1, offset2, ang, list1, out obj_id_camf); theUfSession.Part.Save(); } catch (NXOpen.NXException ex) { } return(retValue); }
public static int Main(string[] args) { int retValue = 0; theForm = new Form(); theForm.Show(); //описание переменных Tag UFPart1; string name1 = "model_k"; int units1 = 1; try { theUfSession = UFSession.GetUFSession(); //Session theUfSession = Session.GetSession(); theUfSession.Part.New(name1, units1, out UFPart1); //создание новой детали //описание переменных, соотв. конечным точкам отрезков эскиза double[] l1_endpt1 = { 0, 5, 0.00 }; double[] l1_endpt2 = { 2, 5, 0.00 }; double[] l2_endpt1 = { 2, 5, 0.00 }; double[] l2_endpt2 = { 2, 32.5, 0.00 }; double[] l3_endpt1 = { 2, 32.5, 0.00 }; double[] l3_endpt2 = { -18, 32.5, 0.00 }; double[] l4_endpt1 = { -18, 32.5, 0.00 }; double[] l4_endpt2 = { -18, 30.5, 0.00 }; double[] l5_endpt1 = { -18, 30.5, 0.00 }; double[] l5_endpt2 = { 0, 30.5, 0.00 }; double[] l6_endpt1 = { 0, 30.5, 0.00 }; double[] l6_endpt2 = { 0, 5, 0.00 }; //Создание новых структур UFCurve.Line line1 = new UFCurve.Line(); UFCurve.Line line2 = new UFCurve.Line(); UFCurve.Line line3 = new UFCurve.Line(); UFCurve.Line line4 = new UFCurve.Line(); UFCurve.Line line5 = new UFCurve.Line(); UFCurve.Line line6 = new UFCurve.Line(); //Конечные точки отрезков line1.start_point = new double[3]; line1.start_point[0] = l1_endpt1[0]; line1.start_point[1] = l1_endpt1[1]; line1.start_point[2] = l1_endpt1[2]; line1.end_point = new double[3]; line1.end_point[0] = l1_endpt2[0]; line1.end_point[1] = l1_endpt2[1]; line1.end_point[2] = l1_endpt2[2]; line2.start_point = new double[3]; line2.start_point[0] = l2_endpt1[0]; line2.start_point[1] = l2_endpt1[1]; line2.start_point[2] = l2_endpt1[2]; line2.end_point = new double[3]; line2.end_point[0] = l2_endpt2[0]; line2.end_point[1] = l2_endpt2[1]; line2.end_point[2] = l2_endpt2[2]; line3.start_point = new double[3]; line3.start_point[0] = l3_endpt1[0]; line3.start_point[1] = l3_endpt1[1]; line3.start_point[2] = l3_endpt1[2]; line3.end_point = new double[3]; line3.end_point[0] = l3_endpt2[0]; line3.end_point[1] = l3_endpt2[1]; line3.end_point[2] = l3_endpt2[2]; line4.start_point = new double[3]; line4.start_point[0] = l4_endpt1[0]; line4.start_point[1] = l4_endpt1[1]; line4.start_point[2] = l4_endpt1[2]; line4.end_point = new double[3]; line4.end_point[0] = l4_endpt2[0]; line4.end_point[1] = l4_endpt2[1]; line4.end_point[2] = l4_endpt2[2]; line5.start_point = new double[3]; line5.start_point[0] = l5_endpt1[0]; line5.start_point[1] = l5_endpt1[1]; line5.start_point[2] = l5_endpt1[2]; line5.end_point = new double[3]; line5.end_point[0] = l5_endpt2[0]; line5.end_point[1] = l5_endpt2[1]; line5.end_point[2] = l5_endpt2[2]; line6.start_point = new double[3]; line6.start_point[0] = l6_endpt1[0]; line6.start_point[1] = l6_endpt1[1]; line6.start_point[2] = l6_endpt1[2]; line6.end_point = new double[3]; line6.end_point[0] = l6_endpt2[0]; line6.end_point[1] = l6_endpt2[1]; line6.end_point[2] = l6_endpt2[2]; //Создание отрезков в 3D пространстве Tag[] objarray1 = new Tag[7]; theUfSession.Curve.CreateLine(ref line1, out objarray1[0]); theUfSession.Curve.CreateLine(ref line2, out objarray1[1]); theUfSession.Curve.CreateLine(ref line3, out objarray1[2]); theUfSession.Curve.CreateLine(ref line4, out objarray1[3]); theUfSession.Curve.CreateLine(ref line5, out objarray1[4]); theUfSession.Curve.CreateLine(ref line6, out objarray1[5]); double[] ref_pt1 = new double[3]; ref_pt1[0] = 0.00; ref_pt1[1] = 0.00; ref_pt1[2] = 0.00; double[] direction1 = { 1.00, 0.00, 0.00 }; string[] limit1 = { "0", "360" }; Tag[] features1; //Операция вращения theUfSession.Modl.CreateRevolved(objarray1, limit1, ref_pt1, direction1, FeatureSigns.Nullsign, out features1); theUfSession.Part.Save(); } catch (NXOpen.NXException ex) { } return(retValue); }