private void DrawCoordinateSystem() { TSM.UI.GraphicsDrawer drawer = new TSM.UI.GraphicsDrawer(); TSG.Point origin = new TSG.Point(); TSG.Point pointX = new TSG.Point(3000, 0, 0); TSG.Point pointY = new TSG.Point(0, 3000, 0); TSG.Point pointZ = new TSG.Point(0, 0, 3000); TSM.UI.Color blue = new TSM.UI.Color(0, 0, 1); TSM.UI.Color red = new TSM.UI.Color(1, 0, 0); drawer.DrawText(pointX, "X", blue); drawer.DrawText(pointY, "Y", blue); drawer.DrawText(pointZ, "Z", blue); drawer.DrawLineSegment(origin, pointX, red); drawer.DrawLineSegment(origin, pointY, red); drawer.DrawLineSegment(origin, pointZ, red); }
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)); } } } }
private void DrawPoint(TSG.Point location, string comment) { TSM.UI.GraphicsDrawer drawer = new TSM.UI.GraphicsDrawer(); drawer.DrawText(location, comment, new TSM.UI.Color(1, 0, 0)); }