Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var selection = new Picker().PickObjects(Picker.PickObjectsEnum.PICK_N_OBJECTS).ToList();
                if (selection == null)
                {
                    return;
                }

                var connections = selection.OfType <Connection>().ToList();

                connections.ForEach(c =>
                {
                    var drawer = new GraphicsDrawer();
                    var color  = new Color(1, 1, 1);

                    //get parts from the connection
                    var parts = c.GetChildren().ToList().OfType <Part>().ToList();

                    parts.ForEach(p =>
                    {
                        var point    = p.GetCenterLine(false)[0] as Point;
                        var partMark = p.GetPartMark();
                        drawer.DrawText(point, partMark, color);
                    });
                });
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// In case of multiple maps might receive delegate to map generator as argument.
 /// </summary>
 public Game()
 {
     formWidth      = FormBambulanci.WidthStatic;
     formHeight     = FormBambulanci.HeightStatic;
     map            = Map.GetStandardMap();
     graphicsDrawer = new GraphicsDrawer(map);
 }
Ejemplo n.º 3
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            //searching for member part mark
            var searchValue = textBoxSearch.Text;

            ModelObjectEnumerator.AutoFetch = true;
            var modelObjects = new Model().GetModelObjectSelector()
                               .GetAllObjectsWithType(ModelObject.ModelObjectEnum.BEAM)
                               .ToList()
                               .OfType <Beam>()
                               .ToList();

            var beams = modelObjects
                        .Where(b => b.GetPartMark()
                               .Contains(searchValue))
                        .ToList();

            beams.ForEach(b =>
            {
                var drawer   = new GraphicsDrawer();
                var color    = new Tekla.Structures.Model.UI.Color(1, 1, 1);
                var location = b.GetCoordinateSystem().Origin;
                drawer.DrawText(location, b.GetPartMark(), color);
            });
        }
Ejemplo n.º 4
0
 private static bool CheckFormat(string format, out IBitMatrixDrawer drawer, out ITripMatrixDrawer textDrawer)
 {
     textDrawer = new GraphicsTextDrawer();
     if (format == null)
     {
         LogError("Format required.");
         drawer = null;
         return(false);
     }
     if (format.Equals("svg", StringComparison.OrdinalIgnoreCase))
     {
         drawer = new SvgDrawer();
         return(true);
     }
     if (format.Equals("gif", StringComparison.OrdinalIgnoreCase))
     {
         drawer = new Rgb24BitmapDrawer();
         return(true);
     }
     if (format.Equals("png", StringComparison.OrdinalIgnoreCase))
     {
         drawer = new GraphicsDrawer();
         return(true);
     }
     if (format.Equals("txt", StringComparison.OrdinalIgnoreCase))
     {
         textDrawer = new GraphicsTextDrawer();
         drawer     = new GraphicsDrawer();
         return(true);
     }
     LogError("Format not supported.");
     drawer     = null;
     textDrawer = null;
     return(false);
 }
Ejemplo n.º 5
0
        private static void DrawMesh(Plane plane)
        {
            GraphicsDrawer graphicsDrawer = new GraphicsDrawer();

            Mesh  mesh   = new Mesh();
            Point Point1 = new Point(plane.Origin);

            Vector NormalX = plane.AxisX.GetNormal() * 300;

            Point Point2 = new Point(plane.Origin);

            Point2.Translate(NormalX.X, NormalX.Y, NormalX.Z);

            Vector NormalY = plane.AxisY.GetNormal() * 300;

            Point Point3 = new Point(plane.Origin);

            Point3.Translate(NormalY.X, NormalY.Y, NormalY.Z);

            Point Point4 = new Point(Point2);

            Point4.Translate(NormalY.X, NormalY.Y, NormalY.Z);

            mesh.AddPoint(Point1);
            mesh.AddPoint(Point2);
            mesh.AddPoint(Point3);
            mesh.AddPoint(Point4);

            mesh.AddTriangle(0, 1, 2);
            mesh.AddTriangle(2, 1, 0);
            mesh.AddTriangle(1, 2, 3);
            mesh.AddTriangle(3, 2, 1);

            graphicsDrawer.DrawMeshSurface(mesh, new Color(1, 0, 0));
        }
