private void distance_Click(object sender, EventArgs e) { Picker picker = new Picker(); Part part = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_OBJECT) as Part; Beam beam = part as Beam; if (beam != null) { var currentPlane = SetPlaneAndReturnOriginal(beam); //cs_net_lib.UI.DrawPlane(beam.GetCoordinateSystem(), new TSM.UI.Color(0.5, 1, 1), // new TSM.UI.Color(1, 0.5, 1), "Вася"); Point px = new Point(-beam.EndPoint.X + beam.StartPoint.X, beam.EndPoint.Y - beam.StartPoint.Y, beam.EndPoint.Z - beam.StartPoint.Z); Vector vZ; vZ = new Vector(-px.Y, px.X, px.Z); var localPlane = new TransformationPlane(beam.EndPoint, new Vector(px), vZ); CoordinateSystem localCoor = new CoordinateSystem(beam.EndPoint, new Vector(px), vZ); cs_net_lib.UI.DrawPlane(beam.GetCoordinateSystem()); cs_net_lib.UI.DrawPlane(localCoor); teklaModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(currentPlane); } ContourPlate plate = part as ContourPlate; if (plate != null) { //cs_net_lib.UI.DrawPlane(beam.GetCoordinateSystem(), new TSM.UI.Color(0.5, 1, 1), // new TSM.UI.Color(1, 0.5, 1), "Вася"); cs_net_lib.UI.DrawPlane(plate.GetCoordinateSystem()); } string tesGid = null; }
public void CK08_CreatePlate() { ArrayList PickedPoints = null; Picker Picker = new Picker(); try { PickedPoints = Picker.PickPoints(Picker.PickPointEnum.PICK_POLYGON); } catch { PickedPoints = null; } if (PickedPoints != null) { ContourPlate Plate = new ContourPlate(); Plate.AssemblyNumber.Prefix = "P"; Plate.AssemblyNumber.StartNumber = 1; Plate.PartNumber.Prefix = "p"; Plate.PartNumber.StartNumber = 1; Plate.Name = "PLATE"; Plate.Profile.ProfileString = "PL25"; Plate.Material.MaterialString = "C245"; Plate.Finish = ""; Plate.Class = "1"; Plate.Position.Depth = Position.DepthEnum.FRONT; foreach (T3D.Point ThisPoint in PickedPoints) { var chamfer = new Chamfer(12.7, 12.7, Chamfer.ChamferTypeEnum.CHAMFER_LINE); var conturPoint = new ContourPoint(ThisPoint, chamfer); Plate.AddContourPoint(conturPoint); } if (!Plate.Insert()) { Tekla.Structures.Model.Operations.Operation.DisplayPrompt("Plate wasn't created."); } else { // Change the workplane to the coordinate system of the plate. var transformationPlane = new TransformationPlane(Plate.GetCoordinateSystem()); Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(transformationPlane); // Show the plate in the model and the workplane change. Model.CommitChanges(); // This gets the plate's coordinates and information in the current workplane. Plate.Select(); ReperShow(Plate.GetCoordinateSystem()); // Draw the coordinate of the plate in the model in the local coordinate system. GraphicsDrawer Drawer = new GraphicsDrawer(); foreach (ContourPoint ContourPoint in Plate.Contour.ContourPoints) { double x = ContourPoint.X, y = ContourPoint.Y, z = ContourPoint.Z; T3D.Point CornerPoint = new T3D.Point(x, y, z); PointXYZ(ContourPoint); //double ImperialValue = 25.4; //double XValue = Math.Round(CornerPoint.X / ImperialValue, 4); //double YValue = Math.Round(CornerPoint.Y / ImperialValue, 4); //double ZValue = Math.Round(CornerPoint.Z / ImperialValue, 4); //Drawer.DrawText(CornerPoint, "(" + XValue + "," + YValue + "," + ZValue + ")", new Color(1,0,0)); Drawer.DrawLineSegment(new LineSegment(new T3D.Point(0, 0, 0), new T3D.Point(0, 0, 500)), new Color(1, 0, 0)); } mw.Msg("На экране Tekla построена пластина по заданным точкам" + " и показаны координаты этих точек и репер ПСК. [OK]"); MessageBox.Show("Построена пластина."); mw.Msg(); } } }
private void Button_Click(object sender, RoutedEventArgs e) { // Reset workplane to global currentModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane()); ArrayList PickedPoints = null; TSMUI.Picker myPicker = new TSMUI.Picker(); try { PickedPoints = myPicker.PickPoints(Tekla.Structures.Model.UI.Picker.PickPointEnum.PICK_POLYGON); } catch { PickedPoints = null; } if (PickedPoints != null) { ContourPlate myPlate = new ContourPlate(); myPlate.AssemblyNumber.Prefix = "P"; myPlate.AssemblyNumber.StartNumber = 1; myPlate.PartNumber.Prefix = "p"; myPlate.PartNumber.StartNumber = 1; myPlate.Name = "Plate"; myPlate.Profile.ProfileString = "PL25.4"; myPlate.Material.MaterialString = "A36"; myPlate.Finish = "GP"; myPlate.Class = "9"; myPlate.Position.Depth = Position.DepthEnum.FRONT; foreach (T3D.Point ThisPoint in PickedPoints) { myPlate.AddContourPoint(new ContourPoint(ThisPoint, new Chamfer(12.7, 12.7, Chamfer.ChamferTypeEnum.CHAMFER_LINE))); } if (!myPlate.Insert()) { Tekla.Structures.Model.Operations.Operation.DisplayPrompt("No plate was created."); } else { // Change the workplane to match coordinate system of plate currentModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane(myPlate.GetCoordinateSystem())); // Show the plate in the model and show the workplane change currentModel.CommitChanges(); // This gets the plates coordinates and information in the current workplane. myPlate.Select(); // Draw the coordinate of the plate in the model in hte local coordinate system. TSMUI.GraphicsDrawer myDrawer = new TSMUI.GraphicsDrawer(); foreach (ContourPoint ContourPoint in myPlate.Contour.ContourPoints) { T3D.Point CornerPoint = new T3D.Point(ContourPoint.X, ContourPoint.Y, ContourPoint.Z); const double IMPERIALUNIT = 25.4; double XValue = Math.Round(CornerPoint.X / IMPERIALUNIT, 4); double YValue = Math.Round(CornerPoint.Y / IMPERIALUNIT, 4); double ZValue = Math.Round(CornerPoint.Z / IMPERIALUNIT, 4); myDrawer.DrawText(CornerPoint, "(" + XValue + "," + YValue + "," + ZValue + ")", new TSMUI.Color(1, 0, 0)); myDrawer.DrawLineSegment(new T3D.LineSegment(new T3D.Point(0, 0, 0), new T3D.Point(0, 0, 500)), new TSMUI.Color(1, 0, 0)); } } } }