예제 #1
0
        private static void RemoveVertexFromCurrentWipeout(ObjectId wipeoutId)
        {
            var doc = Application.DocumentManager.MdiActiveDocument;
            var ed  = doc.Editor;

            var loop = true;

            while (loop)
            {
                using (doc.LockDocument())
                {
                    using (var tr = doc.TransactionManager.StartTransaction())
                    {
                        var wipeout = tr.GetObject(wipeoutId, OpenMode.ForWrite) as Wipeout;
                        if (wipeout != null)
                        {
                            var points3D = wipeout.GetVertices();
                            if (points3D.Count > 3)
                            {
                                var polyline = new Polyline();
                                for (var i = 0; i < points3D.Count; i++)
                                {
                                    polyline.AddVertexAt(i, new Point2d(points3D[i].X, points3D[i].Y), 0.0, 0.0, 0.0);
                                }

                                var pickedPt = ed.GetPoint($"\n{Language.GetItem(LangItem, "msg22")}:");
                                if (pickedPt.Status != PromptStatus.OK)
                                {
                                    loop = false;
                                }
                                else
                                {
                                    var pt     = polyline.GetClosestPointTo(pickedPt.Value, false);
                                    var param  = polyline.GetParameterAtPoint(pt);
                                    var vertex = Convert.ToInt32(Math.Truncate(param));
                                    polyline.RemoveVertexAt(vertex);
                                    var new2DPoints = new Point2dCollection();
                                    for (var i = 0; i < polyline.NumberOfVertices; i++)
                                    {
                                        new2DPoints.Add(polyline.GetPoint2dAt(i));
                                    }

                                    wipeout.SetFrom(new2DPoints, polyline.Normal);
                                }
                            }
                            else
                            {
                                // message
                                loop = false;
                            }
                        }

                        tr.Commit();
                    }
                }
            }
        }
예제 #2
0
            protected override bool WorldDraw(WorldDraw draw)
            {
                var mods    = System.Windows.Forms.Control.ModifierKeys;
                var control = (mods & System.Windows.Forms.Keys.Control) > 0;
                var pt      = _polyline.GetClosestPointTo(_currentPoint, false);
                var param   = _polyline.GetParameterAtPoint(pt);

                _vertex = Convert.ToInt32(Math.Truncate(param));
                var maxVx = _polyline.NumberOfVertices - 1;

                if (control)
                {
                    if (_vertex < maxVx)
                    {
                        _vertex++;
                    }
                }

                if (_vertex != maxVx)
                {
                    // Если вершина не последня
                    var line1 = new Line(_polyline.GetPoint3dAt(_vertex), _currentPoint)
                    {
                        ColorIndex = PlinesEditFunction.HelpGeometryColor
                    };
                    draw.Geometry.Draw(line1);
                    var line2 = new Line(_polyline.GetPoint3dAt(_vertex + 1), _currentPoint)
                    {
                        ColorIndex = PlinesEditFunction.HelpGeometryColor
                    };
                    draw.Geometry.Draw(line2);
                }
                else
                {
                    var line1 = new Line(_polyline.GetPoint3dAt(_vertex), _currentPoint)
                    {
                        ColorIndex = PlinesEditFunction.HelpGeometryColor
                    };
                    draw.Geometry.Draw(line1);
                    if (_polyline.Closed)
                    {
                        // Если полилиния замкнута, то рисуем отрезок к первой вершине
                        var line2 = new Line(_polyline.GetPoint3dAt(0), _currentPoint)
                        {
                            ColorIndex = PlinesEditFunction.HelpGeometryColor
                        };
                        draw.Geometry.Draw(line2);
                    }
                }

                return(true);
            }