Ejemplo n.º 6
0
        public void PlaneShow(CoordinateSystem cs, int lng = 1000)
        {
            Model.GetWorkPlaneHandler()
            .SetCurrentTransformationPlane(new TransformationPlane(cs));

            Model.CommitChanges();
            ViewHandler.SetRepresentation("standard");
            var   p  = cs.Origin;
            Point p1 = new Point(p.X + lng, p.Y - lng);
            Point p2 = new Point(p.X + lng, p.Y + lng);
            Point p3 = new Point(p.X - lng, p.Y + lng);
            Point p4 = new Point(p.X - lng, p.Y - lng);

            //var trPlane = new TransformationPlane();
            //Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(trPlane);
            GraphicsDrawer GraphicsDrawer = new GraphicsDrawer();
            Color          _color         = new Color(1, 0, 0);

            GraphicsDrawer.DrawLineSegment(p1, p2, _color); Txt(p1, "p1");
            GraphicsDrawer.DrawLineSegment(p2, p3, _color); Txt(p2, "p2");
            GraphicsDrawer.DrawLineSegment(p3, p4, _color); Txt(p3, "p3");
            GraphicsDrawer.DrawLineSegment(p4, p1, _color); Txt(p4, "p4");

            Model.GetWorkPlaneHandler()
            .SetCurrentTransformationPlane(new TransformationPlane());

            ReperShow(cs);
        }
Ejemplo n.º 7
0
        public override void Initialize()
        {
            base.Initialize();

            skyBounds = new Rectangle(
                GraphicsDevice.Viewport.X,
                GraphicsDevice.Viewport.Y,
                GraphicsDevice.Viewport.Width,
                GraphicsDevice.Viewport.Height);

            SetAltitude(0);

            drawer = new GraphicsDrawer(GraphicsDevice);
            drawer.Initialize();

            Random random = new Random();
            List <GraphicsDrawer.IDrawable> stars = new List <GraphicsDrawer.IDrawable>();

            for (int index = 0; index < numberOfStars; ++index)
            {
                float   size     = random.Next(starSizeMin, starSizeMax);
                Vector3 position = new Vector3(random.Next(0, skyBounds.Width), random.Next(0, skyBounds.Height), 0f);

                stars.Add(new GraphicsDrawer.Ellipse(position, size, size, 0f, 6, Color.LightYellow));
            }
            startBufferID = drawer.CreateBuffer <GraphicsDrawer.IDrawable>(stars);
        }
        public void CK10_SetWorkplane()
        {
            // Reset the workplane back to global
            Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane());

            Picker Picker     = new Picker();
            Part   PickedPart = null;

            try
            {
                PickedPart = Picker.PickObject(Picker.PickObjectEnum.PICK_ONE_PART) as Part;
            }
            catch { PickedPart = null; }
            if (PickedPart != null)
            {
                // Change the workplane to the coordinate system of the plate
                var psk = new TransformationPlane(PickedPart.GetCoordinateSystem());
                Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(psk);

                // Show the plate in the model and the workplane change
                Model.CommitChanges();

                // Draw Positive Z axis.
                GraphicsDrawer Drawer = new GraphicsDrawer();
                var            red    = new Color(1, 0, 0);
                Drawer.DrawLineSegment(new T3D.Point(0, 0, 0), new T3D.Point(0, 0, 500), red);
            }
        }
 public static dynamic GetTSObject(GraphicsDrawer dynObject)
 {
     if (dynObject is null)
     {
         return(null);
     }
     return(dynObject.teklaObject);
 }
Ejemplo n.º 10
0
        public static void DrawCoordinates()
        {
            GraphicsDrawer graphicsDrawer = new GraphicsDrawer();

            graphicsDrawer.DrawLineSegment(new Point(0.0, 0.0, 0.0), new Point(1000.0, 0.0, 0.0), new Color(1.0, 0.0, 0.0));
            graphicsDrawer.DrawLineSegment(new Point(0.0, 0.0, 0.0), new Point(0.0, 3000.0, 0.0), new Color(0.0, 1.0, 0.0));
            graphicsDrawer.DrawLineSegment(new Point(0.0, 0.0, 0.0), new Point(0.0, 0.0, 9000.0), new Color(0.0, 0.0, 1.0));
        }
