Example #1
0
        private void WriteStream(Stream stream, bool asText)
        {
            var writer = new DxfWriter(stream, asText, Header.Version);

            writer.Initialize();
            WriteSectionsAndClose(writer, Sections);
        }
Example #2
0
        private void WriteSectionsAndClose(DxfWriter writer, IEnumerable <DxfSection> sections)
        {
            var writtenItems  = new HashSet <IDxfItem>();
            var outputHandles = Header.Version >= DxfAcadVersion.R13 || Header.HandlesEnabled; // handles are always enabled on R13+

            foreach (var section in sections)
            {
                foreach (var pair in section.GetValuePairs(Header.Version, outputHandles, writtenItems))
                {
                    writer.WriteCodeValuePair(pair);
                }

                if (section is DxfEntitiesSection)
                {
                    var entitiesSection = (DxfEntitiesSection)section;
                    var addedObjects    = new HashSet <DxfObject>(Objects);
                    foreach (var additionalObject in entitiesSection.AdditionalObjects)
                    {
                        if (additionalObject != null && addedObjects.Add(additionalObject))
                        {
                            Objects.Add(additionalObject);
                        }
                    }
                }
            }

            writer.Close();
        }
Example #3
0
        private void WriteSectionsAndClose(DxfWriter writer, IEnumerable <DxfSection> sections)
        {
            foreach (var pair in GetCodePairs(sections))
            {
                writer.WriteCodeValuePair(pair);
            }

            writer.Close();
        }
Example #4
0
        private DxfWriter PrepareWriter(Stream stream, bool asText)
        {
            UpdateTimes();
            Normalize();

            var writer = new DxfWriter(stream, asText);

            writer.Open();

            var nextHandle = DxfPointer.AssignHandles(this);

            Header.NextAvailableHandle = nextHandle;

            return(writer);
        }
Example #5
0
        private void WriteSectionsAndClose(DxfWriter writer, IEnumerable <DxfSection> sections)
        {
            var writtenItems  = new HashSet <IDxfItem>();
            var outputHandles = Header.Version >= DxfAcadVersion.R13 || Header.HandlesEnabled; // handles are always enabled on R13+

            foreach (var section in sections)
            {
                foreach (var pair in section.GetValuePairs(Header.Version, outputHandles, writtenItems))
                {
                    writer.WriteCodeValuePair(pair);
                }
            }

            writer.Close();
        }
Example #6
0
        private void WriteSectionsAndClose(DxfWriter writer, IEnumerable<DxfSection> sections)
        {
            var writtenItems = new HashSet<IDxfItem>();
            var outputHandles = Header.Version >= DxfAcadVersion.R13 || Header.HandlesEnabled; // handles are always enabled on R13+
            foreach (var section in sections)
            {
                foreach (var pair in section.GetValuePairs(Header.Version, outputHandles, writtenItems))
                {
                    writer.WriteCodeValuePair(pair);
                }
            }

            writer.Close();
        }
Example #7
0
        private DxfWriter PrepareWriter(Stream stream, bool asText)
        {
            UpdateTimes();
            Normalize();

            var writer = new DxfWriter(stream, asText);
            writer.Open();

            var nextHandle = DxfPointer.AssignHandles(this);
            Header.NextAvailableHandle = nextHandle;

            return writer;
        }
Example #8
0
 public override string ToString()
 {
     return($"[{DxfWriter.CodeAsString(Code)}: {Value ?? "<null>"}]");
 }
Example #9
0
File: DxfFile.cs Project: atph/Dxf
        private void WriteStream(Stream stream, bool asText)
        {
            var writer = new DxfWriter(stream, asText);
            writer.Open();

            var nextHandle = SetHandles();
            Header.NextAvailableHandle = nextHandle;

            // write sections
            var outputHandles = Header.Version >= DxfAcadVersion.R13 || Header.HandlesEnabled; // handles are always enabled on R13+
            foreach (var section in Sections)
            {
                foreach (var pair in section.GetValuePairs(Header.Version, outputHandles))
                    writer.WriteCodeValuePair(pair);
            }

            writer.Close();
        }