//--------------------------------------------------------------------------------------------------

        void _ReadFromBytes(byte[] bytes, Sketch sketch, bool replace, DxfFlags flags = DxfFlags.None, double scale = 1.0)
        {
            Assert.IsTrue(DxfSketchImporter.Import(new MemoryStream(bytes), out var points, out var segments, flags, 0.01, scale));

            if (replace && points?.Count > 0)
            {
                sketch.Clear();
            }
            sketch.AddElements(points, null, segments, null);
        }
Example #2
0
        //--------------------------------------------------------------------------------------------------

        void _ReadFromBytes(byte[] bytes, Sketch sketch, bool replace)
        {
            Assert.IsTrue(SvgSketchImporter.Import(new MemoryStream(bytes), out var points, out var segments));

            if (replace && points?.Count > 0)
            {
                sketch.Clear();
            }
            sketch.AddElements(points, null, segments, null);
        }
Example #3
0
        //--------------------------------------------------------------------------------------------------

        public void FinishSegmentCreation(Dictionary <int, Pnt2d> points, int[] mergePointIndices, IEnumerable <SketchSegment> segments, IEnumerable <SketchConstraint> constraints, int continueWithPoint = -1)
        {
            var(pointMap, segmentMap, _) = Sketch.AddElements(points, mergePointIndices, segments.ToIndexedDictionary(), constraints);
            InteractiveContext.Current.UndoHandler.Commit();
            WorkspaceController.UpdateSelection();

            if (_ContinuesSegmentCreation && continueWithPoint >= 0 && pointMap.ContainsKey(continueWithPoint))
            {
                (CurrentTool as ISketchSegmentCreator)?.Continue(pointMap[continueWithPoint]);
            }
            else
            {
                StopTool();
                Elements.DeselectAll();
                Elements.Select(null, segmentMap.Values);
                _UpdateSelections();
            }
        }
Example #4
0
        //--------------------------------------------------------------------------------------------------

        public List <SketchConstraint> CreateConstraint <T>() where T : SketchConstraint
        {
            if (!CanCreateConstraint <T>())
            {
                return(null);
            }

            var constraints = SketchConstraintCreator.Create <T>(Sketch, SelectedPoints, SelectedSegmentIndices);

            if (constraints != null)
            {
                Sketch.AddElements(null, null, null, constraints);
                Sketch.SolveConstraints(false);
                Sketch.SolveConstraints(true);
                InteractiveContext.Current.UndoHandler.Commit();

                _MoveAction?.Stop();
                Elements.DeselectAll();
                Elements.Select(constraints);
                _UpdateSelections();
            }

            return(constraints);
        }