Ejemplo n.º 11
0
            public static void Run()
            {
                var pickedObjects = new Picker().PickObjects(Picker.PickObjectsEnum.PICK_N_PARTS);

                if (pickedObjects.GetSize() < 1)
                {
                    return;
                }

                while (pickedObjects.MoveNext())
                {
                    var part = pickedObjects.Current as Part;

                    if (part == null)
                    {
                        continue;
                    }

                    var origin = part.GetCoordinateSystem().Origin;
                    var axisX  = part.GetCoordinateSystem().AxisX;
                    var normal = axisX.GetNormal();
                    var length = axisX.GetLength();

                    double height = 0;
                    part.GetReportProperty("HEIGHT", ref height);

                    string topLevel = string.Empty;
                    part.GetReportProperty("TOP_LEVEL", ref topLevel);

                    var midPoint = new Point(
                        origin.X + normal.X * length / 2,
                        origin.Y + normal.Y * length / 2,
                        origin.Z + normal.Z * length / 2
                        );

                    var markPoint = new Point(midPoint);
                    markPoint.Z += height / 2 + 250;

                    var profilePoint = new Point(markPoint);
                    profilePoint.Z -= 100;

                    var levelPoint = new Point(markPoint);
                    levelPoint.Z -= 200;

                    var partMark = part.GetPartMark();

                    var drawer = new GraphicsDrawer();
                    var color  = new Color(1, 1, 1);

                    drawer.DrawText(markPoint, partMark, color);
                    drawer.DrawText(profilePoint, part.Profile.ProfileString, color);
                    drawer.DrawText(levelPoint, topLevel, color);

                    drawer.DrawLineSegment(midPoint, markPoint, color);
                }
            }
        public void CK10_ApplyFitting()
        {
            // Current Workplane. Reminder how the user had the model before you did stuff.
            TransformationPlane CurrentPlane = Model.GetWorkPlaneHandler().GetCurrentTransformationPlane();

            Picker Picker     = new Picker();
            Beam   PickedBeam = null;

            try
            {
                PickedBeam = (Beam)Picker.PickObject(Picker.PickObjectEnum.PICK_ONE_PART);
            }
            catch { PickedBeam = null; }
            if (PickedBeam != null)
            {
                // Change the workplane to the coordinate system of the Beam
                var psk = new TransformationPlane(PickedBeam.GetCoordinateSystem());
                Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(psk);

                // Applyfitting
                Fitting BeamFitting = new Fitting();
                BeamFitting.Father = PickedBeam;
                Plane FittingPlane = new Plane();
                FittingPlane.Origin = new T3D.Point(500, 0, 0);
                FittingPlane.AxisX  = new T3D.Vector(0, 0, 500);
                FittingPlane.AxisY  = new T3D.Vector(0, -500, 0);
                BeamFitting.Plane   = FittingPlane;
                BeamFitting.Insert();

                // Apply Line Cut
                CutPlane BeamLineCut = new CutPlane();
                BeamLineCut.Father = PickedBeam;
                Plane BeamCutPlane = new Plane();
                BeamCutPlane.Origin = new T3D.Point(200, 0, 0);
                BeamCutPlane.AxisX  = new T3D.Vector(0, 0, 500);
                // Changing the positive vs. negative value here determines which direction
                // the line cut will take away material where as fitting looks at which end
                // of beam it is closest to figure out how to cut.
                BeamCutPlane.AxisX = new T3D.Vector(0, -500, 0);
                BeamLineCut.Plane  = BeamCutPlane;
                BeamLineCut.Insert();

                // SetWorkplane back to what user had before
                Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(CurrentPlane);

                // Show the plate in the model and the workplane change
                Model.CommitChanges();

                // Draw Positive Z axis.
                GraphicsDrawer Drawer = new GraphicsDrawer();
                var            red    = new Color(1, 0, 0);
                Drawer.DrawLineSegment(new T3D.Point(0, 0, 0), new T3D.Point(0, 0, 500), red);
            }
            Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane());
        }
