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

        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);
        }
示例#2
0
        //--------------------------------------------------------------------------------------------------

        #endregion

        #region ISketchImporter

        bool ISketchImporter.DoImport(string fileName, out IDictionary <int, Pnt2d> points, out IDictionary <int, SketchSegment> segments, out IEnumerable <SketchConstraint> constraints)
        {
            points      = null;
            segments    = null;
            constraints = null;
            bool result = false;

            using (new ProcessingScope(null, "Importing sketch from DXF"))
            {
                if (_ReadFromFile(fileName, out var content))
                {
                    result = DxfSketchImporter.Import(content, out points, out segments,
                                                      _GetFlags(), Settings.ImportMergePointPrecision, DxfUtils.GetImportScaleValue(Settings.ImportScaling));
                }
            }

            return(result);
        }