Ejemplo n.º 13
0
        override public void CreateMapObject(Point?position)
        {
            var r = GameManager.Random;

            if (!position.HasValue)
            {
                position = new System.Windows.Point(r.Next(0, 700), r.Next(0, 500));                 // TODO remove hardcoded valus
            }
            Position = position.Value;
            var color = System.Windows.Media.Color.FromRgb((byte)r.Next(0, 256), (byte)r.Next(0, 256), (byte)r.Next(0, 256));

            Shape = GraphicsDrawer.CreateNewEllipse(50, color, Position);
        }
        public void CK07_Column()
        {
            // Create Column after Pick a Point of this column
            T3D.Point FirstPoint = null;
            Picker    Picker     = new Picker();

            try
            {
                ArrayList PickedPoints = Picker.PickPoints(Picker.PickPointEnum.PICK_ONE_POINT);
                FirstPoint = PickedPoints[0] as T3D.Point;
            }
            catch { FirstPoint = null; }
            if (FirstPoint != null)
            {
                T3D.Point SecondPoint = new T3D.Point(FirstPoint.X, FirstPoint.Y, FirstPoint.Z + 8000);
                Beam      ThisBeam    = CreateBeam("MyColumn", mw.prfStr, FirstPoint, SecondPoint);
                ThisBeam.Finish = "D";
                ThisBeam.Class  = "7";
                ThisBeam.AssemblyNumber.Prefix      = "C";
                ThisBeam.AssemblyNumber.StartNumber = 1;
                ThisBeam.Position.Depth             = Position.DepthEnum.MIDDLE;
                ThisBeam.Position.Plane             = Position.PlaneEnum.MIDDLE;
                ThisBeam.Position.Rotation          = Position.RotationEnum.TOP;
                ThisBeam.Modify();
                //ThisBeam.SetUserProperty("USER_FIELD_1", "PEOPLE");
                //string UserField = "";
                //ThisBeam.GetUserProperty("USER_FIELD_1", ref UserField);
                //Solid BeamSolid = ThisBeam.GetSolid();
                T3D.CoordinateSystem  BeamCoordinateSystem = ThisBeam.GetCoordinateSystem();
                Assembly              BeamAssembly         = ThisBeam.GetAssembly();
                ModelObjectEnumerator BeamsBolt            = ThisBeam.GetBolts();
                ReperShow(BeamCoordinateSystem);
                Model.CommitChanges();

                Matrix         FromColumnSystem = MatrixFactory.FromCoordinateSystem(ThisBeam.GetCoordinateSystem());
                T3D.Point      FrontFacePoint   = FromColumnSystem.Transform(new T3D.Point(50, 50, 500));
                GraphicsDrawer Drawer           = new GraphicsDrawer();
                // Label for Front Face
                var label = new Color(0, 0, 0);
                Drawer.DrawLineSegment(new LineSegment(FirstPoint, FrontFacePoint), label);
                Drawer.DrawText(FrontFacePoint, "THIS IS FRONT FACE", label);

                mw.Msg("В выбранной точке создается колонна с осью Х ПСК, направленой вверх."
                       + " Профиль колонны как в поле TextBox выше. Черная надпись показывает"
                       + "  переднюю грань.      [ОК]");
                MessageBox.Show("Создал колонну и вывел репер, указал переднюю грань");
                mw.Msg();
            }
        }
Ejemplo n.º 15
0
		protected override void Initialize() {
			IsMouseVisible = true;

			graphics.PreferredBackBufferHeight = 600;
			graphics.PreferredBackBufferWidth = 800;
			graphics.IsFullScreen = false;
			graphics.ApplyChanges();

			gd = new GraphicsDrawer(GraphicsDevice);

			controlPoints = new List<Vector3>();
			curvePoints = new Vector3[0];

			base.Initialize();

			#region Properties initialization

			#region Drawing properties

			// General properties
			BackgroundColor = Color.Black;
			ForegroundColor = Color.White;

			// Control line properties
			IsControlLinesDrawing = true;
			ControlLineColor = Color.LightGray;
			ControlLineSelectedColor = Color.Orange;

			// Control point properties
			IsControlPointsDrawing = true;
			ControlPointColor = Color.Gray;
			ControlPointSelectedColor = Color.Orange;

			// Curve line properties
			IsCurveLinesDrawing = true;
			CurveLineColor = Color.YellowGreen;

			// Curve point properties
			IsCurvePointsDrawing = true;
			CurvePointColor = Color.DarkGreen;

			#endregion

			#endregion
		}
Ejemplo n.º 16
0
        /// <summary>
        /// Generates tilemap from which game background is drawn.
        /// </summary>
        public static Map GetStandardMap()
        {
            int  cols           = 20;
            int  rows           = 12;
            Size tileSizeScaled = new Size(FormBambulanci.WidthStatic / cols, FormBambulanci.HeightStatic / rows);
            Map  result         = new Map(cols, rows, tileSizeScaled);

            Bitmap tileAtlas = Properties.Resources.standardTileAtlas;
            int    atlasCols = 6;
            int    tileCount = 24;
            Size   tileSize  = new Size(48, 48);

            result.tiles = new Bitmap[tileCount];
            for (int i = 0; i < tileCount; i++)
            {
                int x = i % atlasCols * tileSize.Width;
                int y = i / atlasCols * tileSize.Height;

                Rectangle cloneRect  = new Rectangle(x, y, tileSize.Width, tileSize.Height);
                Bitmap    tile       = tileAtlas.Clone(cloneRect, tileAtlas.PixelFormat);
                Bitmap    tileScaled = GraphicsDrawer.ResizeImage(tile, result.tileSizeScaled.Width, result.tileSizeScaled.Height);

                result.tiles[i] = tileScaled;
            }

            result.grid = new int[, ]
            {
                { 7, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 6 },
                { 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19 },
                { 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19 },
                { 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19 },
                { 21, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19 },
                { 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19 },
                { 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 19 },
                { 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19 },
                { 21, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19 },
                { 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19 },
                { 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19 },
                { 9, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 8 },
            };
            result.wallTiles = new int[] { 6, 7, 8, 9, 18, 19, 20, 21, 15 };
            return(result);
        }
Ejemplo n.º 17
0
        public void ReperShow(CoordinateSystem beamCoordinateSystem, int lng = 1000)
        {
            var trPlane = new TransformationPlane();

            Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(trPlane);
            GraphicsDrawer GraphicsDrawer = new GraphicsDrawer();
            Color          _color         = new Color(1, 0, 0);
            Point          p  = beamCoordinateSystem.Origin;
            Vector         aX = beamCoordinateSystem.AxisX.GetNormal();
            Vector         aY = beamCoordinateSystem.AxisY.GetNormal();
            Vector         aZ = Vector.Cross(aX, aY);
            Point          pX = PointAddVector(p, aX, lng);
            Point          pY = PointAddVector(p, aY, lng);
            Point          pZ = PointAddVector(p, aZ, lng);

            GraphicsDrawer.DrawLineSegment(p, pX, _color); Txt(pX, "X");
            GraphicsDrawer.DrawLineSegment(p, pY, _color); Txt(pY, "Y");
            GraphicsDrawer.DrawLineSegment(p, pZ, _color); Txt(pZ, "Z");
        }
Ejemplo n.º 18
0
        private void displayBoltsInModel_Click(object sender, EventArgs e)
        {
            if (!_boltResults.Any())
            {
                return;
            }

            var row = dataGridViewResults.CurrentRow?.DataBoundItem as BoltView;

            var result = _boltResults.Where(b => Math.Round(b.BoltSize, 2).ToString() == row.Size &&
                                            b.BoltStandard == row.Standard &&
                                            b.BoltType == row.Type).ToList();

            var drawer = new GraphicsDrawer();

            result.ForEach(b =>
            {
                var location = b.FirstPosition;
                var color    = new Color(1, 1, 1);
                var text     = $"{Math.Round(b.BoltSize, 2)} {b.BoltStandard} {b.BoltType}";
                drawer.DrawText(location, text, color);
            });
        }
        private static void DrawMesh(Face face)
        {
            GraphicsDrawer graphicsDrawer = new GraphicsDrawer();
            Mesh           mesh           = new Mesh();
            LoopEnumerator loops          = face.GetLoopEnumerator();

            loops.MoveNext();
            Loop             loop     = loops.Current as Loop;
            VertexEnumerator vertexes = loop.GetVertexEnumerator();

            while (vertexes.MoveNext())
            {
                mesh.AddPoint(vertexes.Current as Point);
            }

            for (int index = 0; index < mesh.Points.Count - 2; index++)
            {
                mesh.AddTriangle(index, index + 1, index + 2);
                mesh.AddTriangle(index + 2, index + 1, index);
            }

            graphicsDrawer.DrawMeshSurface(mesh, new Color(1, 0, 0));
        }
Ejemplo n.º 20
0
        static void Main(string[] args)
        {
            var connection = new Picker()
                             .PickObject(Picker.PickObjectEnum.PICK_ONE_OBJECT) as Connection;

            if (connection == null)
            {
                return;
            }

            var children = GetModelObjectsAsList(connection.GetChildren());

            var drawer = new GraphicsDrawer();
            var color  = new Color(0, 1, 1);

            children.ForEach(c =>
            {
                var part     = c as Part;
                var location = part?.GetCenterLine(false)[0] as Point;
                var partMark = part?.GetPartMark();
                drawer.DrawText(location, partMark, color);
            });
        }
Ejemplo n.º 21
0
 public void Txt(Point point, string text, string color = RED)
 => GraphicsDrawer.DrawText(point, text, setColor(color));
        public override bool Run(List <InputDefinition> input)
        {
            try
            {
                var connection = Model.SelectModelObject((Identifier)input[0].GetInput()) as Connection;
                if (connection == null)
                {
                    return(false);
                }

                connection.GetPhase(out Phase phase);

                var parts = connection.GetChildren().ToList().OfType <Part>().ToList();
                var part  = parts[0];
                if (part == null)
                {
                    MessageBox.Show("Not a part " + parts.Count);
                }

                var newPartNumberPrefix     = Data.PhaseNumber + Data.PartPrefix;
                var newAssemblyNumberPrefix = Data.PhaseNumber + Data.AssemblyPrefix;

                var newPartStartNumber     = Data.PhaseNumber + Data.PartStartNumber;
                var newAssemblyStartNumber = Data.PhaseNumber + Data.AssemblyStartNumber;

                if (part.PartNumber.Prefix != newPartNumberPrefix)
                {
                    part.PartNumber.Prefix = newPartNumberPrefix;
                    part.Modify();
                }

                if (part.AssemblyNumber.Prefix != newAssemblyNumberPrefix)
                {
                    part.AssemblyNumber.Prefix = newAssemblyNumberPrefix;
                    part.Modify();
                }

                if (part.PartNumber.StartNumber != newPartStartNumber)
                {
                    part.PartNumber.StartNumber = newPartStartNumber;
                    part.Modify();
                }

                if (part.AssemblyNumber.StartNumber != newAssemblyStartNumber)
                {
                    part.AssemblyNumber.StartNumber = newAssemblyStartNumber;
                    part.Modify();
                }

                var partNumber = part.GetPartMark();

                var drawer = new GraphicsDrawer();
                drawer.DrawText(connection.GetCoordinateSystem().Origin, $"{part.PartNumber.Prefix} : {part.AssemblyNumber.Prefix} : {partNumber}",
                                new Color(1, 1, 1));

                return(true);
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.ToString());
            }

            return(true);
        }
Ejemplo n.º 23
0
 public void Line(Point p1, Point p2, string color = "red")
 => GraphicsDrawer.DrawLineSegment(p1, p2, setColor(color));
Ejemplo n.º 24
0
        protected override void LoadContent()
        {
            this.log.WriteInformation("Loading content...");

            GraphicsDevice.DeviceReset += (s, e) => LoadContent();

            gd = new GraphicsDrawer(GraphicsDevice) {
                DebugFont = Game.Content.Load<SpriteFont>("Fonts/DebugFont")
            };

            GenerateContent();

            base.LoadContent();

            this.log.WriteInformation("Content loaded!");
        }
Ejemplo n.º 25
0
        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();
                }
            }
        }
Ejemplo n.º 26
0
        public static void Main(string[] args)
        {
            var model          = new Model();
            var graphicsDrawer = new GraphicsDrawer();
            var picker         = new Picker();
            var red            = new Color(1, 0, 0);
            var white          = new Color(1, 1, 1);
            var blue           = new Color(0, 0, 1);
            var green          = new Color(0, 1, 0);
            var black          = new Color(0, 0, 0);

            try
            {
                var savedPlane = model.GetWorkPlaneHandler().GetCurrentTransformationPlane();
                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane());

                var part1 = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_PART, "Pick Part") as Part;
                var solid = part1.GetSolid();

                var maximumPoint = solid.MaximumPoint;
                var minimumPoint = solid.MinimumPoint;

                graphicsDrawer.DrawText(maximumPoint, maximumPoint.ToString(), white);
                graphicsDrawer.DrawText(minimumPoint, maximumPoint.ToString(), white);

                var part2 = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_PART, "Pick Part") as Part;

                var part2CoordinateSystem = part2.GetCoordinateSystem();
                var origin     = part2CoordinateSystem.Origin;
                var xDirection = origin + part2CoordinateSystem.AxisX;
                var yDirection = origin + part2CoordinateSystem.AxisY;

                var xAxis = new LineSegment(origin, xDirection);
                var yAxis = new LineSegment(origin, yDirection);

                graphicsDrawer.DrawLineSegment(xAxis, blue);
                graphicsDrawer.DrawLineSegment(yAxis, red);

                graphicsDrawer.DrawText(origin, "ORIGIN", white);
                graphicsDrawer.DrawText(xDirection, "XAXIS", blue);
                graphicsDrawer.DrawText(yDirection, "YAXIS", red);


                var intersectionPoints = solid.GetAllIntersectionPoints(part2CoordinateSystem.Origin, part2CoordinateSystem.AxisX, part2CoordinateSystem.AxisY);

                while (intersectionPoints.MoveNext())
                {
                    var point = intersectionPoints.Current as Point;
                    graphicsDrawer.DrawText(point, point.ToString(), green);
                }

                var plane = new Plane()
                {
                    Origin = origin,
                    AxisX  = part2CoordinateSystem.AxisX,
                    AxisY  = part2CoordinateSystem.AxisY,
                };

                var cut = new CutPlane()
                {
                    Father     = part1,
                    Identifier = new Identifier(new Guid()),
                    Plane      = plane,
                };

                cut.Insert();
                model.CommitChanges();

                var part2Centerline = part2.GetCenterLine(false);
                var intersect       = solid.Intersect(new LineSegment(part2Centerline[0] as Point, part2Centerline[1] as Point));

                var point1 = intersect[0] as Point;
                var point2 = intersect[1] as Point;

                graphicsDrawer.DrawText(point1, "POINT1", red);
                graphicsDrawer.DrawText(point2, "POINT2", blue);

                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(savedPlane);

                var currentViews = ViewHandler.GetAllViews();
                while (currentViews.MoveNext())
                {
                    var currentView = currentViews.Current;
                    currentView.Select();
                    currentView.VisibilitySettings.WeldsVisible                = false;
                    currentView.VisibilitySettings.WeldsVisibleInComponents    = false;
                    currentView.VisibilitySettings.ComponentsVisible           = false;
                    currentView.VisibilitySettings.FittingsVisible             = false;
                    currentView.VisibilitySettings.FittingsVisibleInComponents = false;
                    currentView.Modify();
                }

                var faces    = picker.PickFace("Pick Face");
                var vertices = faces.OfType <InputItem>().ToList()[1].GetData() as ArrayList;
                foreach (Point vertex in vertices)
                {
                    graphicsDrawer.DrawText(vertex, vertex.ToString(), black);
                }

                plane = new Plane
                {
                    Origin = vertices[0] as Point,
                    AxisX  = new Vector((vertices[1] as Point) - (vertices[0] as Point)),
                    AxisY  = new Vector((vertices[2] as Point) - (vertices[0] as Point)),
                };

                cut = new CutPlane
                {
                    Father     = part1,
                    Identifier = new Identifier(new Guid()),
                    Plane      = plane,
                };

                cut.Insert();
                model.CommitChanges();
            }
            catch (Exception ex)
            {
                // ignored
            }
        }
Ejemplo n.º 27
0
        protected override void LoadContent()
        {
            this.log.WriteInformation("Loading content...");

            GraphicsDevice.DeviceReset += (s, e) => LoadContent();

            camera.OnMoved += (cameraSender, cameraEvents) => RecalculateCameraPosition(cameraEvents.Position);

            gd = new GraphicsDrawer(GraphicsDevice) {
                DebugFont = Game.Content.Load<SpriteFont>("Fonts/DebugFont")
            };

            GenerateContent();

            camera.MoveTo(Vector3.One);

            base.LoadContent();

            this.log.WriteInformation("Content loaded!");
        }
Ejemplo n.º 28
0
 private void painBoxForGraphics_Paint(object sender, PaintEventArgs e)
 {
     GraphicsDrawer.Draw(e.Graphics, _pointsList);
 }