Esempio n. 1
0
        public Class921(Stream stream, DxfModel model)
        {
            if (!stream.CanSeek || !stream.CanWrite)
            {
                throw new ArgumentException("Stream must allow writing and seeking.");
            }
            this.dxfModel_0   = model;
            this.stream_0     = stream;
            this.dxfVersion_0 = model.Header.AcadVersion;
            this.encoding_0   = Encodings.GetEncoding((int)model.Header.DrawingCodePage);
            Random random = new Random();

            byte[] numArray = new byte[8];
            random.NextBytes(numArray);
            this.class995_0.method_0(LittleEndianBitConverter.ToUInt64(numArray));
            this.uint_0 = 0U;
            this.class954_0.RandomSeed         = this.class995_0.Seed;
            this.class954_0.CrcSeed            = (ulong)this.uint_0;
            this.class954_0.PagesMapCrcSeed    = (ulong)this.uint_0;
            this.class954_0.SectionsMapCrcSeed = (ulong)this.uint_0;
        }
Esempio n. 2
0
 internal static byte[] smethod_0(DxfVersion version, DateTime dateTime)
 {
     byte[] bytes;
     if (version >= DxfVersion.Dxf21)
     {
         bytes = new byte[16];
         DxfValue.smethod_4(bytes, 0, dateTime.Year);
         DxfValue.smethod_4(bytes, 2, dateTime.Month);
         DxfValue.smethod_4(bytes, 4, (int)dateTime.DayOfWeek);
         DxfValue.smethod_4(bytes, 6, dateTime.Day);
         DxfValue.smethod_4(bytes, 8, dateTime.Hour);
         DxfValue.smethod_4(bytes, 10, dateTime.Minute);
         DxfValue.smethod_4(bytes, 12, dateTime.Second);
         DxfValue.smethod_4(bytes, 14, dateTime.Millisecond);
     }
     else
     {
         bytes = DxfValue.smethod_2(dateTime);
     }
     return(bytes);
 }
Esempio n. 3
0
        /// <summary>
        /// Saves a block to a DXF file.
        /// </summary>
        /// <param name="file">DXF file name.</param>
        /// <param name="version">Version of the DXF database version.</param>
        /// <param name="isBinary">Defines if the file will be saved as binary.</param>
        /// <returns>Return true if the file has been successfully save, false otherwise.</returns>
        public bool Save(string file, DxfVersion version, bool isBinary)
        {
            DxfDocument dwg = new DxfDocument(version);

            dwg.DrawingVariables.InsBase  = this.origin;
            dwg.DrawingVariables.InsUnits = this.Record.Units;

            foreach (AttributeDefinition attdef in this.attributes.Values)
            {
                if (!dwg.Layouts[Layout.ModelSpaceName].AssociatedBlock.AttributeDefinitions.ContainsTag(attdef.Tag))
                {
                    dwg.Layouts[Layout.ModelSpaceName].AssociatedBlock.AttributeDefinitions.Add((AttributeDefinition)attdef.Clone());
                }
            }

            foreach (EntityObject entity in this.entities)
            {
                dwg.Layouts[Layout.ModelSpaceName].AssociatedBlock.Entities.Add((EntityObject)entity.Clone());
            }

            return(dwg.Save(file, isBinary));
        }
Esempio n. 4
0
        internal void method_9(
            DxfVersion version,
            Class1026 cell,
            int rowIndex,
            int columnIndex,
            DxfXRecord cellRoundTripData,
            out double checksum,
            out int overrideFlags,
            out int extendedFlags)
        {
            checksum = this.method_10(cell.Value.Format._FormatString);
            byte edgeFlags;
            byte virtualEdgeFlags;
            int  borderTopFlags;
            int  borderRightFlags;
            int  borderBottomFlags;
            int  borderLeftFlags;

            this.method_11(version, cell, rowIndex, columnIndex, out edgeFlags, out virtualEdgeFlags, out overrideFlags, out borderTopFlags, out borderRightFlags, out borderBottomFlags, out borderLeftFlags);
            extendedFlags = cell.ExtendedFlags;
            cell.Value.Write(cellRoundTripData);
        }
Esempio n. 5
0
        public void DxfWriterApp()
        {
            // path of dxf file
            Console.Write("Podaj sciezke do plikow *.dxf (np. C:\\Users\\user\\Desktop\\): ");
            filesPath = Directory.GetFiles(Console.ReadLine(), "*.dxf");

            // object of ExcelReader
            excelText = new ExcelReader();
            string readExcelText = excelText.GetChoosenCellValue(excelRow, excelCol);

            bool isBinary;

            foreach (string file in filesPath)
            {
                // this check is optional but recommended before loading a DXF file
                DxfVersion dxfVersion = DxfDocument.CheckDxfFileVersion(file, out isBinary);
                // netDxf is only compatible with AutoCad2000 and higher DXF version
                if (dxfVersion < DxfVersion.AutoCad2000)
                {
                    return;
                }
                // load file
                dxfDocument = DxfDocument.Load(file);

                entity = new Line(new Vector2(5, 5), new Vector2(10, 5));
                //add an entity here
                dxfDocument.AddEntity(entity);
                // text
                text = new Text(readExcelText, textLocation, 2.0);
                Layer layer = new Layer("text");
                text.Layer     = layer;
                text.Alignment = TextAlignment.BottomLeft;
                dxfDocument.AddEntity(text);
                // save to file
                dxfDocument.Save(file);
            }
        }
Esempio n. 6
0
        private void method_0(int version, DxfVersion outVersion)
        {
            switch (outVersion)
            {
            case DxfVersion.Dxf10:
            case DxfVersion.Dxf10PlusUnofficial:
            case DxfVersion.Dxf12:
            case DxfVersion.Dxf13:
            case DxfVersion.Dxf14:
                this.bool_0 = version <= 106;
                break;

            case DxfVersion.Dxf15:
                this.bool_0 = version <= 400;
                break;

            case DxfVersion.Dxf18:
                this.bool_0 = version <= 20800;
                break;

            case DxfVersion.Dxf21:
                this.bool_0 = version <= 21200;
                break;

            case DxfVersion.Dxf24:
                this.bool_0 = version <= 21500;
                break;

            case DxfVersion.Dxf27:
                this.bool_0 = version <= 21800;
                break;

            default:
                this.bool_0 = false;
                break;
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Initalizes a new instance of the <c>DxfDocument</c> class.
 /// </summary>
 public DxfDocument()
 {
     this.addedObjects     = new Dictionary <object, object>(); // keeps track of the added object to avoid duplicates
     this.version          = DxfVersion.AutoCad2007;
     this.viewports        = new Dictionary <string, ViewPort>();
     this.layers           = new Dictionary <string, Layer>();
     this.lineTypes        = new Dictionary <string, LineType>();
     this.textStyles       = new Dictionary <string, TextStyle>();
     this.blocks           = new Dictionary <string, Block>();
     this.appRegisterNames = new Dictionary <string, ApplicationRegistry>();
     this.dimStyles        = new Dictionary <string, DimensionStyle>();
     this.shaps            = new List <IEntityObject>();
     this.arcs             = new List <Arc>();
     this.ellipses         = new List <Ellipse>();
     this.nurbsCurves      = new List <NurbsCurve>();
     this.faces3d          = new List <Face3d>();
     this.solids           = new List <Solid>();
     this.inserts          = new List <Insert>();
     this.polylines        = new List <IPolyline>();
     this.lines            = new List <Line>();
     this.circles          = new List <Circle>();
     this.points           = new List <Point>();
     this.texts            = new List <Text>();
 }
Esempio n. 8
0
        /// <summary>
        /// Saves the database of the actual DxfDocument to a dxf ASCII file.
        /// </summary>
        /// <param name="file">File name.</param>
        /// <param name="dxfVersion">Dxf file <see cref="DxfVersion">version</see>.</param>
        public void Save(string file, DxfVersion dxfVersion)
        {
            ReAsignHandlersAndDefaultObjects();
            this.fileName = Path.GetFileNameWithoutExtension(file);
            this.version  = dxfVersion;

            List <Polyline>  ellipsePolys = null;
            List <IPolyline> lwPolys;
            Dictionary <string, List <IEntityObject> > blockEntities;

            if (this.version == DxfVersion.AutoCad12)
            {
                // since AutoCad dxf Version 12 doesn't support ellipses, we will transform them in polylines
                ellipsePolys = new List <Polyline>();
                foreach (Ellipse ellipse in this.ellipses)
                {
                    Polyline poly = ellipse.ToPolyline(ellipse.CurvePoints);
                    this.handleCount = poly.AsignHandle(this.handleCount);
                    ellipsePolys.Add(poly);
                }

                // since AutoCad dxf Version 12 doesn't support lwpolylines, we will transform them in polylines
                lwPolys = new List <IPolyline>();
                foreach (IPolyline lwPoly in this.polylines)
                {
                    if (lwPoly is LightWeightPolyline)
                    {
                        Polyline poly = ((LightWeightPolyline)lwPoly).ToPolyline();
                        this.handleCount = poly.AsignHandle(this.handleCount);
                        lwPolys.Add(poly);
                    }
                    else
                    {
                        lwPolys.Add(lwPoly);
                    }
                }

                // since AutoCad dxf Version 12 doesn't support lwpolylines in blocks, we will transform them in polylines
                blockEntities = new Dictionary <string, List <IEntityObject> >();
                foreach (Block block in this.blocks.Values)
                {
                    blockEntities.Add(block.Name, new List <IEntityObject>());
                    foreach (IEntityObject entity in block.Entities)
                    {
                        if (entity is LightWeightPolyline)
                        {
                            Polyline poly = ((LightWeightPolyline)entity).ToPolyline();
                            this.handleCount = poly.AsignHandle(this.handleCount);
                            blockEntities[block.Name].Add(poly);
                        }
                        else
                        {
                            blockEntities[block.Name].Add(entity);
                        }
                    }
                }
            }
            else
            {
                // since AutoCad dxf Version 12 doesn't support lwpolylines, we will transform them in polylines
                lwPolys = new List <IPolyline>();
                foreach (IPolyline lwPoly in this.polylines)
                {
                    if ((lwPoly is Polyline))
                    {
                        LightWeightPolyline poly = ((Polyline)lwPoly).ToLightWeightPolyline();
                        this.handleCount = poly.AsignHandle(this.handleCount);
                        lwPolys.Add(poly);
                    }
                    else
                    {
                        lwPolys.Add(lwPoly);
                    }
                }

                // since latter AutoCad dxf Version doesn't support polylines in blocks, we will transform them in lightweightpolylines
                blockEntities = new Dictionary <string, List <IEntityObject> >();
                foreach (Block block in this.blocks.Values)
                {
                    blockEntities.Add(block.Name, new List <IEntityObject>());
                    foreach (IEntityObject entity in block.Entities)
                    {
                        if (entity is Polyline)
                        {
                            LightWeightPolyline poly = ((Polyline)entity).ToLightWeightPolyline();
                            this.handleCount = poly.AsignHandle(this.handleCount);
                            blockEntities[block.Name].Add(poly);
                        }
                        else
                        {
                            blockEntities[block.Name].Add(entity);
                        }
                    }
                }
            }

            CultureInfo cultureInfo = CultureInfo.CurrentCulture;

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            DxfWriter dxfWriter = new DxfWriter(file, dxfVersion);

            dxfWriter.Open();
            dxfWriter.WriteComment("Dxf file generated by SharpDxf, Copyright(C) 2009 Lomatus, Licensed under LGPL");

            //HEADER SECTION
            dxfWriter.BeginSection(StringCode.HeaderSection);
            dxfWriter.WriteSystemVariable(new HeaderVariable(SystemVariable.DabaseVersion, StringEnum.GetStringValue(this.version)));
            dxfWriter.WriteSystemVariable(new HeaderVariable(SystemVariable.HandSeed, Convert.ToString(this.handleCount, 16)));
            dxfWriter.EndSection();

            ////CLASSES SECTION
            //dxfWriter.BeginSection(StringCode.ClassesSection);
            //dxfWriter.EndSection();

            //TABLES SECTION
            dxfWriter.BeginSection(StringCode.TablesSection);

            //viewport tables
            if (this.version != DxfVersion.AutoCad12)
            {
                dxfWriter.BeginTable(StringCode.ViewPortTable);
                foreach (ViewPort vport in this.viewports.Values)
                {
                    dxfWriter.WriteViewPort(vport);
                }
                dxfWriter.EndTable();
            }

            //line type tables
            dxfWriter.BeginTable(StringCode.LineTypeTable);
            foreach (LineType lineType in this.lineTypes.Values)
            {
                dxfWriter.WriteLineType(lineType);
            }
            dxfWriter.EndTable();

            //layer tables
            dxfWriter.BeginTable(StringCode.LayerTable);
            foreach (Layer layer in this.layers.Values)
            {
                dxfWriter.WriteLayer(layer);
            }
            dxfWriter.EndTable();

            //text style tables
            dxfWriter.BeginTable(StringCode.TextStyleTable);
            foreach (TextStyle style in this.textStyles.Values)
            {
                dxfWriter.WriteTextStyle(style);
            }
            dxfWriter.EndTable();

            //view
            dxfWriter.BeginTable(StringCode.ViewTable);
            dxfWriter.EndTable();

            //ucs
            dxfWriter.BeginTable(StringCode.UcsTable);
            dxfWriter.EndTable();

            //registered application tables
            dxfWriter.BeginTable(StringCode.ApplicationIDTable);
            foreach (ApplicationRegistry id in this.appRegisterNames.Values)
            {
                dxfWriter.RegisterApplication(id);
            }
            dxfWriter.EndTable();

            //dimension style tables
            if (this.version != DxfVersion.AutoCad12)
            {
                dxfWriter.BeginTable(StringCode.DimensionStyleTable);
                foreach (DimensionStyle style in this.dimStyles.Values)
                {
                    dxfWriter.WriteDimensionStyle(style);
                }
                dxfWriter.EndTable();
            }

            //block record tables, this table isnot recognized by AutoCad12
            if (this.version != DxfVersion.AutoCad12)
            {
                dxfWriter.BeginTable(StringCode.BlockRecordTable);
                foreach (Block block in this.blocks.Values)
                {
                    dxfWriter.WriteBlockRecord(block.Record);
                }
                dxfWriter.EndTable();
            }

            dxfWriter.EndSection(); //End section tables

            dxfWriter.BeginSection(StringCode.BlocksSection);
            foreach (Block block in this.blocks.Values)
            {
                dxfWriter.WriteBlock(block, blockEntities[block.Name]);
            }

            dxfWriter.EndSection(); //End section blocks

            //ENTITIES SECTION
            dxfWriter.BeginSection(StringCode.EntitiesSection);

            #region writting entities

            foreach (Arc arc in this.arcs)
            {
                dxfWriter.WriteEntity(arc);
            }
            foreach (Circle circle in this.circles)
            {
                dxfWriter.WriteEntity(circle);
            }

            // only for version 12 draw polylines instead of ellipses
            if (this.version == DxfVersion.AutoCad12)
            {
                if (ellipsePolys != null)
                {
                    foreach (Polyline ellipse in ellipsePolys)
                    {
                        dxfWriter.WriteEntity(ellipse);
                    }
                }
            }
            else
            {
                foreach (Ellipse ellipse  in this.ellipses)
                {
                    dxfWriter.WriteEntity(ellipse);
                }
            }
            foreach (NurbsCurve nurbsCurve  in this.nurbsCurves)
            {
                dxfWriter.WriteEntity(nurbsCurve);
            }
            foreach (Point point in this.points)
            {
                dxfWriter.WriteEntity(point);
            }
            foreach (Face3d face in this.faces3d)
            {
                dxfWriter.WriteEntity(face);
            }
            foreach (Solid solid in this.solids)
            {
                dxfWriter.WriteEntity(solid);
            }
            foreach (Insert insert in this.inserts)
            {
                dxfWriter.WriteEntity(insert);
            }
            foreach (Line line in this.lines)
            {
                dxfWriter.WriteEntity(line);
            }

            // lwpolyline in Acad12 are written as polylines

            foreach (IPolyline pol in lwPolys)
            {
                dxfWriter.WriteEntity(pol);
            }

            //foreach (IPolyline polyline in this.polylines)
            //{
            //    // avoid write lwpolylines in Acad12
            //    if (this.version != DxfVersion.AutoCad12 || !(polyline is LightWeightPolyline))
            //    {
            //        dxfWriter.WriteEntity(polyline);
            //    }
            //}

            foreach (Text text in this.texts)
            {
                dxfWriter.WriteEntity(text);
            }
            #endregion

            dxfWriter.EndSection(); //End section entities

            //OBJECTS SECTION
            dxfWriter.BeginSection(StringCode.ObjectsSection);
            dxfWriter.WriteDictionary(Dictionary.Default);
            dxfWriter.EndSection();

            dxfWriter.Close();

            Thread.CurrentThread.CurrentCulture = cultureInfo;
        }
        public static DxfDocument Test(string file, string output = null)
        {
            // optionally you can save the information to a text file
            bool       outputLog = !string.IsNullOrEmpty(output);
            TextWriter writer    = null;

            if (outputLog)
            {
                writer = new StreamWriter(File.Create(output));
                Console.SetOut(writer);
            }

            // check if the dxf actually exists
            FileInfo fileInfo = new FileInfo(file);

            if (!fileInfo.Exists)
            {
                Console.WriteLine("THE FILE {0} DOES NOT EXIST", file);
                Console.WriteLine();

                if (outputLog)
                {
                    writer.Flush();
                    writer.Close();
                }
                else
                {
                    Console.WriteLine("Press a key to continue...");
                    Console.ReadLine();
                }
                return(null);
            }
            bool       isBinary;
            DxfVersion dxfVersion = DxfDocument.CheckDxfFileVersion(file, out isBinary);

            // check if the file is a dxf
            if (dxfVersion == DxfVersion.Unknown)
            {
                Console.WriteLine("THE FILE {0} IS NOT A VALID DXF OR THE DXF DOES NOT INCLUDE VERSION INFORMATION IN THE HEADER SECTION", file);
                Console.WriteLine();

                if (outputLog)
                {
                    writer.Flush();
                    writer.Close();
                }
                else
                {
                    Console.WriteLine("Press a key to continue...");
                    Console.ReadLine();
                }
                return(null);
            }

            // check if the dxf file version is supported
            if (dxfVersion < DxfVersion.AutoCad2000)
            {
                Console.WriteLine("THE FILE {0} IS NOT A SUPPORTED DXF", file);
                Console.WriteLine();

                Console.WriteLine("FILE VERSION: {0}", dxfVersion);
                Console.WriteLine();

                if (outputLog)
                {
                    writer.Flush();
                    writer.Close();
                }
                else
                {
                    Console.WriteLine("Press a key to continue...");
                    Console.ReadLine();
                }
                return(null);
            }

            // DxfDocument dxf = DxfDocument.Load(file, new List<string> { @".\Support" });
            DxfDocument dxf = DxfDocument.Load(file);

            // check if there has been any problems loading the file,
            // this might be the case of a corrupt file or a problem in the library
            if (dxf == null)
            {
                Console.WriteLine("ERROR LOADING {0}", file);
                Console.WriteLine();

                Console.WriteLine("Press a key to continue...");
                Console.ReadLine();

                if (outputLog)
                {
                    writer.Flush();
                    writer.Close();
                }
                else
                {
                    Console.WriteLine("Press a key to continue...");
                    Console.ReadLine();
                }
                return(null);
            }

            // the dxf has been properly loaded, let's show some information about it
            Console.WriteLine("FILE NAME: {0}", file);
            Console.WriteLine("\tbinary dxf: {0}", isBinary);
            Console.WriteLine();
            Console.WriteLine("FILE VERSION: {0}", dxf.DrawingVariables.AcadVer);
            Console.WriteLine();
            Console.WriteLine("FILE COMMENTS: {0}", dxf.Comments.Count);
            foreach (var o in dxf.Comments)
            {
                Console.WriteLine("\t{0}", o);
            }
            Console.WriteLine();
            Console.WriteLine("FILE TIME:");
            Console.WriteLine("\tdrawing created (UTC): {0}.{1}", dxf.DrawingVariables.TduCreate, dxf.DrawingVariables.TduCreate.Millisecond.ToString("000"));
            Console.WriteLine("\tdrawing last update (UTC): {0}.{1}", dxf.DrawingVariables.TduUpdate, dxf.DrawingVariables.TduUpdate.Millisecond.ToString("000"));
            Console.WriteLine("\tdrawing edition time: {0}", dxf.DrawingVariables.TdinDwg);
            Console.WriteLine();
            Console.WriteLine("APPLICATION REGISTRIES: {0}", dxf.ApplicationRegistries.Count);
            foreach (var o in dxf.ApplicationRegistries)
            {
                Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.ApplicationRegistries.GetReferences(o.Name).Count);
            }
            Console.WriteLine();

            Console.WriteLine("LAYERS: {0}", dxf.Layers.Count);
            foreach (var o in dxf.Layers)
            {
                Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.Layers.GetReferences(o).Count);
                Debug.Assert(ReferenceEquals(o.Linetype, dxf.Linetypes[o.Linetype.Name]), "Object reference not equal.");
            }
            Console.WriteLine();

            Console.WriteLine("LINE TYPES: {0}", dxf.Linetypes.Count);
            foreach (var o in dxf.Linetypes)
            {
                Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.Linetypes.GetReferences(o.Name).Count);
            }
            Console.WriteLine();

            Console.WriteLine("TEXT STYLES: {0}", dxf.TextStyles.Count);
            foreach (var o in dxf.TextStyles)
            {
                Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.TextStyles.GetReferences(o.Name).Count);
            }
            Console.WriteLine();

            //Console.WriteLine("SHAPE STYLES: {0}", dxf.ShapeStyles.Count);
            //foreach (var o in dxf.ShapeStyles)
            //{
            //    Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.ShapeStyles.GetReferences(o.Name).Count);
            //}
            //Console.WriteLine();

            Console.WriteLine("DIMENSION STYLES: {0}", dxf.DimensionStyles.Count);
            foreach (var o in dxf.DimensionStyles)
            {
                Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.DimensionStyles.GetReferences(o.Name).Count);
                Debug.Assert(ReferenceEquals(o.TextStyle, dxf.TextStyles[o.TextStyle.Name]), "Object reference not equal.");
                Debug.Assert(ReferenceEquals(o.DimLineLinetype, dxf.Linetypes[o.DimLineLinetype.Name]), "Object reference not equal.");
                Debug.Assert(ReferenceEquals(o.ExtLine1Linetype, dxf.Linetypes[o.ExtLine1Linetype.Name]), "Object reference not equal.");
                Debug.Assert(ReferenceEquals(o.ExtLine2Linetype, dxf.Linetypes[o.ExtLine2Linetype.Name]), "Object reference not equal.");
                if (o.DimArrow1 != null)
                {
                    Debug.Assert(ReferenceEquals(o.DimArrow1, dxf.Blocks[o.DimArrow1.Name]), "Object reference not equal.");
                }
                if (o.DimArrow2 != null)
                {
                    Debug.Assert(ReferenceEquals(o.DimArrow2, dxf.Blocks[o.DimArrow2.Name]), "Object reference not equal.");
                }
            }
            Console.WriteLine();

            Console.WriteLine("MLINE STYLES: {0}", dxf.MlineStyles.Count);
            foreach (var o in dxf.MlineStyles)
            {
                Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.MlineStyles.GetReferences(o.Name).Count);
                foreach (var e in o.Elements)
                {
                    Debug.Assert(ReferenceEquals(e.Linetype, dxf.Linetypes[e.Linetype.Name]), "Object reference not equal.");
                }
            }
            Console.WriteLine();

            Console.WriteLine("UCSs: {0}", dxf.UCSs.Count);
            foreach (var o in dxf.UCSs)
            {
                Console.WriteLine("\t{0}", o.Name);
            }
            Console.WriteLine();

            Console.WriteLine("BLOCKS: {0}", dxf.Blocks.Count);
            foreach (var o in dxf.Blocks)
            {
                Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.Blocks.GetReferences(o.Name).Count);
                Debug.Assert(ReferenceEquals(o.Layer, dxf.Layers[o.Layer.Name]), "Object reference not equal.");

                foreach (var e in o.Entities)
                {
                    Debug.Assert(ReferenceEquals(e.Layer, dxf.Layers[e.Layer.Name]), "Object reference not equal.");
                    Debug.Assert(ReferenceEquals(e.Linetype, dxf.Linetypes[e.Linetype.Name]), "Object reference not equal.");
                    Debug.Assert(ReferenceEquals(e.Owner, dxf.Blocks[o.Name]), "Object reference not equal.");
                    foreach (var x in e.XData.Values)
                    {
                        Debug.Assert(ReferenceEquals(x.ApplicationRegistry, dxf.ApplicationRegistries[x.ApplicationRegistry.Name]), "Object reference not equal.");
                    }

                    Text txt = e as Text;
                    if (txt != null)
                    {
                        Debug.Assert(ReferenceEquals(txt.Style, dxf.TextStyles[txt.Style.Name]), "Object reference not equal.");
                    }

                    MText mtxt = e as MText;
                    if (mtxt != null)
                    {
                        Debug.Assert(ReferenceEquals(mtxt.Style, dxf.TextStyles[mtxt.Style.Name]), "Object reference not equal.");
                    }

                    Dimension dim = e as Dimension;
                    if (dim != null)
                    {
                        Debug.Assert(ReferenceEquals(dim.Style, dxf.DimensionStyles[dim.Style.Name]), "Object reference not equal.");
                        Debug.Assert(ReferenceEquals(dim.Block, dxf.Blocks[dim.Block.Name]), "Object reference not equal.");
                    }

                    MLine mline = e as MLine;
                    if (mline != null)
                    {
                        Debug.Assert(ReferenceEquals(mline.Style, dxf.MlineStyles[mline.Style.Name]), "Object reference not equal.");
                    }

                    Image img = e as Image;
                    if (img != null)
                    {
                        Debug.Assert(ReferenceEquals(img.Definition, dxf.ImageDefinitions[img.Definition.Name]), "Object reference not equal.");
                    }

                    Insert ins = e as Insert;
                    if (ins != null)
                    {
                        Debug.Assert(ReferenceEquals(ins.Block, dxf.Blocks[ins.Block.Name]), "Object reference not equal.");
                        foreach (var a in ins.Attributes)
                        {
                            Debug.Assert(ReferenceEquals(a.Layer, dxf.Layers[a.Layer.Name]), "Object reference not equal.");
                            Debug.Assert(ReferenceEquals(a.Linetype, dxf.Linetypes[a.Linetype.Name]), "Object reference not equal.");
                            Debug.Assert(ReferenceEquals(a.Style, dxf.TextStyles[a.Style.Name]), "Object reference not equal.");
                        }
                    }
                }

                foreach (var a in o.AttributeDefinitions.Values)
                {
                    Debug.Assert(ReferenceEquals(a.Layer, dxf.Layers[a.Layer.Name]), "Object reference not equal.");
                    Debug.Assert(ReferenceEquals(a.Linetype, dxf.Linetypes[a.Linetype.Name]), "Object reference not equal.");
                    foreach (var x in a.XData.Values)
                    {
                        Debug.Assert(ReferenceEquals(x.ApplicationRegistry, dxf.ApplicationRegistries[x.ApplicationRegistry.Name]), "Object reference not equal.");
                    }
                }
            }
            Console.WriteLine();

            Console.WriteLine("LAYOUTS: {0}", dxf.Layouts.Count);
            foreach (var o in dxf.Layouts)
            {
                Debug.Assert(ReferenceEquals(o.AssociatedBlock, dxf.Blocks[o.AssociatedBlock.Name]), "Object reference not equal.");

                Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.Layouts.GetReferences(o.Name).Count);
                List <DxfObject> entities = dxf.Layouts.GetReferences(o.Name);
                foreach (var e in entities)
                {
                    EntityObject entity = e as EntityObject;
                    if (entity != null)
                    {
                        Debug.Assert(ReferenceEquals(entity.Layer, dxf.Layers[entity.Layer.Name]), "Object reference not equal.");
                        Debug.Assert(ReferenceEquals(entity.Linetype, dxf.Linetypes[entity.Linetype.Name]), "Object reference not equal.");
                        Debug.Assert(ReferenceEquals(entity.Owner, dxf.Blocks[o.AssociatedBlock.Name]), "Object reference not equal.");
                        foreach (var x in entity.XData.Values)
                        {
                            Debug.Assert(ReferenceEquals(x.ApplicationRegistry, dxf.ApplicationRegistries[x.ApplicationRegistry.Name]), "Object reference not equal.");
                        }
                    }

                    Text txt = e as Text;
                    if (txt != null)
                    {
                        Debug.Assert(ReferenceEquals(txt.Style, dxf.TextStyles[txt.Style.Name]), "Object reference not equal.");
                    }

                    MText mtxt = e as MText;
                    if (mtxt != null)
                    {
                        Debug.Assert(ReferenceEquals(mtxt.Style, dxf.TextStyles[mtxt.Style.Name]), "Object reference not equal.");
                    }

                    Dimension dim = e as Dimension;
                    if (dim != null)
                    {
                        Debug.Assert(ReferenceEquals(dim.Style, dxf.DimensionStyles[dim.Style.Name]), "Object reference not equal.");
                        Debug.Assert(ReferenceEquals(dim.Block, dxf.Blocks[dim.Block.Name]), "Object reference not equal.");
                    }

                    MLine mline = e as MLine;
                    if (mline != null)
                    {
                        Debug.Assert(ReferenceEquals(mline.Style, dxf.MlineStyles[mline.Style.Name]), "Object reference not equal.");
                    }

                    Image img = e as Image;
                    if (img != null)
                    {
                        Debug.Assert(ReferenceEquals(img.Definition, dxf.ImageDefinitions[img.Definition.Name]), "Object reference not equal.");
                    }

                    Insert ins = e as Insert;
                    if (ins != null)
                    {
                        Debug.Assert(ReferenceEquals(ins.Block, dxf.Blocks[ins.Block.Name]), "Object reference not equal.");
                        foreach (var a in ins.Attributes)
                        {
                            Debug.Assert(ReferenceEquals(a.Layer, dxf.Layers[a.Layer.Name]), "Object reference not equal.");
                            Debug.Assert(ReferenceEquals(a.Linetype, dxf.Linetypes[a.Linetype.Name]), "Object reference not equal.");
                            Debug.Assert(ReferenceEquals(a.Style, dxf.TextStyles[a.Style.Name]), "Object reference not equal.");
                        }
                    }
                }
            }
            Console.WriteLine();

            Console.WriteLine("IMAGE DEFINITIONS: {0}", dxf.ImageDefinitions.Count);
            foreach (var o in dxf.ImageDefinitions)
            {
                Console.WriteLine("\t{0}; File name: {1}; References count: {2}", o.Name, o.FileName, dxf.ImageDefinitions.GetReferences(o.Name).Count);
            }
            Console.WriteLine();

            Console.WriteLine("DGN UNDERLAY DEFINITIONS: {0}", dxf.UnderlayDgnDefinitions.Count);
            foreach (var o in dxf.UnderlayDgnDefinitions)
            {
                Console.WriteLine("\t{0}; File name: {1}; References count: {2}", o.Name, o.FileName, dxf.UnderlayDgnDefinitions.GetReferences(o.Name).Count);
            }
            Console.WriteLine();

            Console.WriteLine("DWF UNDERLAY DEFINITIONS: {0}", dxf.UnderlayDwfDefinitions.Count);
            foreach (var o in dxf.UnderlayDwfDefinitions)
            {
                Console.WriteLine("\t{0}; File name: {1}; References count: {2}", o.Name, o.FileName, dxf.UnderlayDwfDefinitions.GetReferences(o.Name).Count);
            }
            Console.WriteLine();

            Console.WriteLine("PDF UNDERLAY DEFINITIONS: {0}", dxf.UnderlayPdfDefinitions.Count);
            foreach (var o in dxf.UnderlayPdfDefinitions)
            {
                Console.WriteLine("\t{0}; File name: {1}; References count: {2}", o.Name, o.FileName, dxf.UnderlayPdfDefinitions.GetReferences(o.Name).Count);
            }
            Console.WriteLine();

            Console.WriteLine("GROUPS: {0}", dxf.Groups.Count);
            foreach (var o in dxf.Groups)
            {
                Console.WriteLine("\t{0}; Entities count: {1}", o.Name, o.Entities.Count);
            }
            Console.WriteLine();

            Console.WriteLine("ATTRIBUTE DEFINITIONS for the \"Model\" Layout: {0}", dxf.Layouts[Layout.ModelSpaceName].AssociatedBlock.AttributeDefinitions.Count);
            foreach (var o in dxf.Layouts[Layout.ModelSpaceName].AssociatedBlock.AttributeDefinitions)
            {
                Console.WriteLine("\tTag: {0}", o.Value.Tag);
            }
            Console.WriteLine();

            // the entities lists contain the geometry that has a graphical representation in the drawing across all layouts,
            // to get the entities that belongs to a specific layout you can get the references through the Layouts.GetReferences(name)
            // or check the EntityObject.Owner.Record.Layout property
            Console.WriteLine("ENTITIES for the Active Layout = {0}:", dxf.ActiveLayout);
            Console.WriteLine("\t{0}; count: {1}", EntityType.Arc, dxf.Arcs.Count());
            Console.WriteLine("\t{0}; count: {1}", EntityType.Circle, dxf.Circles.Count());
            Console.WriteLine("\t{0}; count: {1}", EntityType.Dimension, dxf.Dimensions.Count());
            foreach (var a in dxf.Dimensions)
            {
                foreach (var styleOverride in a.StyleOverrides.Values)
                {
                    switch (styleOverride.Type)
                    {
                    case DimensionStyleOverrideType.DimLineLinetype:
                        Debug.Assert(ReferenceEquals((Linetype)styleOverride.Value, dxf.Linetypes[((Linetype)styleOverride.Value).Name]), "Object reference not equal.");
                        break;

                    case DimensionStyleOverrideType.ExtLine1Linetype:
                        Debug.Assert(ReferenceEquals((Linetype)styleOverride.Value, dxf.Linetypes[((Linetype)styleOverride.Value).Name]), "Object reference not equal.");
                        break;

                    case DimensionStyleOverrideType.ExtLine2Linetype:
                        Debug.Assert(ReferenceEquals((Linetype)styleOverride.Value, dxf.Linetypes[((Linetype)styleOverride.Value).Name]), "Object reference not equal.");
                        break;

                    case DimensionStyleOverrideType.TextStyle:
                        Debug.Assert(ReferenceEquals((TextStyle)styleOverride.Value, dxf.TextStyles[((TextStyle)styleOverride.Value).Name]), "Object reference not equal.");
                        break;

                    case DimensionStyleOverrideType.LeaderArrow:
                        Debug.Assert(ReferenceEquals((Block)styleOverride.Value, dxf.Blocks[((Block)styleOverride.Value).Name]), "Object reference not equal.");
                        break;

                    case DimensionStyleOverrideType.DimArrow1:
                        if (styleOverride.Value == null)
                        {
                            break;
                        }
                        Debug.Assert(ReferenceEquals((Block)styleOverride.Value, dxf.Blocks[((Block)styleOverride.Value).Name]), "Object reference not equal.");
                        break;

                    case DimensionStyleOverrideType.DimArrow2:
                        if (styleOverride.Value == null)
                        {
                            break;
                        }
                        Debug.Assert(ReferenceEquals((Block)styleOverride.Value, dxf.Blocks[((Block)styleOverride.Value).Name]), "Object reference not equal.");
                        break;
                    }
                }
            }
            Console.WriteLine("\t{0}; count: {1}", EntityType.Ellipse, dxf.Ellipses.Count());
            Console.WriteLine("\t{0}; count: {1}", EntityType.Face3D, dxf.Faces3d.Count());
            Console.WriteLine("\t{0}; count: {1}", EntityType.Hatch, dxf.Hatches.Count());
            Console.WriteLine("\t{0}; count: {1}", EntityType.Image, dxf.Images.Count());
            Console.WriteLine("\t{0}; count: {1}", EntityType.Insert, dxf.Inserts.Count());
            Console.WriteLine("\t{0}; count: {1}", EntityType.Leader, dxf.Leaders.Count());
            foreach (var a in dxf.Leaders)
            {
                foreach (var styleOverride in a.StyleOverrides.Values)
                {
                    switch (styleOverride.Type)
                    {
                    case DimensionStyleOverrideType.DimLineLinetype:
                        Debug.Assert(ReferenceEquals((Linetype)styleOverride.Value, dxf.Linetypes[((Linetype)styleOverride.Value).Name]), "Object reference not equal.");
                        break;

                    case DimensionStyleOverrideType.ExtLine1Linetype:
                        Debug.Assert(ReferenceEquals((Linetype)styleOverride.Value, dxf.Linetypes[((Linetype)styleOverride.Value).Name]), "Object reference not equal.");
                        break;

                    case DimensionStyleOverrideType.ExtLine2Linetype:
                        Debug.Assert(ReferenceEquals((Linetype)styleOverride.Value, dxf.Linetypes[((Linetype)styleOverride.Value).Name]), "Object reference not equal.");
                        break;

                    case DimensionStyleOverrideType.TextStyle:
                        Debug.Assert(ReferenceEquals((TextStyle)styleOverride.Value, dxf.TextStyles[((TextStyle)styleOverride.Value).Name]), "Object reference not equal.");
                        break;

                    case DimensionStyleOverrideType.LeaderArrow:
                        Debug.Assert(ReferenceEquals((Block)styleOverride.Value, dxf.Blocks[((Block)styleOverride.Value).Name]), "Object reference not equal.");
                        break;

                    case DimensionStyleOverrideType.DimArrow1:
                        Debug.Assert(ReferenceEquals((Block)styleOverride.Value, dxf.Blocks[((Block)styleOverride.Value).Name]), "Object reference not equal.");
                        break;

                    case DimensionStyleOverrideType.DimArrow2:
                        Debug.Assert(ReferenceEquals((Block)styleOverride.Value, dxf.Blocks[((Block)styleOverride.Value).Name]), "Object reference not equal.");
                        break;
                    }
                }
            }
            Console.WriteLine("\t{0}; count: {1}", EntityType.LightWeightPolyline, dxf.LwPolylines.Count());
            Console.WriteLine("\t{0}; count: {1}", EntityType.Line, dxf.Lines.Count());
            Console.WriteLine("\t{0}; count: {1}", EntityType.Mesh, dxf.Meshes.Count());
            Console.WriteLine("\t{0}; count: {1}", EntityType.MLine, dxf.MLines.Count());
            Console.WriteLine("\t{0}; count: {1}", EntityType.MText, dxf.MTexts.Count());
            Console.WriteLine("\t{0}; count: {1}", EntityType.Point, dxf.Points.Count());
            Console.WriteLine("\t{0}; count: {1}", EntityType.PolyfaceMesh, dxf.PolyfaceMeshes.Count());
            Console.WriteLine("\t{0}; count: {1}", EntityType.Polyline, dxf.Polylines.Count());
            // Console.WriteLine("\t{0}; count: {1}", EntityType.Shape, dxf.Shapes.Count());
            Console.WriteLine("\t{0}; count: {1}", EntityType.Solid, dxf.Solids.Count());
            Console.WriteLine("\t{0}; count: {1}", EntityType.Spline, dxf.Splines.Count());
            Console.WriteLine("\t{0}; count: {1}", EntityType.Text, dxf.Texts.Count());
            Console.WriteLine("\t{0}; count: {1}", EntityType.Ray, dxf.Rays.Count());
            Console.WriteLine("\t{0}; count: {1}", EntityType.Underlay, dxf.Underlays.Count());
            Console.WriteLine("\t{0}; count: {1}", EntityType.Viewport, dxf.Viewports.Count());
            Console.WriteLine("\t{0}; count: {1}", EntityType.Wipeout, dxf.Wipeouts.Count());
            Console.WriteLine("\t{0}; count: {1}", EntityType.XLine, dxf.XLines.Count());
            Console.WriteLine();

            // the dxf version is controlled by the DrawingVariables property of the dxf document,
            // also a HeaderVariables instance or a DxfVersion can be passed to the constructor to initialize a new DxfDocument.
            //  dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2018;
            //  dxf.Save("sample 2018.dxf");
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2013;
            dxf.Save("sample 2013.dxf");
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2010;
            dxf.Save("sample 2010.dxf");
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save("sample 2007.dxf");
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2004;
            dxf.Save("sample 2004.dxf");
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2000;
            dxf.Save("sample 2000.dxf");

            // saving to binary dxf
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2013;
            dxf.Save("binary test.dxf", true);
            // DxfDocument test = DxfDocument.Load("binary test.dxf", new List<string> { @".\Support" });
            DxfDocument test = DxfDocument.Load("binary test.dxf");

            if (outputLog)
            {
                writer.Flush();
                writer.Close();
            }
            else
            {
                Console.WriteLine("Press a key to continue...");
                Console.ReadLine();
            }
            return(dxf);
        }
Esempio n. 10
0
 public Class1070(DxfModel model, FileFormat fileFormat, DxfVersion version)
 {
     this.dxfModel_0   = model;
     this.fileFormat_0 = fileFormat;
     this.dxfVersion_0 = version;
 }
Esempio n. 11
0
 private bool method_23(DxfVersion version)
 {
     return(version > DxfVersion.Dxf18 == this.FormatIsLessThanOrEqualToDxfR18);
 }
Esempio n. 12
0
 public DxfWriter(string file, DxfVersion version)
 {
     Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
     this.file = file;
     this.version = version;
 }
Esempio n. 13
0
 public Class726(Stream stream, Encoding encoding, DxfVersion version)
     : base(stream, encoding, version)
 {
 }
Esempio n. 14
0
        /// <summary>
        /// Initalizes a new instance of the <c>DxfDocument</c> class.
        /// </summary>
        public DxfDocument()
        {
            this.addedObjects = new Hashtable(); // keeps track of the added object to avoid duplicates
            this.version = this.version;
            this.viewports = new Dictionary<string, ViewPort>();
            this.layers = new Dictionary<string, Layer>();
            this.lineTypes = new Dictionary<string, LineType>();
            this.textStyles = new Dictionary<string, TextStyle>();
            this.blocks = new Dictionary<string, Block>();
            this.appRegisterNames = new Dictionary<string, ApplicationRegistry>();
            this.dimStyles = new Dictionary<string, DimensionStyle>();

            ////add default viewports
            //ViewPort active = ViewPort.Active;
            //this.viewports.Add(active.Name, active);
            //this.handleCount = active.AsignHandle(this.handleCount);

            ////add default layer
            //Layer.PlotStyleHandle = Conversion.Hex(this.handleCount++);
            //Layer byDefault = Layer.Default;
            //this.layers.Add(byDefault.Name, byDefault);
            //this.handleCount = byDefault.AsignHandle(this.handleCount);

            //// add default line types
            //LineType byLayer = LineType.ByLayer;
            //LineType byBlock = LineType.ByBlock;
            //this.lineTypes.Add(byLayer.Name, byLayer);
            //this.handleCount = byLayer.AsignHandle(this.handleCount);
            //this.lineTypes.Add(byBlock.Name, byBlock);
            //this.handleCount = byBlock.AsignHandle(this.handleCount);

            //// add default text style
            //TextStyle defaultStyle = TextStyle.Default;
            //this.textStyles.Add(defaultStyle.Name, defaultStyle);
            //this.handleCount = defaultStyle.AsignHandle(this.handleCount);

            //// add default blocks
            //Block modelSpace = Block.ModelSpace;
            //Block paperSpace = Block.PaperSpace;
            //this.blocks.Add(modelSpace.Name, modelSpace);
            //this.handleCount = modelSpace.AsignHandle(this.handleCount);
            //this.blocks.Add(paperSpace.Name, paperSpace);
            //this.handleCount = paperSpace.AsignHandle(this.handleCount);

            //// add default application registry
            //ApplicationRegistry defaultAppId = ApplicationRegistry.Default;
            //this.appRegisterNames.Add(defaultAppId.Name, defaultAppId);
            //this.handleCount = defaultAppId.AsignHandle(this.handleCount);

            ////add default dimension style
            //DimensionStyle defaultDimStyle = DimensionStyle.Default;
            //this.dimStyles.Add(defaultDimStyle.Name, defaultDimStyle);
            //this.handleCount = defaultDimStyle.AsignHandle(this.handleCount);

            this.arcs = new List<Arc>();
            this.ellipses = new List<Ellipse>();
            this.nurbsCurves = new List<NurbsCurve>();
            this.faces3d = new List<Face3d>();
            this.solids = new List<Solid>();
            this.inserts = new List<Insert>();
            this.polylines = new List<IPolyline>();
            this.lines = new List<Line>();
            this.circles = new List<Circle>();
            this.points = new List<Point>();
            this.texts = new List<Text>();
        }
Esempio n. 15
0
        /// <summary>
        /// Saves the database of the actual DxfDocument to a dxf ASCII file.
        /// </summary>
        /// <param name="file">File name.</param>
        /// <param name="dxfVersion">Dxf file <see cref="DxfVersion">version</see>.</param>
        public void Save(string file, DxfVersion dxfVersion)
        {
            ReAsignHandlersAndDefaultObjects();
            this.fileName = Path.GetFileNameWithoutExtension(file);
            this.version = dxfVersion;

            List<Polyline> ellipsePolys = null;
            List<IPolyline> lwPolys;
            Dictionary<string, List<IEntityObject>> blockEntities;
            if (this.version == DxfVersion.AutoCad12)
            {
                // since AutoCad dxf Version 12 doesn't support ellipses, we will transform them in polylines
                ellipsePolys = new List<Polyline>();
                foreach (Ellipse ellipse in this.ellipses)
                {
                    Polyline poly = ellipse.ToPolyline(ellipse.CurvePoints);
                    this.handleCount = poly.AsignHandle(this.handleCount);
                    ellipsePolys.Add(poly);
                }

                // since AutoCad dxf Version 12 doesn't support lwpolylines, we will transform them in polylines
                lwPolys = new List<IPolyline>();
                foreach (IPolyline lwPoly in this.polylines)
                {
                    if (lwPoly is LightWeightPolyline)
                    {
                        Polyline poly = ((LightWeightPolyline) lwPoly).ToPolyline();
                        this.handleCount = poly.AsignHandle(this.handleCount);
                        lwPolys.Add(poly);
                    }
                    else
                    {
                        lwPolys.Add(lwPoly);
                    }

                }

                // since AutoCad dxf Version 12 doesn't support lwpolylines in blocks, we will transform them in polylines
                blockEntities = new Dictionary<string, List<IEntityObject>>();
                foreach (Block block in this.blocks.Values)
                {
                    blockEntities.Add(block.Name, new List<IEntityObject>());
                    foreach (IEntityObject entity in block.Entities)
                    {
                        if (entity is LightWeightPolyline)
                        {
                            Polyline poly = ((LightWeightPolyline) entity).ToPolyline();
                            this.handleCount = poly.AsignHandle(this.handleCount);
                            blockEntities[block.Name].Add(poly);
                        }
                        else
                        {
                            blockEntities[block.Name].Add(entity);
                        }
                    }
                }
            }
            else
            {
                // since AutoCad dxf Version 12 doesn't support lwpolylines, we will transform them in polylines
                lwPolys = new List<IPolyline>();
                foreach (IPolyline lwPoly in this.polylines)
                {
                    if ((lwPoly is Polyline))
                    {
                        LightWeightPolyline poly = ((Polyline)lwPoly).ToLightWeightPolyline();
                        this.handleCount = poly.AsignHandle(this.handleCount);
                        lwPolys.Add(poly);
                    }
                    else
                    {
                        lwPolys.Add(lwPoly);
                    }
                }

                // since latter AutoCad dxf Version doesn't support polylines in blocks, we will transform them in lightweightpolylines
                blockEntities = new Dictionary<string, List<IEntityObject>>();
                foreach (Block block in this.blocks.Values)
                {
                    blockEntities.Add(block.Name, new List<IEntityObject>());
                    foreach (IEntityObject entity in block.Entities)
                    {
                        if (entity is Polyline)
                        {
                            LightWeightPolyline poly = ((Polyline) entity).ToLightWeightPolyline();
                            this.handleCount = poly.AsignHandle(this.handleCount);
                            blockEntities[block.Name].Add(poly);
                        }
                        else
                        {
                            blockEntities[block.Name].Add(entity);
                        }
                    }
                }
            }

            CultureInfo cultureInfo = CultureInfo.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            DxfWriter dxfWriter = new DxfWriter(file, dxfVersion);
            dxfWriter.Open();
            dxfWriter.WriteComment("Dxf file generated by SharpDxf, Copyright(C) 2009 Lomatus, Licensed under LGPL");

            //HEADER SECTION
            dxfWriter.BeginSection(StringCode.HeaderSection);
            dxfWriter.WriteSystemVariable(new HeaderVariable(SystemVariable.DabaseVersion, StringEnum.GetStringValue(this.version)));
            dxfWriter.WriteSystemVariable(new HeaderVariable(SystemVariable.HandSeed, Convert.ToString(this.handleCount, 16)));
            dxfWriter.EndSection();

            ////CLASSES SECTION
            //dxfWriter.BeginSection(StringCode.ClassesSection);
            //dxfWriter.EndSection();

            //TABLES SECTION
            dxfWriter.BeginSection(StringCode.TablesSection);

            //viewport tables
            if (this.version != DxfVersion.AutoCad12)
            {
                dxfWriter.BeginTable(StringCode.ViewPortTable);
                foreach (ViewPort vport in this.viewports.Values)
                {
                    dxfWriter.WriteViewPort(vport);
                }
                dxfWriter.EndTable();
            }

            //line type tables
            dxfWriter.BeginTable(StringCode.LineTypeTable);
            foreach (LineType lineType in this.lineTypes.Values)
            {
                dxfWriter.WriteLineType(lineType);
            }
            dxfWriter.EndTable();

            //layer tables
            dxfWriter.BeginTable(StringCode.LayerTable);
            foreach (Layer layer in this.layers.Values)
            {
                dxfWriter.WriteLayer(layer);
            }
            dxfWriter.EndTable();

            //text style tables
            dxfWriter.BeginTable(StringCode.TextStyleTable);
            foreach (TextStyle style in this.textStyles.Values)
            {
                dxfWriter.WriteTextStyle(style);
            }
            dxfWriter.EndTable();

            //view
            dxfWriter.BeginTable(StringCode.ViewTable);
            dxfWriter.EndTable();

            //ucs
            dxfWriter.BeginTable(StringCode.UcsTable);
            dxfWriter.EndTable();

            //registered application tables
            dxfWriter.BeginTable(StringCode.ApplicationIDTable);
            foreach (ApplicationRegistry id in this.appRegisterNames.Values)
            {
                dxfWriter.RegisterApplication(id);
            }
            dxfWriter.EndTable();

            //dimension style tables
            if (this.version != DxfVersion.AutoCad12)
            {
                dxfWriter.BeginTable(StringCode.DimensionStyleTable);
                foreach (DimensionStyle style in this.dimStyles.Values)
                {
                    dxfWriter.WriteDimensionStyle(style);
                }
                dxfWriter.EndTable();
            }

            //block record tables, this table isnot recognized by AutoCad12
            if (this.version != DxfVersion.AutoCad12)
            {
                dxfWriter.BeginTable(StringCode.BlockRecordTable);
                foreach (Block block in this.blocks.Values)
                {
                    dxfWriter.WriteBlockRecord(block.Record);
                }
                dxfWriter.EndTable();
            }

            dxfWriter.EndSection(); //End section tables

            dxfWriter.BeginSection(StringCode.BlocksSection);
            foreach (Block block in this.blocks.Values)
            {
                dxfWriter.WriteBlock(block, blockEntities[block.Name]);
            }

            dxfWriter.EndSection(); //End section blocks

            //ENTITIES SECTION
            dxfWriter.BeginSection(StringCode.EntitiesSection);

            #region writting entities

            foreach (Arc arc in this.arcs)
            {
                dxfWriter.WriteEntity(arc);
            }
            foreach (Circle circle in this.circles)
            {
                dxfWriter.WriteEntity(circle);
            }

            // only for version 12 draw polylines instead of ellipses
            if (this.version == DxfVersion.AutoCad12)
            {
                if (ellipsePolys != null)
                    foreach (Polyline ellipse in ellipsePolys)
                    {
                        dxfWriter.WriteEntity(ellipse);
                    }
            }
            else
            {
                foreach (Ellipse ellipse  in this.ellipses)
                {
                    dxfWriter.WriteEntity(ellipse);
                }
            }
            foreach (NurbsCurve nurbsCurve  in this.nurbsCurves)
            {
                dxfWriter.WriteEntity(nurbsCurve);
            }
            foreach (Point point in this.points)
            {
                dxfWriter.WriteEntity(point);
            }
            foreach (Face3d face in this.faces3d)
            {
                dxfWriter.WriteEntity(face);
            }
            foreach (Solid solid in this.solids)
            {
                dxfWriter.WriteEntity(solid);
            }
            foreach (Insert insert in this.inserts)
            {
                dxfWriter.WriteEntity(insert);
            }
            foreach (Line line in this.lines)
            {
                dxfWriter.WriteEntity(line);
            }

            // lwpolyline in Acad12 are written as polylines

            foreach (IPolyline pol in lwPolys)
            {
               dxfWriter.WriteEntity(pol);
            }

            //foreach (IPolyline polyline in this.polylines)
            //{
            //    // avoid write lwpolylines in Acad12
            //    if (this.version != DxfVersion.AutoCad12 || !(polyline is LightWeightPolyline))
            //    {
            //        dxfWriter.WriteEntity(polyline);
            //    }
            //}

            foreach (Text text in this.texts)
            {
                dxfWriter.WriteEntity(text);
            }
            #endregion

            dxfWriter.EndSection(); //End section entities

            //OBJECTS SECTION
            dxfWriter.BeginSection(StringCode.ObjectsSection);
            dxfWriter.WriteDictionary(Dictionary.Default);
            dxfWriter.EndSection();

            dxfWriter.Close();

            Thread.CurrentThread.CurrentCulture = cultureInfo;
        }
Esempio n. 16
0
        /// <summary>
        /// Loads a dxf ASCII file.
        /// </summary>
        /// <param name="file">File name.</param>
        public void Load(string file)
        {
            if (!File.Exists(file))
                throw new FileNotFoundException("File " + file + " not found.", file);

            this.fileName = Path.GetFileNameWithoutExtension(file);

            CultureInfo cultureInfo = CultureInfo.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            DxfReader dxfReader = new DxfReader(file);
            dxfReader.Open();
            dxfReader.Read();
            dxfReader.Close();

            //header information
            this.version = dxfReader.Version;
            this.handleCount = Convert.ToInt32(dxfReader.HandleSeed,16);

            //tables information
            this.appRegisterNames = dxfReader.ApplicationRegistrationIds;
            this.layers = dxfReader.Layers;
            this.lineTypes = dxfReader.LineTypes;
            this.textStyles = dxfReader.TextStyles;
            this.blocks = dxfReader.Blocks;

            //entities information
            this.arcs = dxfReader.Arcs;
            this.circles = dxfReader.Circles;
            this.ellipses = dxfReader.Ellipses;
            this.points = dxfReader.Points;
            this.faces3d = dxfReader.Faces3d;
            this.solids = dxfReader.Solids;
            this.polylines = dxfReader.Polylines;
            this.lines = dxfReader.Lines;
            this.inserts = dxfReader.Inserts;
            this.texts = dxfReader.Texts;

            Thread.CurrentThread.CurrentCulture = cultureInfo;

            #region reasign handles
            //add default viewports
            //foreach (ViewPort viewPort in this.viewports.Values )
            //{
            //    this.handleCount = viewPort.AsignHandle(this.handleCount);
            //}

            ////add default layer
            //Layer.PlotStyleHandle = Conversion.Hex(this.handleCount++);
            //Layer byDefault = Layer.Default;
            //this.layers.Add(byDefault.Name, byDefault);
            //this.handleCount = byDefault.AsignHandle(this.handleCount);

            //// add default line types
            //LineType byLayer = LineType.ByLayer;
            //LineType byBlock = LineType.ByBlock;
            //this.lineTypes.Add(byLayer.Name, byLayer);
            //this.handleCount = byLayer.AsignHandle(this.handleCount);
            //this.lineTypes.Add(byBlock.Name, byBlock);
            //this.handleCount = byBlock.AsignHandle(this.handleCount);

            //// add default text style
            //TextStyle defaultStyle = TextStyle.Default;
            //this.textStyles.Add(defaultStyle.Name, defaultStyle);
            //this.handleCount = defaultStyle.AsignHandle(this.handleCount);

            //// add default blocks
            //Block modelSpace = Block.ModelSpace;
            //Block paperSpace = Block.PaperSpace;
            //this.blocks.Add(modelSpace.Name, modelSpace);
            //this.handleCount = modelSpace.AsignHandle(this.handleCount);
            //this.blocks.Add(paperSpace.Name, paperSpace);
            //this.handleCount = paperSpace.AsignHandle(this.handleCount);

            //// add default application registry
            //ApplicationRegistry defaultAppId = ApplicationRegistry.Default;
            //this.appRegisterNames.Add(defaultAppId.Name, defaultAppId);
            //this.handleCount = defaultAppId.AsignHandle(this.handleCount);

            //add default dimension style
            //foreach (DimensionStyle dimStyle in this.dimStyles.Values)
            //{
            //    this.handleCount = dimStyle.AsignHandle(this.handleCount);
            //}

            //foreach (Block block in this.blocks.Values)
            //{
            //    this.handleCount = block.AsignHandle(this.handleCount);
            //}

            #endregion
        }
Esempio n. 17
0
 /// <summary>
 /// Saves a block to a text dxf file.
 /// </summary>
 /// <param name="file">Dxf file name.</param>
 /// <param name="version">Version of the dxf database version.</param>
 /// <returns>Return true if the file has been successfully save, false otherwise.</returns>
 public bool Save(string file, DxfVersion version)
 {
     return this.Save(file, version, false);
 }
Esempio n. 18
0
        /// <summary>
        /// 加载dxf ASCII文件
        /// </summary>
        /// <param name="file">Dxf文件流</param>
        public void Load(Stream file)
        {
            CultureInfo cultureInfo = CultureInfo.CurrentCulture;

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            DxfReader dxfReader = new DxfReader(file);

            dxfReader.Open();
            dxfReader.Read();
            dxfReader.Close();

            //header information
            this.version     = dxfReader.Version;
            this.handleCount = Convert.ToInt32(dxfReader.HandleSeed, 16);

            this.extMaxPoint = dxfReader.ExtMaxPoint;
            this.extMinPoint = dxfReader.ExtMinPoint;

            //tables information
            this.appRegisterNames = dxfReader.ApplicationRegistrationIds;
            this.layers           = dxfReader.Layers;
            this.lineTypes        = dxfReader.LineTypes;
            this.textStyles       = dxfReader.TextStyles;
            this.blocks           = dxfReader.Blocks;

            //entities information
            this.arcs      = dxfReader.Arcs;
            this.circles   = dxfReader.Circles;
            this.ellipses  = dxfReader.Ellipses;
            this.points    = dxfReader.Points;
            this.faces3d   = dxfReader.Faces3d;
            this.solids    = dxfReader.Solids;
            this.polylines = dxfReader.Polylines;
            this.lines     = dxfReader.Lines;
            this.inserts   = dxfReader.Inserts;
            this.texts     = dxfReader.Texts;
            this.shaps     = dxfReader.Shaps.Where(p => p.Type != EntityType.Hatch).ToList();
            this.hatchs    = dxfReader.Shaps.Where(p => p.Type == EntityType.Hatch).Select(p => p as Hatch).ToList();
            Thread.CurrentThread.CurrentCulture = cultureInfo;

            #region reasign handles
            //add default viewports
            //foreach (ViewPort viewPort in this.viewports.Values )
            //{
            //    this.handleCount = viewPort.AsignHandle(this.handleCount);
            //}

            ////add default layer
            //Layer.PlotStyleHandle = Conversion.Hex(this.handleCount++);
            //Layer byDefault = Layer.Default;
            //this.layers.Add(byDefault.Name, byDefault);
            //this.handleCount = byDefault.AsignHandle(this.handleCount);

            //// add default line types
            //LineType byLayer = LineType.ByLayer;
            //LineType byBlock = LineType.ByBlock;
            //this.lineTypes.Add(byLayer.Name, byLayer);
            //this.handleCount = byLayer.AsignHandle(this.handleCount);
            //this.lineTypes.Add(byBlock.Name, byBlock);
            //this.handleCount = byBlock.AsignHandle(this.handleCount);

            //// add default text style
            //TextStyle defaultStyle = TextStyle.Default;
            //this.textStyles.Add(defaultStyle.Name, defaultStyle);
            //this.handleCount = defaultStyle.AsignHandle(this.handleCount);

            //// add default blocks
            //Block modelSpace = Block.ModelSpace;
            //Block paperSpace = Block.PaperSpace;
            //this.blocks.Add(modelSpace.Name, modelSpace);
            //this.handleCount = modelSpace.AsignHandle(this.handleCount);
            //this.blocks.Add(paperSpace.Name, paperSpace);
            //this.handleCount = paperSpace.AsignHandle(this.handleCount);

            //// add default application registry
            //ApplicationRegistry defaultAppId = ApplicationRegistry.Default;
            //this.appRegisterNames.Add(defaultAppId.Name, defaultAppId);
            //this.handleCount = defaultAppId.AsignHandle(this.handleCount);

            //add default dimension style
            //foreach (DimensionStyle dimStyle in this.dimStyles.Values)
            //{
            //    this.handleCount = dimStyle.AsignHandle(this.handleCount);
            //}

            //foreach (Block block in this.blocks.Values)
            //{
            //    this.handleCount = block.AsignHandle(this.handleCount);
            //}

            #endregion
        }
Esempio n. 19
0
        public void method_0()
        {
            DxfHeader  header  = this.class374_0.Model.Header;
            DxfVersion version = this.class374_0.Version;

            this.interface30_0.imethod_19(16);
            this.interface30_0.imethod_3();
            int num1 = this.interface30_0.imethod_43();

            if (version > DxfVersion.Dxf21 && this.class374_0.Model.Header.AcadMaintenanceVersion > 3 || version > DxfVersion.Dxf27)
            {
                this.interface30_0.imethod_43();
            }
            long num2 = this.interface30_0.imethod_3();

            if (version >= DxfVersion.Dxf21)
            {
                int  num3 = this.interface30_0.imethod_43();
                long stringStreamEndBitPosition = num2 + (long)num3 - 1L;
                this.interface30_2 = Class444.Create(version, this.dwgReader_0, (Stream)Class1045.smethod_1(this.interface30_0.Stream, this.interface30_0.Stream.Length, this.dwgReader_0.MemoryPageCache), false);
                this.interface30_2.imethod_5(stringStreamEndBitPosition);
                this.list_0.Add((IDisposable)this.interface30_2.Stream);
                this.interface30_3 = Class444.Create(version, this.dwgReader_0, (Stream)Class1045.smethod_1(this.interface30_0.Stream, this.interface30_0.Stream.Length, this.dwgReader_0.MemoryPageCache), false);
                this.interface30_3.imethod_4(stringStreamEndBitPosition + 1L);
                this.list_0.Add((IDisposable)this.interface30_3.Stream);
                this.interface30_0 = (Interface30) new Class1048(this.interface30_0, this.interface30_2, this.interface30_3);
            }
            if (version > DxfVersion.Dxf24)
            {
                header.RequiredVersions = this.interface30_0.imethod_12();
            }
            this.interface30_0.imethod_8();
            this.interface30_0.imethod_8();
            this.interface30_0.imethod_8();
            this.interface30_0.imethod_8();
            this.interface30_0.ReadString();
            this.interface30_0.ReadString();
            this.interface30_0.ReadString();
            this.interface30_0.ReadString();
            this.interface30_0.imethod_11();
            this.interface30_0.imethod_11();
            if (this.class374_0.IsVersion13Or14)
            {
                int num4 = (int)this.interface30_0.imethod_14();
            }
            if (version < DxfVersion.Dxf18)
            {
                this.class374_0.CurrentViewportHandle = this.interface30_0.imethod_32(false);
            }
            header.AssociatedDimensions          = this.interface30_0.imethod_6();
            header.UpdateDimensionsWhileDragging = this.interface30_0.imethod_6();
            if (this.class374_0.IsVersion13Or14)
            {
                header.DimSav = this.interface30_0.imethod_6();
            }
            header.PolylineLineTypeGeneration = (PolylineLineTypeGeneration)this.interface30_0.imethod_7();
            header.OrthoMode                 = this.interface30_0.imethod_6();
            header.RegenerationMode          = this.interface30_0.imethod_6();
            header.FillMode                  = this.interface30_0.imethod_6();
            header.QuickTextMode             = this.interface30_0.imethod_6();
            header.PaperSpaceLineTypeScaling = (PaperSpaceLineTypeScaling)this.interface30_0.imethod_7();
            header.LimitCheckingOn           = this.interface30_0.imethod_6();
            if (this.class374_0.IsVersion13Or14)
            {
                this.interface30_0.imethod_6();
            }
            if (version >= DxfVersion.Dxf18)
            {
                this.interface30_0.imethod_6();
            }
            header.UserTimer               = this.interface30_0.imethod_6();
            header.SketchPolylines         = this.interface30_0.imethod_6();
            header.AngularDirection        = (AngularDirection)this.interface30_0.imethod_7();
            header.ShowSplineControlPoints = this.interface30_0.imethod_6();
            if (this.class374_0.IsVersion13Or14)
            {
                this.interface30_0.imethod_6();
                this.interface30_0.imethod_6();
            }
            header.MirrorText = this.interface30_0.imethod_6();
            header.WorldView  = this.interface30_0.imethod_6();
            if (this.class374_0.IsVersion13Or14)
            {
                this.interface30_0.imethod_6();
            }
            header.ShowModelSpace           = this.interface30_0.imethod_6();
            header.PaperSpaceLimitsChecking = this.interface30_0.imethod_6();
            header.RetainXRefDependentVisibilitySettings = this.interface30_0.imethod_6();
            if (this.class374_0.IsVersion13Or14)
            {
                this.interface30_0.imethod_6();
            }
            header.DisplaySilhouetteCurves = this.interface30_0.imethod_6();
            header.CreateEllipseAsPolyline = this.interface30_0.imethod_6();
            header.ProxyGraphics           = this.interface30_0.imethod_15();
            if (this.class374_0.IsVersion13Or14)
            {
                int num5 = (int)this.interface30_0.imethod_14();
            }
            header.SpatialIndexMaxTreeDepth = this.interface30_0.imethod_14();
            header.LinearUnitFormat         = (LinearUnitFormat)this.interface30_0.imethod_14();
            header.LinearUnitPrecision      = this.interface30_0.imethod_14();
            header.AngularUnit          = (AngularUnit)this.interface30_0.imethod_14();
            header.AngularUnitPrecision = this.interface30_0.imethod_14();
            if (this.class374_0.IsVersion13Or14)
            {
                header.ObjectSnapMode = (ObjectSnapMode)this.interface30_0.imethod_14();
            }
            header.AttributeVisibility = (AttributeVisibility)this.interface30_0.imethod_14();
            if (this.class374_0.IsVersion13Or14)
            {
                int num6 = (int)this.interface30_0.imethod_14();
            }
            header.PointDisplayMode = (PointDisplayMode)this.interface30_0.imethod_14();
            if (this.class374_0.IsVersion13Or14)
            {
                int num7 = (int)this.interface30_0.imethod_14();
            }
            if (version >= DxfVersion.Dxf18)
            {
                this.interface30_0.imethod_11();
                this.interface30_0.imethod_11();
                this.interface30_0.imethod_11();
            }
            header.UserShort1                  = this.interface30_0.imethod_14();
            header.UserShort2                  = this.interface30_0.imethod_14();
            header.UserShort3                  = this.interface30_0.imethod_14();
            header.UserShort4                  = this.interface30_0.imethod_14();
            header.UserShort5                  = this.interface30_0.imethod_14();
            header.NumberOfSplineSegments      = this.interface30_0.imethod_14();
            header.SurfaceDensityU             = this.interface30_0.imethod_14();
            header.SurfaceDensityV             = this.interface30_0.imethod_14();
            header.SurfaceType                 = this.interface30_0.imethod_14();
            header.SurfaceMeshTabulationCount1 = this.interface30_0.imethod_14();
            header.SurfaceMeshTabulationCount2 = this.interface30_0.imethod_14();
            header.SplineType                  = (SplineType)this.interface30_0.imethod_14();
            header.ShadeEdge = (ShadeEdge)this.interface30_0.imethod_14();
            header.ShadeDiffuseToAmbientPercentage = this.interface30_0.imethod_14();
            header.UnitMode                      = this.interface30_0.imethod_14();
            header.MaxViewportCount              = this.interface30_0.imethod_14();
            header.SurfaceIsolineCount           = this.interface30_0.imethod_14();
            header.CurrentMultilineJustification = (VerticalAlignment)this.interface30_0.imethod_14();
            header.TextQuality                   = this.interface30_0.imethod_14();
            header.LineTypeScale                 = this.interface30_0.imethod_8();
            header.TextHeightDefault             = this.interface30_0.imethod_8();
            header.TraceWidthDefault             = this.interface30_0.imethod_8();
            header.SketchIncrement               = this.interface30_0.imethod_8();
            header.FilletRadius                  = this.interface30_0.imethod_8();
            header.ThicknessDefault              = this.interface30_0.imethod_8();
            header.AngleBase                     = this.interface30_0.imethod_8();
            header.PointDisplaySize              = this.interface30_0.imethod_8();
            header.PolylineWidthDefault          = this.interface30_0.imethod_8();
            header.UserDouble1                   = this.interface30_0.imethod_8();
            header.UserDouble2                   = this.interface30_0.imethod_8();
            header.UserDouble3                   = this.interface30_0.imethod_8();
            header.UserDouble4                   = this.interface30_0.imethod_8();
            header.UserDouble5                   = this.interface30_0.imethod_8();
            header.ChamferDistance1              = this.interface30_0.imethod_8();
            header.ChamferDistance2              = this.interface30_0.imethod_8();
            header.ChamferLength                 = this.interface30_0.imethod_8();
            header.ChamferAngle                  = this.interface30_0.imethod_8();
            header.FacetResolution               = this.interface30_0.imethod_8();
            header.CurrentMultilineScale         = this.interface30_0.imethod_8();
            header.CurrentEntityLinetypeScale    = this.interface30_0.imethod_8();
            if (!this.class374_0.IsVersion21OrLater)
            {
                header.MenuFileName = this.interface30_0.ReadString();
            }
            header.CreateDateTime = this.interface30_0.imethod_28();
            header.UpdateDateTime = this.interface30_0.imethod_28();
            if (version >= DxfVersion.Dxf18)
            {
                this.interface30_0.imethod_11();
                this.interface30_0.imethod_11();
                this.interface30_0.imethod_11();
            }
            this.class374_0.Model.SummaryInfo.TotalEditingTime = this.interface30_0.imethod_48();
            header.UserElapsedTimeSpan                  = this.interface30_0.imethod_48();
            header.CurrentEntityColor                   = this.interface30_0.imethod_22();
            header.HandleSeed                           = this.interface30_1.imethod_32(false);
            this.class374_0.CurrentLayerHandle          = this.interface30_0.imethod_32(false);
            this.class374_0.TextStyleHandle             = this.interface30_0.imethod_32(false);
            this.class374_0.CurrentEntityLineTypeHandle = this.interface30_0.imethod_32(false);
            if (version >= DxfVersion.Dxf21)
            {
                long num8 = (long)this.interface30_0.imethod_32(false);
            }
            this.class374_0.CurrentDimensionStyleHandle = this.interface30_0.imethod_32(false);
            this.class374_0.CurrentMultilineStyleHandle = this.interface30_0.imethod_32(false);
            if (this.class374_0.IsVersion15OrLater)
            {
                header.ViewportDefaultViewScaleFactor = this.interface30_0.imethod_8();
            }
            header.PaperSpaceInsertionBase = this.interface30_0.imethod_39();
            header.PaperSpaceExtMin        = this.interface30_0.imethod_39();
            header.PaperSpaceExtMax        = this.interface30_0.imethod_39();
            header.PaperSpaceLimitsMin     = this.interface30_0.imethod_38();
            header.PaperSpaceLimitsMax     = this.interface30_0.imethod_38();
            header.PaperSpaceElevation     = this.interface30_0.imethod_8();
            header.PaperSpaceUcs.Origin    = this.interface30_0.imethod_39();
            header.PaperSpaceUcs.XAxis     = this.interface30_0.imethod_51();
            header.PaperSpaceUcs.YAxis     = this.interface30_0.imethod_51();
            if (!this.class374_0.IsVersion21OrLater)
            {
                this.class374_0.PaperSpaceUcsHandle = this.interface30_0.imethod_32(false);
            }
            if (this.class374_0.IsVersion15OrLater)
            {
                if (!this.class374_0.IsVersion21OrLater)
                {
                    long num3 = (long)this.interface30_0.imethod_32(false);
                }
                int num9 = (int)this.interface30_0.imethod_14();
                if (!this.class374_0.IsVersion21OrLater)
                {
                    long num10 = (long)this.interface30_0.imethod_32(false);
                }
                header.PaperSpaceUcs.OrthographicTopDOrigin    = this.interface30_0.imethod_51();
                header.PaperSpaceUcs.OrthographicBottomDOrigin = this.interface30_0.imethod_51();
                header.PaperSpaceUcs.OrthographicLeftDOrigin   = this.interface30_0.imethod_51();
                header.PaperSpaceUcs.OrthographicRightDOrigin  = this.interface30_0.imethod_51();
                header.PaperSpaceUcs.OrthographicFrontDOrigin  = this.interface30_0.imethod_51();
                header.PaperSpaceUcs.OrthographicBackDOrigin   = this.interface30_0.imethod_51();
            }
            header.InsertionBase = this.interface30_0.imethod_39();
            header.ExtMin        = this.interface30_0.imethod_39();
            header.ExtMax        = this.interface30_0.imethod_39();
            header.LimitsMin     = this.interface30_0.imethod_38();
            header.LimitsMax     = this.interface30_0.imethod_38();
            header.Elevation     = this.interface30_0.imethod_8();
            header.Ucs.Origin    = this.interface30_0.imethod_39();
            header.Ucs.XAxis     = this.interface30_0.imethod_51();
            header.Ucs.YAxis     = this.interface30_0.imethod_51();
            if (!this.class374_0.IsVersion21OrLater)
            {
                this.class374_0.UcsHandle = this.interface30_0.imethod_32(false);
            }
            if (this.class374_0.IsVersion15OrLater)
            {
                if (!this.class374_0.IsVersion21OrLater)
                {
                    long num3 = (long)this.interface30_0.imethod_32(false);
                }
                int num9 = (int)this.interface30_0.imethod_14();
                if (!this.class374_0.IsVersion21OrLater)
                {
                    long num10 = (long)this.interface30_0.imethod_32(false);
                }
                header.Ucs.OrthographicTopDOrigin    = this.interface30_0.imethod_51();
                header.Ucs.OrthographicBottomDOrigin = this.interface30_0.imethod_51();
                header.Ucs.OrthographicLeftDOrigin   = this.interface30_0.imethod_51();
                header.Ucs.OrthographicRightDOrigin  = this.interface30_0.imethod_51();
                header.Ucs.OrthographicFrontDOrigin  = this.interface30_0.imethod_51();
                header.Ucs.OrthographicBackDOrigin   = this.interface30_0.imethod_51();
                if (!this.class374_0.IsVersion21OrLater)
                {
                    header.DimensionStyleOverrides.PostFix = this.interface30_0.ReadString();
                    header.DimensionStyleOverrides.AlternateDimensioningSuffix = this.interface30_0.ReadString();
                }
            }
            if (this.class374_0.IsVersion13Or14)
            {
                header.DimensionStyleOverrides.GenerateTolerances          = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.LimitsGeneration            = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.TextInsideHorizontal        = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.TextOutsideHorizontal       = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.SuppressFirstDimensionLine  = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.SuppressSecondDimensionLine = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.AlternateUnitDimensioning   = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.TextOutsideExtensions       = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.SeparateArrowBlocks         = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.TextInsideExtensions        = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.SuppressOutsideExtensions   = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.AlternateUnitDecimalPlaces  = (short)this.interface30_0.imethod_18();
                header.DimensionStyleOverrides.ZeroHandling = (ZeroHandling)this.interface30_0.imethod_18();
                header.DimensionStyleOverrides.SuppressFirstDimensionLine  = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.SuppressSecondDimensionLine = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.ToleranceAlignment          = (ToleranceAlignment)this.interface30_0.imethod_18();
                header.DimensionStyleOverrides.TextHorizontalAlignment     = (DimensionTextHorizontalAlignment)this.interface30_0.imethod_18();
                int num3 = (int)this.interface30_0.imethod_18();
                header.DimensionStyleOverrides.CursorUpdate                       = (CursorUpdate)this.interface30_0.imethod_7();
                header.DimensionStyleOverrides.ToleranceZeroHandling              = (ZeroHandling)this.interface30_0.imethod_18();
                header.DimensionStyleOverrides.AlternateUnitZeroHandling          = (ZeroHandling)this.interface30_0.imethod_18();
                header.DimensionStyleOverrides.AlternateUnitToleranceZeroHandling = (ZeroHandling)this.interface30_0.imethod_18();
                header.DimensionStyleOverrides.TextVerticalAlignment              = (DimensionTextVerticalAlignment)this.interface30_0.imethod_18();
                int num9 = (int)this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.AngularDimensionDecimalPlaces = this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.DecimalPlaces          = this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.ToleranceDecimalPlaces = this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.AlternateUnitFormat    = (AlternateUnitFormat)this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.AlternateUnitToleranceDecimalPlaces = this.interface30_0.imethod_14();
                this.class374_0.DimensionStyleTextStyleHandle = this.interface30_0.imethod_32(false);
            }
            header.DimensionStyleOverrides.ScaleFactor            = this.interface30_0.imethod_8();
            header.DimensionStyleOverrides.ArrowSize              = this.interface30_0.imethod_8();
            header.DimensionStyleOverrides.ExtensionLineOffset    = this.interface30_0.imethod_8();
            header.DimensionStyleOverrides.DimensionLineIncrement = this.interface30_0.imethod_8();
            header.DimensionStyleOverrides.ExtensionLineExtension = this.interface30_0.imethod_8();
            header.DimensionStyleOverrides.Rounding = this.interface30_0.imethod_8();
            header.DimensionStyleOverrides.DimensionLineExtension = this.interface30_0.imethod_8();
            header.DimensionStyleOverrides.PlusTolerance          = this.interface30_0.imethod_8();
            header.DimensionStyleOverrides.MinusTolerance         = this.interface30_0.imethod_8();
            if (version >= DxfVersion.Dxf21)
            {
                header.DimensionStyleOverrides.FixedExtensionLineLength = this.interface30_0.imethod_8();
                header.DimensionStyleOverrides.JoggedRadiusDimensionTransverseSegmentAngle = this.interface30_0.imethod_8();
                header.DimensionStyleOverrides.TextBackgroundFillMode = (DimensionTextBackgroundFillMode)this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.TextBackgroundColor    = this.interface30_0.imethod_22();
            }
            if (this.class374_0.IsVersion15OrLater)
            {
                header.DimensionStyleOverrides.GenerateTolerances          = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.LimitsGeneration            = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.TextInsideHorizontal        = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.TextOutsideHorizontal       = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.SuppressFirstExtensionLine  = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.SuppressSecondExtensionLine = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.TextVerticalAlignment       = (DimensionTextVerticalAlignment)this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.ZeroHandling        = (ZeroHandling)this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.AngularZeroHandling = (ZeroHandling)this.interface30_0.imethod_14();
            }
            if (version >= DxfVersion.Dxf21)
            {
                header.DimensionStyleOverrides.ArcLengthSymbolPosition = (ArcLengthSymbolPosition)this.interface30_0.imethod_14();
            }
            header.DimensionStyleOverrides.TextHeight               = this.interface30_0.imethod_8();
            header.DimensionStyleOverrides.CenterMarkSize           = this.interface30_0.imethod_8();
            header.DimensionStyleOverrides.TickSize                 = this.interface30_0.imethod_8();
            header.DimensionStyleOverrides.AlternateUnitScaleFactor = this.interface30_0.imethod_8();
            header.DimensionStyleOverrides.LinearScaleFactor        = this.interface30_0.imethod_8();
            header.DimensionStyleOverrides.TextVerticalPosition     = this.interface30_0.imethod_8();
            header.DimensionStyleOverrides.ToleranceScaleFactor     = this.interface30_0.imethod_8();
            header.DimensionStyleOverrides.DimensionLineGap         = this.interface30_0.imethod_8();
            if (this.class374_0.IsVersion13Or14)
            {
                header.DimensionStyleOverrides.PostFix = this.interface30_0.ReadString();
                header.DimensionStyleOverrides.AlternateDimensioningSuffix = this.interface30_0.ReadString();
                this.class374_0.DimensionStyleArrowBlockName       = this.interface30_0.ReadString();
                this.class374_0.DimensionStyleFirstArrowBlockName  = this.interface30_0.ReadString();
                this.class374_0.DimensionStyleSecondArrowBlockName = this.interface30_0.ReadString();
            }
            if (this.class374_0.IsVersion15OrLater)
            {
                header.DimensionStyleOverrides.AlternateUnitRounding      = this.interface30_0.imethod_8();
                header.DimensionStyleOverrides.AlternateUnitDimensioning  = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.AlternateUnitDecimalPlaces = this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.TextOutsideExtensions      = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.SeparateArrowBlocks        = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.TextInsideExtensions       = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.SuppressOutsideExtensions  = this.interface30_0.imethod_6();
            }
            header.DimensionStyleOverrides.DimensionLineColor = this.interface30_0.imethod_22();
            header.DimensionStyleOverrides.ExtensionLineColor = this.interface30_0.imethod_22();
            header.DimensionStyleOverrides.TextColor          = this.interface30_0.imethod_22();
            if (this.class374_0.IsVersion15OrLater)
            {
                header.DimensionStyleOverrides.AngularDimensionDecimalPlaces = this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.DecimalPlaces          = this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.ToleranceDecimalPlaces = this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.AlternateUnitFormat    = (AlternateUnitFormat)this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.AlternateUnitToleranceDecimalPlaces = this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.AngularDimensionDecimalPlaces       = this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.FractionFormat                     = (FractionFormat)this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.LinearUnitFormat                   = (LinearUnitFormat)this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.DecimalSeparator                   = (char)this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.TextMovement                       = (TextMovement)this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.TextHorizontalAlignment            = (DimensionTextHorizontalAlignment)this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.SuppressFirstDimensionLine         = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.SuppressSecondDimensionLine        = this.interface30_0.imethod_6();
                header.DimensionStyleOverrides.ToleranceAlignment                 = (ToleranceAlignment)this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.ToleranceZeroHandling              = (ZeroHandling)this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.AlternateUnitZeroHandling          = (ZeroHandling)this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.AlternateUnitToleranceZeroHandling = (ZeroHandling)this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.CursorUpdate                       = (CursorUpdate)this.interface30_0.imethod_7();
                int num3 = (int)this.interface30_0.imethod_14();
            }
            if (version >= DxfVersion.Dxf21)
            {
                header.DimensionStyleOverrides.IsExtensionLineLengthFixed = this.interface30_0.imethod_6();
            }
            if (version >= DxfVersion.Dxf24)
            {
                header.DimensionStyleOverrides.TextDirection = this.interface30_0.imethod_6() ? TextDirection.RightToLeft : TextDirection.LeftToRight;
                header.DimensionStyleOverrides.AltMzf        = this.interface30_0.imethod_8();
                header.DimensionStyleOverrides.Mzf           = this.interface30_0.imethod_8();
            }
            if (this.class374_0.Version >= DxfVersion.Dxf15 && this.class374_0.Version <= DxfVersion.Dxf18)
            {
                this.class374_0.DimensionStyleTextStyleHandle        = this.interface30_0.imethod_32(false);
                this.class374_0.DimensionStyleLeaderArrowBlockHandle = this.interface30_0.imethod_32(false);
                this.class374_0.DimensionStyleArrowBlockHandle       = this.interface30_0.imethod_32(false);
                this.class374_0.DimensionStyleFirstArrowBlockHandle  = this.interface30_0.imethod_32(false);
                this.class374_0.DimensionStyleSecondArrowBlockHandle = this.interface30_0.imethod_32(false);
            }
            if (this.class374_0.IsVersion15OrLater)
            {
                header.DimensionStyleOverrides.DimensionLineWeight = this.interface30_0.imethod_14();
                header.DimensionStyleOverrides.ExtensionLineWeight = this.interface30_0.imethod_14();
            }
            if (!this.class374_0.IsVersion21OrLater)
            {
                long num3  = (long)this.method_1();
                long num9  = (long)this.method_1();
                long num10 = (long)this.method_1();
                long num11 = (long)this.method_1();
                long num12 = (long)this.method_1();
                long num13 = (long)this.method_1();
                long num14 = (long)this.method_1();
                long num15 = (long)this.method_1();
                long num16 = (long)this.method_1();
                if (version >= DxfVersion.Dxf13 && version <= DxfVersion.Dxf15)
                {
                    long num17 = (long)this.method_1();
                }
                long num18 = (long)this.interface30_0.imethod_32(false);
                long num19 = (long)this.interface30_0.imethod_32(false);
                long num20 = (long)this.method_1();
            }
            if (this.class374_0.IsVersion15OrLater)
            {
                header.StackedTextAlignment      = (VerticalAlignment)(2 - (int)this.interface30_0.imethod_14());
                header.StackedTextSizePercentage = this.interface30_0.imethod_14();
                if (!this.class374_0.IsVersion21OrLater)
                {
                    this.class374_0.Model.SummaryInfo.HyperLinkBase = this.interface30_0.ReadString();
                    this.interface30_0.ReadString();
                    this.class374_0.LayoutsDictionaryHandle = this.interface30_0.imethod_32(false);
                    long num3 = (long)this.interface30_0.imethod_32(false);
                    long num9 = (long)this.interface30_0.imethod_32(false);
                }
            }
            if (!this.class374_0.IsVersion21OrLater)
            {
                if (version > DxfVersion.Dxf15)
                {
                    long num3 = (long)this.interface30_0.imethod_32(false);
                    long num9 = (long)this.interface30_0.imethod_32(false);
                }
                if (version > DxfVersion.Dxf18)
                {
                    long num10 = (long)this.interface30_0.imethod_32(false);
                }
            }
            if (this.class374_0.IsVersion15OrLater)
            {
                int num3 = this.interface30_0.imethod_11();
                header.CurrentEntityLineWeight = (short)(num3 & 31);
                header.EndCaps                    = (EndCaps)((num3 & 96) >> 5);
                header.JoinStyle                  = (JoinStyle)((num3 & 384) >> 7);
                header.DisplayLineWeight          = (num3 & 512) == 0;
                header.XEdit                      = (num3 & 1024) == 0;
                header.ExtendedNames              = (num3 & 2048) == 2048;
                header.PlotStyleMode              = (num3 & 8192) == 8192 ? PlotStyleMode.ColorDependent : PlotStyleMode.Named;
                header.InsUnits                   = (DrawingUnits)this.interface30_0.imethod_14();
                header.CurrentEntityPlotStyleType = (PlotStyleType)this.interface30_0.imethod_14();
                if (!this.class374_0.IsVersion21OrLater)
                {
                    if (header.CurrentEntityPlotStyleType == PlotStyleType.ByObjectId)
                    {
                        long num9 = (long)this.interface30_0.imethod_32(false);
                    }
                    header.FingerPrintGuid = this.interface30_0.ReadString();
                    header.VersionGuid     = this.interface30_0.ReadString();
                }
            }
            if (version >= DxfVersion.Dxf18)
            {
                header.EntitySortingFlags = (ObjectSortingFlags)this.interface30_0.imethod_18();
                header.IndexCreationFlags = (IndexCreationFlags)this.interface30_0.imethod_18();
                int num3 = (int)this.interface30_0.imethod_18();
                header.ExternalReferenceClippingBoundaryType = (SimpleLineType)this.interface30_0.imethod_18();
                header.DimensionAssociativity = (DimensionAssociativity)this.interface30_0.imethod_18();
                header.HaloGapPercentage      = this.interface30_0.imethod_18();
                short colorIndex1 = this.interface30_0.imethod_14();
                header.ObscuredColor = Color.CreateFromColorIndex(colorIndex1);
                short colorIndex2 = this.interface30_0.imethod_14();
                header.InterfereColor = Color.CreateFromColorIndex(colorIndex2);
                int num9 = (int)this.interface30_0.imethod_18();
                header.IntersectionDisplay = this.interface30_0.imethod_18() != (byte)0;
                if (!this.class374_0.IsVersion21OrLater)
                {
                    header.ProjectName = this.interface30_0.ReadString();
                }
            }
            if (!this.class374_0.IsVersion21OrLater)
            {
                this.class374_0.PaperSpaceBlockRecordHandle = this.interface30_0.imethod_32(false);
                this.class374_0.ModelSpaceBlockRecordHandle = this.interface30_0.imethod_32(false);
                this.class374_0.ByLayerLineTypeHandle       = this.interface30_0.imethod_32(false);
                this.class374_0.ByBlockLineTypeHandle       = this.interface30_0.imethod_32(false);
                this.class374_0.ContinuousLineTypeHandle    = this.interface30_0.imethod_32(false);
            }
            if (version >= DxfVersion.Dxf21)
            {
                this.interface30_0.imethod_6();
                this.interface30_0.imethod_11();
                this.interface30_0.imethod_11();
                this.interface30_0.imethod_8();
                this.interface30_0.imethod_8();
                this.interface30_0.imethod_8();
                this.interface30_0.imethod_8();
                this.interface30_0.imethod_8();
                this.interface30_0.imethod_8();
                int num3 = (int)this.interface30_0.imethod_18();
                int num9 = (int)this.interface30_0.imethod_18();
                this.interface30_0.imethod_8();
                this.interface30_0.imethod_8();
                this.interface30_0.imethod_8();
                this.interface30_0.imethod_8();
                this.interface30_0.imethod_8();
                this.interface30_0.imethod_8();
                int num10 = (int)this.interface30_0.imethod_14();
                int num11 = (int)this.interface30_0.imethod_18();
                this.interface30_0.imethod_8();
                this.interface30_0.imethod_8();
                this.interface30_0.imethod_8();
                this.interface30_0.imethod_11();
                int num12 = (int)this.interface30_0.imethod_18();
                int num13 = (int)this.interface30_0.imethod_18();
                int num14 = (int)this.interface30_0.imethod_18();
                int num15 = (int)this.interface30_0.imethod_18();
                this.interface30_0.imethod_6();
                header.InterfereColor = this.interface30_0.imethod_22();
                if (!this.class374_0.IsVersion21OrLater)
                {
                    long num16 = (long)this.interface30_0.imethod_32(false);
                    long num17 = (long)this.interface30_0.imethod_32(false);
                    long num18 = (long)this.interface30_0.imethod_32(false);
                }
                header.ShadowMode          = (ShadowMode)this.interface30_0.imethod_18();
                header.ShadowPlaneLocation = this.interface30_0.imethod_8();
            }
            if (this.class374_0.IsVersion21OrLater)
            {
                header.MenuFileName = this.interface30_0.ReadString();
                header.DimensionStyleOverrides.PostFix = this.interface30_0.ReadString();
                header.DimensionStyleOverrides.AlternateDimensioningSuffix = this.interface30_0.ReadString();
                if (this.class374_0.Version > DxfVersion.Dxf21)
                {
                    header.DimensionStyleOverrides.AltMzs = this.interface30_0.ReadString();
                    header.DimensionStyleOverrides.Mzs    = this.interface30_0.ReadString();
                }
                this.class374_0.Model.SummaryInfo.HyperLinkBase = this.interface30_0.ReadString();
                this.interface30_0.ReadString();
                header.FingerPrintGuid = this.interface30_0.ReadString();
                header.VersionGuid     = this.interface30_0.ReadString();
                this.interface30_0.ReadString();
                this.class374_0.PaperSpaceUcsHandle = this.interface30_0.imethod_32(false);
                long num3 = (long)this.interface30_0.imethod_32(false);
                long num9 = (long)this.interface30_0.imethod_32(false);
                this.class374_0.UcsHandle = this.interface30_0.imethod_32(false);
                long num10 = (long)this.interface30_0.imethod_32(false);
                long num11 = (long)this.interface30_0.imethod_32(false);
                this.class374_0.DimensionStyleTextStyleHandle             = this.interface30_0.imethod_32(false);
                this.class374_0.DimensionStyleLeaderArrowBlockHandle      = this.interface30_0.imethod_32(false);
                this.class374_0.DimensionStyleArrowBlockHandle            = this.interface30_0.imethod_32(false);
                this.class374_0.DimensionStyleFirstArrowBlockHandle       = this.interface30_0.imethod_32(false);
                this.class374_0.DimensionStyleSecondArrowBlockHandle      = this.interface30_0.imethod_32(false);
                this.class374_0.DimStyleDimensionLineLineTypeHandle       = this.interface30_0.imethod_32(false);
                this.class374_0.DimStyleFirstExtensionLineLineTypeHandle  = this.interface30_0.imethod_32(false);
                this.class374_0.DimStyleSecondExtensionLineLineTypeHandle = this.interface30_0.imethod_32(false);
                long num12 = (long)this.method_1();
                long num13 = (long)this.method_1();
                long num14 = (long)this.method_1();
                long num15 = (long)this.method_1();
                long num16 = (long)this.method_1();
                long num17 = (long)this.method_1();
                long num18 = (long)this.method_1();
                long num19 = (long)this.method_1();
                long num20 = (long)this.method_1();
                long num21 = (long)this.interface30_0.imethod_32(false);
                long num22 = (long)this.interface30_0.imethod_32(false);
                long num23 = (long)this.method_1();
                this.class374_0.LayoutsDictionaryHandle = this.interface30_0.imethod_32(false);
                long num24 = (long)this.interface30_0.imethod_32(false);
                long num25 = (long)this.interface30_0.imethod_32(false);
                long num26 = (long)this.interface30_0.imethod_32(false);
                long num27 = (long)this.interface30_0.imethod_32(false);
                long num28 = (long)this.interface30_0.imethod_32(false);
                if (version > DxfVersion.Dxf24)
                {
                    long num29 = (long)this.interface30_0.imethod_32(false);
                }
                if (header.CurrentEntityPlotStyleType == PlotStyleType.ByObjectId)
                {
                    long num30 = (long)this.interface30_0.imethod_32(false);
                }
                this.class374_0.PaperSpaceBlockRecordHandle = this.interface30_0.imethod_32(false);
                this.class374_0.ModelSpaceBlockRecordHandle = this.interface30_0.imethod_32(false);
                this.class374_0.ByLayerLineTypeHandle       = this.interface30_0.imethod_32(false);
                this.class374_0.ByBlockLineTypeHandle       = this.interface30_0.imethod_32(false);
                this.class374_0.ContinuousLineTypeHandle    = this.interface30_0.imethod_32(false);
                long num31 = (long)this.interface30_0.imethod_32(false);
                long num32 = (long)this.interface30_0.imethod_32(false);
                long num33 = (long)this.interface30_0.imethod_32(false);
            }
            this.interface30_0 = this.interface30_3;
            if (header.AcadVersion >= DxfVersion.Dxf14)
            {
                try
                {
                    int num3  = (int)this.interface30_0.imethod_14();
                    int num9  = (int)this.interface30_0.imethod_14();
                    int num10 = (int)this.interface30_0.imethod_14();
                    int num11 = (int)this.interface30_0.imethod_14();
                    if (header.AcadVersion >= DxfVersion.Dxf18)
                    {
                        this.interface30_0.imethod_11();
                        this.interface30_0.imethod_11();
                        this.interface30_0.imethod_6();
                    }
                }
                catch (DxfException ex)
                {
                }
            }
            if (this.interface30_0.BitIndex > 0)
            {
                for (int bitIndex = this.interface30_0.BitIndex; bitIndex < 8; ++bitIndex)
                {
                    this.interface30_0.imethod_6();
                }
            }
            this.interface30_0.imethod_3();
            this.interface30_0.imethod_4(num2 + (long)(num1 * 8));
            int num34 = (int)this.interface30_0.imethod_27();

            this.interface30_0.imethod_52(16);
            foreach (IDisposable disposable in this.list_0)
            {
                disposable.Dispose();
            }
        }
Esempio n. 20
0
 /// <summary>
 /// Initializes a new instance of the <c>DxfDocument</c> class.
 /// </summary>
 /// <param name="version">AutoCAD drawing database version number.</param>
 public DxfDocument(DxfVersion version)
     : this(new HeaderVariables {AcadVer = version})
 {
 }
Esempio n. 21
0
 internal void method_11(
     DxfVersion version,
     Class1026 cell,
     int rowIndex,
     int columnIndex,
     out byte edgeFlags,
     out byte virtualEdgeFlags,
     out int overrideFlags,
     out int borderTopFlags,
     out int borderRightFlags,
     out int borderBottomFlags,
     out int borderLeftFlags)
 {
     edgeFlags        = (byte)0;
     virtualEdgeFlags = (byte)0;
     borderTopFlags   = this.method_12(version, cell.BorderTop);
     if (borderTopFlags != 0)
     {
         edgeFlags |= (byte)1;
     }
     else if (rowIndex > 0 && this.Rows[rowIndex - 1].Cells[columnIndex].BorderBottom.method_0(version))
     {
         edgeFlags        |= (byte)1;
         virtualEdgeFlags |= (byte)1;
     }
     borderRightFlags = this.method_12(version, cell.BorderRight);
     if (borderRightFlags != 0)
     {
         edgeFlags |= (byte)2;
     }
     else if (columnIndex < this.ColumnCount - 1 && this.Rows[rowIndex].Cells[columnIndex + 1].BorderLeft.method_0(version))
     {
         edgeFlags        |= (byte)2;
         virtualEdgeFlags |= (byte)2;
     }
     borderBottomFlags = this.method_12(version, cell.BorderBottom);
     if (borderBottomFlags != 0)
     {
         edgeFlags |= (byte)4;
     }
     else if (rowIndex < this.RowCount - 1 && this.Rows[rowIndex + 1].Cells[columnIndex].BorderTop.method_0(version))
     {
         edgeFlags        |= (byte)4;
         virtualEdgeFlags |= (byte)4;
     }
     borderLeftFlags = this.method_12(version, cell.BorderLeft);
     if (borderLeftFlags != 0)
     {
         edgeFlags |= (byte)8;
     }
     else if (columnIndex > 0 && this.Rows[rowIndex].Cells[columnIndex - 1].BorderRight.method_0(version))
     {
         edgeFlags        |= (byte)8;
         virtualEdgeFlags |= (byte)8;
     }
     overrideFlags = borderTopFlags << 6 | borderRightFlags << 7 | borderBottomFlags << 8 | borderLeftFlags << 9;
     if (cell.CellAlignment.HasValue)
     {
         overrideFlags |= 1;
     }
     if (cell.IsBackColorEnabled.HasValue)
     {
         overrideFlags |= 2;
     }
     if (cell.BackColor.HasValue)
     {
         overrideFlags |= 4;
     }
     if (cell.ContentColor.HasValue)
     {
         overrideFlags |= 8;
     }
     if (cell.TextStyle != null)
     {
         overrideFlags |= 16;
     }
     if (!cell.TextHeight.HasValue)
     {
         return;
     }
     overrideFlags |= 32;
 }
Esempio n. 22
0
 public static Interface30 Create(DxfVersion version, Stream stream)
 {
     return(Class444.Create(version, stream, false));
 }
Esempio n. 23
0
 public Class920(DxfVersion outputVersion)
     : base(outputVersion)
 {
 }
Esempio n. 24
0
 public static Class889 Create(Stream stream, DxfVersion version, Encoding encoding)
 {
     return(version < DxfVersion.Dxf21 ? new Class889(stream, encoding) : (Class889) new Class890(stream, encoding));
 }
Esempio n. 25
0
        internal void WriteFile()
        {
            if (String.IsNullOrEmpty(this.FileName))
            {
                throw new InvalidOperationException("Output file name has not been specified");
            }

            DxfVersion v = DxfVersion.AutoCad2007;

            if (!String.IsNullOrEmpty(this.Version))
            {
                if (this.Version == "2007")
                {
                    v = DxfVersion.AutoCad2007;
                }
                else if (this.Version == "2004")
                {
                    v = DxfVersion.AutoCad2004;
                }
                else if (this.Version == "2000")
                {
                    v = DxfVersion.AutoCad2000;
                }
                else if (this.Version == "12")
                {
                    v = DxfVersion.AutoCad12;
                }
                else
                {
                    throw new InvalidOperationException("Unsupported AutoCad version: " + this.Version);
                }
            }

            // Form entity->AutoCad layer index
            m_Layers = new AcLayerEntitySet();

            // If we have an entity translation file, adjust the AutoCad layer
            // names to correspond to the translations. If an entity type has
            // no translation, the output layer name will be the same as the
            // name of the entity type.
            if (!String.IsNullOrEmpty(this.EntityTranslationFileName))
            {
                m_Layers.TranslateLayerNames(this.EntityTranslationFileName);
            }

            // Get info for exporting fonts.

            /*
             * CeFontFile ffile;
             * if ( !ffile.Create() )
             *  ShowMessage("Cannot load font file.\nText will be exported without font information.");
             */

            // Are line annotations relevant? If so, get the font for them (assuming
            // the font is ALWAYS Arial).

            /*
             * AD_SHPTB* pAnnoStyle = 0;
             * UINT4 annoflags = 0;
             * if ( !isTopological ) annoflags = pMap->GetLineAnnoFlags();
             * if ( annoflags ) pAnnoStyle = ffile.GetShapeFile(DwgHandle,"Arial");
             */

            // Create output model and pick up some stock items
            m_Dxf = new DxfDocument();

            m_ContinuousLineType = LineType.Continuous;
            //m_ModelSpace = m_Dxf

            CadastralMapModel mapModel = CadastralMapModel.Current;

            // Convert points if doing a non-topological export
            if (!this.IsTopological)
            {
                // Will we be writing out observed angles?
                //const LOGICAL showAngles = ((annoflags & SHOW_OBSV_ANGLE) != 0);

                mapModel.Index.QueryWindow(null, SpatialType.Point, WritePoint);
            }

            // Convert polygon labels (or misc text)
            mapModel.Index.QueryWindow(null, SpatialType.Text, WriteText);

            mapModel.Index.QueryWindow(null, SpatialType.Line, WriteLine);

            m_Dxf.Save(this.FileName, v);
        }
Esempio n. 26
0
        /// <summary>
        /// Saves a block to a dxf file.
        /// </summary>
        /// <param name="file">Dxf file name.</param>
        /// <param name="version">Version of the dxf database version.</param>
        /// <param name="isBinary">Defines if the file will be saved as binary, by default it will be saved as text</param>
        /// <returns>Return true if the file has been successfully save, false otherwise.</returns>
        public bool Save(string file, DxfVersion version, bool isBinary = false)
        {
            DxfDocument dwg = new DxfDocument(version);
            dwg.DrawingVariables.InsBase = this.origin;
            dwg.DrawingVariables.InsUnits = this.Record.Units;

            foreach (EntityObject entity in this.entities)
                dwg.AddEntity((EntityObject)entity.Clone());

            foreach (AttributeDefinition attdef in this.attributes.Values)
                dwg.AddEntity((EntityObject)attdef.Clone());

            return dwg.Save(file, isBinary);
        }
Esempio n. 27
0
        private void ReadHeader()
        {
            CodeValuePair code = this.ReadCodePair();
            while (code.Value != StringCode.EndSection)
            {
                if (HeaderVariable.Allowed.ContainsKey(code.Value))
                {
                    int codeGroup = HeaderVariable.Allowed[code.Value];
                    string variableName = code.Value;
                    code = this.ReadCodePair();
                    if (code.Code != codeGroup)
                        throw new DxfHeaderVariableException(variableName, this.file, "Invalid variable name and code group convination in line " + this.fileLine);
                    switch (variableName)
                    {
                        case SystemVariable.DabaseVersion:
                            this.version = (DxfVersion) StringEnum.Parse(typeof (DxfVersion), code.Value);
                            break;
                        case SystemVariable.HandSeed :
                            this.handleSeed = code.Value;
                            break;

                    }
                }
                code = this.ReadCodePair();
            }
        }
Esempio n. 28
0
        private void method_18(DxfReader r, Class259 objectBuilder)
        {
            this.bool_2 = true;
            DxfVersion version = r.ModelBuilder.Version;

            this.dwgVersion_0 = Class885.smethod_3(version);
            if (this.stream_0 == null)
            {
                this.stream_0 = (Stream) new PagedMemoryStream(1024L, 1024);
            }
            if (this.dwgVersion_0 > DwgVersion.Dwg1018 && this.stream_1 == null)
            {
                this.stream_1 = (Stream) new PagedMemoryStream(1024L, 1024);
            }
            r.method_85();
            Encoding    encoding   = Encodings.GetEncoding((int)r.Model.Header.DrawingCodePage);
            Interface40 nterface40 = (Interface40) new Class725(this.stream_0, encoding, version);

            DxfProxyEntity.Class361 class361 = new DxfProxyEntity.Class361((Interface29) new Class990((Stream)null, nterface40, this.dwgVersion_0 > DwgVersion.Dwg1018 ? (Interface40) new Class728(this.stream_1, encoding, version) : nterface40, nterface40));
            while (r.CurrentGroup.Code != 0)
            {
                switch (Class820.smethod_2(r.CurrentGroup.Code))
                {
                case Enum5.const_8:
                case Enum5.const_9:
                case Enum5.const_14:
                case Enum5.const_15:
                    ulong            handle           = (ulong)r.CurrentGroup.Value;
                    DxfHandledObject dxfHandledObject = new DxfHandledObject();
                    dxfHandledObject.SetHandle(handle);
                    DxfObjectReference dxfObjectReference = new DxfObjectReference((IDxfHandledObject)dxfHandledObject);
                    Struct18           group1             = new Struct18(r.CurrentGroup.Code, (object)dxfObjectReference);
                    class361.imethod_0(group1);
                    r.method_85();
                    continue;

                case Enum5.const_13:
                    int             code    = r.CurrentGroup.Code;
                    WW.Math.Point3D point3D = new WW.Math.Point3D((double)r.CurrentGroup.Value, 0.0, 0.0);
                    r.method_85();
                    if (r.CurrentGroup.Code == code + 10)
                    {
                        point3D.Y = (double)r.CurrentGroup.Value;
                        r.method_85();
                        if (r.CurrentGroup.Code == code + 20)
                        {
                            point3D.Z = (double)r.CurrentGroup.Value;
                            r.method_85();
                        }
                    }
                    Struct18 group2 = new Struct18(code, (object)point3D);
                    class361.imethod_0(group2);
                    continue;

                default:
                    class361.imethod_0(r.CurrentGroup);
                    r.method_85();
                    continue;
                }
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Saves a block to a dxf file.
        /// </summary>
        /// <param name="file">Dxf file name.</param>
        /// <param name="version">Version of the dxf database version.</param>
        /// <param name="isBinary">Defines if the file will be saved as binary, by default it will be saved as text</param>
        /// <returns>Return true if the file has been successfully save, false otherwise.</returns>
        public bool Save(string file, DxfVersion version, bool isBinary = false)
        {
            DxfDocument dwg = new DxfDocument(version);
            dwg.DrawingVariables.InsBase = this.position;
            dwg.DrawingVariables.InsUnits = this.Record.Units;

            Block copy = (Block) this.Clone();
            dwg.AddEntity(copy.Entities);

            foreach (AttributeDefinition attdef in copy.AttributeDefinitions.Values)
            {
                dwg.AddEntity(attdef);
            }

            return dwg.Save(file, isBinary);
        }
Esempio n. 30
0
 /// <summary>
 /// Saves a block to a text dxf file.
 /// </summary>
 /// <param name="file">Dxf file name.</param>
 /// <param name="version">Version of the dxf database version.</param>
 /// <returns>Return true if the file has been successfully save, false otherwise.</returns>
 public bool Save(string file, DxfVersion version)
 {
     return(Save(file, version, false));
 }
Esempio n. 31
0
        /// <summary>
        /// Adds a new <see cref="IEntityObject">entity</see> to the document.
        /// </summary>
        /// <param name="entity">An <see cref="IEntityObject">entity</see></param>
        //public void AddEntity(IEntidadObjeto entidad)
        //{
        //    // check if the entity has not been added to the document
        //    if (this.addedObjects.ContainsKey(entidad))
        //        throw new ArgumentException("The entity " + entidad.Tipo + " object has already been added to the document.", "entity");
        //    this.addedObjects.Add(entidad, entidad);
        //    if (entidad.XData != null)
        //    {
        //        foreach (ApplicationRegistry appReg in entidad.XData.Keys)
        //        {
        //            if (!this.appRegisterNames.ContainsKey(appReg.Name))
        //            {
        //                this.appRegisterNames.Add(appReg.Name, appReg);
        //            }
        //        }
        //    }
        //    if (!this.layers.ContainsKey(entidad.Layer.Name))
        //    {
        //        if (!this.lineTypes.ContainsKey(entidad.Layer.LineType.Name))
        //        {
        //            this.lineTypes.Add(entidad.Layer.LineType.Name, entidad.Layer.LineType);
        //        }
        //        this.layers.Add(entidad.Layer.Name, entidad.Layer);
        //    }
        //    if (!this.lineTypes.ContainsKey(entidad.LineType.Name))
        //    {
        //        this.lineTypes.Add(entidad.LineType.Name, entidad.LineType);
        //    }
        //    switch (entidad.Tipo)
        //    {
        //        case EntidadTipo.Arco:
        //            this.arcos.Add((Arco)entidad);
        //            break;
        //        case EntidadTipo.Circulo:
        //            this.circulos.Add((Circulo)entidad);
        //            break;
        //        //case EntidadTipo.Ellipse:
        //        //    this.ellipses.Add((Ellipse)entidad);
        //        //    break;
        //        //case EntidadTipo.NurbsCurve:
        //        //    throw new NotImplementedException("Nurbs curves not avaliable at the moment.");
        //        //    this.nurbsCurves.Add((NurbsCurve)entidad);
        //        //    break;
        //        case EntidadTipo.Punto:
        //            this.puntos.Add((Punto)entidad);
        //            break;
        //        //case EntidadTipo.Face3D:
        //        //    this.faces3d.Add((Face3d)entidad);
        //        //    break;
        //        //case EntidadTipo.Solid:
        //        //    this.solids.Add((Solid)entidad);
        //        //    break;
        //        //case EntidadTipo.Insert:
        //        //    // if the block definition has already been added, we do not need to do anything else
        //        //    if (!this.blocks.ContainsKey(((Insert)entidad).Block.Name))
        //        //    {
        //        //        this.blocks.Add(((Insert)entidad).Block.Name, ((Insert)entidad).Block);
        //        //        if (!this.layers.ContainsKey(((Insert)entidad).Block.Layer.Name))
        //        //        {
        //        //            this.layers.Add(((Insert)entidad).Block.Layer.Name, ((Insert)entidad).Block.Layer);
        //        //        }
        //        //        //for new block definitions configure its entities
        //        //        foreach (IEntidadObjeto blockEntity in ((Insert)entidad).Block.Entities)
        //        //        {
        //        //            // check if the entity has not been added to the document
        //        //            if (this.addedObjects.ContainsKey(blockEntity))
        //        //                throw new ArgumentException("The entity " + blockEntity.Type +
        //        //                                            " object of the block " + ((Insert)entidad).Block.Name +
        //        //                                            " has already been added to the document.", "entity");
        //        //            this.addedObjects.Add(blockEntity, blockEntity);
        //        //            if (!this.layers.ContainsKey(blockEntity.Layer.Name))
        //        //            {
        //        //                this.layers.Add(blockEntity.Layer.Name, blockEntity.Layer);
        //        //            }
        //        //            if (!this.lineTypes.ContainsKey(blockEntity.LineType.Name))
        //        //            {
        //        //                this.lineTypes.Add(blockEntity.LineType.Name, blockEntity.LineType);
        //        //            }
        //        //        }
        //        //        //for new block definitions configure its attributes
        //        //        foreach (Attribute attribute in ((Insert)entidad).Attributes)
        //        //        {
        //        //            if (!this.layers.ContainsKey(attribute.Layer.Name))
        //        //            {
        //        //                this.layers.Add(attribute.Layer.Name, attribute.Layer);
        //        //            }
        //        //            if (!this.lineTypes.ContainsKey(attribute.LineType.Name))
        //        //            {
        //        //                this.lineTypes.Add(attribute.LineType.Name, attribute.LineType);
        //        //            }
        //        //            AttributeDefinition attDef = attribute.Definition;
        //        //            if (!this.layers.ContainsKey(attDef.Layer.Name))
        //        //            {
        //        //                this.layers.Add(attDef.Layer.Name, attDef.Layer);
        //        //            }
        //        //            if (!this.lineTypes.ContainsKey(attDef.LineType.Name))
        //        //            {
        //        //                this.lineTypes.Add(attDef.LineType.Name, attDef.LineType);
        //        //            }
        //        //            if (!this.textStyles.ContainsKey(attDef.Style.Name))
        //        //            {
        //        //                this.textStyles.Add(attDef.Style.Name, attDef.Style);
        //        //            }
        //        //        }
        //        //    }
        //        //    this.inserts.Add((Insert)entidad);
        //        //    break;
        //        case EntidadTipo.Linea:
        //            this.lineas.Add((Linea)entidad);
        //            break;
        //        //case EntidadTipo.LightWeightPolyline:
        //        //    this.polylines.Add((IPolyline)entidad);
        //        //    break;
        //        //case EntidadTipo.Polyline:
        //        //    this.polylines.Add((IPolyline)entidad);
        //        //    break;
        //        //case EntidadTipo.Polyline3d:
        //        //    this.polylines.Add((IPolyline)entidad);
        //        //    break;
        //        //case EntidadTipo.PolyfaceMesh:
        //        //    this.polylines.Add((IPolyline)entidad);
        //        //    break;
        //        //case EntidadTipo.Text:
        //        //    if (!this.textStyles.ContainsKey(((Text)entidad).Style.Name))
        //        //    {
        //        //        this.textStyles.Add(((Text)entidad).Style.Name, ((Text)entidad).Style);
        //        //    }
        //        //    this.texts.Add((Text)entidad);
        //        //    break;
        //        //case EntidadTipo.Vertex:
        //        //    throw new ArgumentException("The entity " + entity.Type + " is only allowed as part of another entity", "entity");
        //        //case EntidadTipo.PolylineVertex:
        //        //    throw new ArgumentException("The entity " + entity.Type + " is only allowed as part of another entity", "entity");
        //        //case EntidadTipo.Polyline3dVertex:
        //        //    throw new ArgumentException("The entity " + entity.Type + " is only allowed as part of another entity", "entity");
        //        //case EntidadTipo.PolyfaceMeshVertex:
        //        //    throw new ArgumentException("The entity " + entity.Type + " is only allowed as part of another entity", "entity");
        //        //case EntidadTipo.PolyfaceMeshFace:
        //        //    throw new ArgumentException("The entity " + entity.Type + " is only allowed as part of another entity", "entity");
        //        //case EntidadTipo.AttributeDefinition:
        //        //    throw new ArgumentException("The entity " + entity.Type + " is only allowed as part of another entity", "entity");
        //        //case EntidadTipo.Attribute:
        //        //    throw new ArgumentException("The entity " + entity.Type + " is only allowed as part of another entity", "entity");
        //        default:
        //            throw new NotImplementedException("La entidad " + entidad.Tipo + " no esta implementada o es desconocida");
        //    }
        //}
        /// <summary>
        /// Carga un archivo DXF.
        /// </summary>
        /// <param name="archivo">Nombre del archivo.</param>
        public void Cargar(string archivo)
        {
            if (!File.Exists(archivo))
                throw new FileNotFoundException("No se puede encontrar el archivo " + archivo + ".", archivo);

            this.fileName = Path.GetFileNameWithoutExtension(archivo);

            CultureInfo cultureInfo = CultureInfo.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            DxfReader dxfReader = new DxfReader(archivo);
            dxfReader.Open();
            dxfReader.Read();
            dxfReader.Close();

            //header information
            this.version = dxfReader.Version;
            this.handleCount = Convert.ToInt32(dxfReader.HandleSeed, 16);

            //tables information
            //this.appRegisterNames = dxfReader.ApplicationRegistrationIds;
            //this.layers = dxfReader.Layers;
            //this.lineTypes = dxfReader.LineTypes;
            //this.textStyles = dxfReader.TextStyles;
            //this.blocks = dxfReader.Blocks;

            //entities information
            this.arcos = dxfReader.Arcos;
            this.circulos = dxfReader.Circulos;
            this.elipses = dxfReader.Elipses;
            this.puntos = dxfReader.Puntos;
            //this.faces3d = dxfReader.Faces3d;
            //this.solids = dxfReader.Solids;
            this.polilineas = dxfReader.Polilineas;
            this.lineas = dxfReader.Lineas;
            //this.inserts = dxfReader.Inserts;
            //this.texts = dxfReader.Texts;

            Thread.CurrentThread.CurrentCulture = cultureInfo;
        }
Esempio n. 32
0
 /// <summary>
 /// Initalizes a new instance of the <c>DxfDocument</c> class.
 /// </summary>
 /// <param name="version">AutoCAD drawing database version number.</param>
 public DxfDocument(DxfVersion version)
     : this(new HeaderVariables {
     AcadVer = version
 })
 {
 }
 /// <summary>
 /// Initializes a new instance of <c>DxfVersionNotSupportedException</c>
 /// </summary>
 /// <param name="version">DXF file version.</param>
 public DxfVersionNotSupportedException(DxfVersion version)
 {
     this.version = version;
 }
Esempio n. 34
0
        public static MemoryStream Export(Sketch sketch, DxfVersion version, DxfFlags flags, double precision = 0.01)
        {
            var exporter = new DxfSketchExporter();

            return(exporter._Export(sketch, version, flags, precision));
        }
 /// <summary>
 /// Initializes a new instance of <c>DxfVersionNotSupportedException</c>
 /// </summary>
 /// <param name="message">Exception message.</param>
 /// <param name="version">DXF file version.</param>
 public DxfVersionNotSupportedException(string message, DxfVersion version)
     : base(message)
 {
     this.version = version;
 }
Esempio n. 36
0
        /// <summary>
        /// Loads a dxf ASCII file.
        /// </summary>
        /// <param name="file">File name.</param>
        public void Load(string file)
        {
            if (!File.Exists(file))
            {
                throw new FileNotFoundException("File " + file + " not found.", file);
            }

            this.fileName = Path.GetFileNameWithoutExtension(file);

            CultureInfo cultureInfo = CultureInfo.CurrentCulture;

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            DxfReader dxfReader = new DxfReader(file);

            dxfReader.Open();
            dxfReader.Read();
            dxfReader.Close();

            //header information
            this.version     = dxfReader.Version;
            this.handleCount = Convert.ToInt32(dxfReader.HandleSeed, 16);

            //tables information
            this.appRegisterNames = dxfReader.ApplicationRegistrationIds;
            this.layers           = dxfReader.Layers;
            this.lineTypes        = dxfReader.LineTypes;
            this.textStyles       = dxfReader.TextStyles;
            this.blocks           = dxfReader.Blocks;

            //entities information
            this.arcs      = dxfReader.Arcs;
            this.circles   = dxfReader.Circles;
            this.ellipses  = dxfReader.Ellipses;
            this.points    = dxfReader.Points;
            this.faces3d   = dxfReader.Faces3d;
            this.solids    = dxfReader.Solids;
            this.polylines = dxfReader.Polylines;
            this.lines     = dxfReader.Lines;
            this.inserts   = dxfReader.Inserts;
            this.texts     = dxfReader.Texts;

            Thread.CurrentThread.CurrentCulture = cultureInfo;

            #region reasign handles
            //add default viewports
            //foreach (ViewPort viewPort in this.viewports.Values )
            //{
            //    this.handleCount = viewPort.AsignHandle(this.handleCount);
            //}

            ////add default layer
            //Layer.PlotStyleHandle = Conversion.Hex(this.handleCount++);
            //Layer byDefault = Layer.Default;
            //this.layers.Add(byDefault.Name, byDefault);
            //this.handleCount = byDefault.AsignHandle(this.handleCount);

            //// add default line types
            //LineType byLayer = LineType.ByLayer;
            //LineType byBlock = LineType.ByBlock;
            //this.lineTypes.Add(byLayer.Name, byLayer);
            //this.handleCount = byLayer.AsignHandle(this.handleCount);
            //this.lineTypes.Add(byBlock.Name, byBlock);
            //this.handleCount = byBlock.AsignHandle(this.handleCount);

            //// add default text style
            //TextStyle defaultStyle = TextStyle.Default;
            //this.textStyles.Add(defaultStyle.Name, defaultStyle);
            //this.handleCount = defaultStyle.AsignHandle(this.handleCount);

            //// add default blocks
            //Block modelSpace = Block.ModelSpace;
            //Block paperSpace = Block.PaperSpace;
            //this.blocks.Add(modelSpace.Name, modelSpace);
            //this.handleCount = modelSpace.AsignHandle(this.handleCount);
            //this.blocks.Add(paperSpace.Name, paperSpace);
            //this.handleCount = paperSpace.AsignHandle(this.handleCount);

            //// add default application registry
            //ApplicationRegistry defaultAppId = ApplicationRegistry.Default;
            //this.appRegisterNames.Add(defaultAppId.Name, defaultAppId);
            //this.handleCount = defaultAppId.AsignHandle(this.handleCount);

            //add default dimension style
            //foreach (DimensionStyle dimStyle in this.dimStyles.Values)
            //{
            //    this.handleCount = dimStyle.AsignHandle(this.handleCount);
            //}

            //foreach (Block block in this.blocks.Values)
            //{
            //    this.handleCount = block.AsignHandle(this.handleCount);
            //}

            #endregion
        }
Esempio n. 37
0
 public Class918(DxfVersion outputVersion)
 {
     this.dxfVersion_0 = outputVersion;
 }
Esempio n. 38
0
        /// <summary>
        /// Initalizes a new instance of the <c>DxfDocument</c> class.
        /// </summary>
        public DxfDocument()
        {
            this.addedObjects     = new Hashtable(); // keeps track of the added object to avoid duplicates
            this.version          = this.version;
            this.viewports        = new Dictionary <string, ViewPort>();
            this.layers           = new Dictionary <string, Layer>();
            this.lineTypes        = new Dictionary <string, LineType>();
            this.textStyles       = new Dictionary <string, TextStyle>();
            this.blocks           = new Dictionary <string, Block>();
            this.appRegisterNames = new Dictionary <string, ApplicationRegistry>();
            this.dimStyles        = new Dictionary <string, DimensionStyle>();

            ////add default viewports
            //ViewPort active = ViewPort.Active;
            //this.viewports.Add(active.Name, active);
            //this.handleCount = active.AsignHandle(this.handleCount);

            ////add default layer
            //Layer.PlotStyleHandle = Conversion.Hex(this.handleCount++);
            //Layer byDefault = Layer.Default;
            //this.layers.Add(byDefault.Name, byDefault);
            //this.handleCount = byDefault.AsignHandle(this.handleCount);

            //// add default line types
            //LineType byLayer = LineType.ByLayer;
            //LineType byBlock = LineType.ByBlock;
            //this.lineTypes.Add(byLayer.Name, byLayer);
            //this.handleCount = byLayer.AsignHandle(this.handleCount);
            //this.lineTypes.Add(byBlock.Name, byBlock);
            //this.handleCount = byBlock.AsignHandle(this.handleCount);

            //// add default text style
            //TextStyle defaultStyle = TextStyle.Default;
            //this.textStyles.Add(defaultStyle.Name, defaultStyle);
            //this.handleCount = defaultStyle.AsignHandle(this.handleCount);

            //// add default blocks
            //Block modelSpace = Block.ModelSpace;
            //Block paperSpace = Block.PaperSpace;
            //this.blocks.Add(modelSpace.Name, modelSpace);
            //this.handleCount = modelSpace.AsignHandle(this.handleCount);
            //this.blocks.Add(paperSpace.Name, paperSpace);
            //this.handleCount = paperSpace.AsignHandle(this.handleCount);

            //// add default application registry
            //ApplicationRegistry defaultAppId = ApplicationRegistry.Default;
            //this.appRegisterNames.Add(defaultAppId.Name, defaultAppId);
            //this.handleCount = defaultAppId.AsignHandle(this.handleCount);

            ////add default dimension style
            //DimensionStyle defaultDimStyle = DimensionStyle.Default;
            //this.dimStyles.Add(defaultDimStyle.Name, defaultDimStyle);
            //this.handleCount = defaultDimStyle.AsignHandle(this.handleCount);

            this.arcs        = new List <Arc>();
            this.ellipses    = new List <Ellipse>();
            this.nurbsCurves = new List <NurbsCurve>();
            this.faces3d     = new List <Face3d>();
            this.solids      = new List <Solid>();
            this.inserts     = new List <Insert>();
            this.polylines   = new List <IPolyline>();
            this.lines       = new List <Line>();
            this.circles     = new List <Circle>();
            this.points      = new List <Point>();
            this.texts       = new List <Text>();
        }
Esempio n. 39
0
        public static void DumpFile(string file, string output)
        {
            // check if the dxf actually exists
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(file);

            // optionally you can save the information to a text file
            bool outputLog = !string.IsNullOrEmpty(output);

            System.IO.TextWriter writer = null;
            if (outputLog)
            {
                writer = new System.IO.StreamWriter(System.IO.File.Create(output));
                System.Console.SetOut(writer);
            }

            if (!fileInfo.Exists)
            {
                System.Console.WriteLine("THE FILE {0} DOES NOT EXIST", file);
                System.Console.WriteLine();

                System.Console.WriteLine("Press a key to continue...");
                System.Console.ReadLine();

                return;
            }

            bool       isBinary;
            DxfVersion dxfVersion = netDxf.DxfDocument.CheckDxfFileVersion(file, out isBinary);

            // check if the file is a dxf
            if (dxfVersion == DxfVersion.Unknown)
            {
                System.Console.WriteLine("THE FILE {0} IS NOT A VALID DXF OR THE DXF DOES NOT INCLUDE VERSION INFORMATION IN THE HEADER SECTION", file);
                System.Console.WriteLine();

                System.Console.WriteLine("Press a key to continue...");
                System.Console.ReadLine();

                return;
            }

            // check if the dxf file version is supported
            if (dxfVersion < DxfVersion.AutoCad2000)
            {
                System.Console.WriteLine("THE FILE {0} IS NOT A SUPPORTED DXF", file);
                System.Console.WriteLine();

                System.Console.WriteLine("FILE VERSION: {0}", dxfVersion);
                System.Console.WriteLine();

                System.Console.WriteLine("Press a key to continue...");
                System.Console.ReadLine();

                return;
            }

            DxfDocument dxf = DxfDocument.Load(file);

            // check if there has been any problems loading the file,
            // this might be the case of a corrupt file or a problem in the library
            if (dxf == null)
            {
                System.Console.WriteLine("ERROR LOADING {0}", file);
                System.Console.WriteLine();

                System.Console.WriteLine("Press a key to continue...");
                System.Console.ReadLine();

                return;
            }

            // the dxf has been properly loaded, let's show some information about it
            System.Console.WriteLine("FILE NAME: {0}", file);
            System.Console.WriteLine("\tbinary dxf: {0}", isBinary);
            System.Console.WriteLine();
            System.Console.WriteLine("FILE VERSION: {0}", dxf.DrawingVariables.AcadVer);
            System.Console.WriteLine();
            System.Console.WriteLine("FILE COMMENTS: {0}", dxf.Comments.Count);
            foreach (var o in dxf.Comments)
            {
                System.Console.WriteLine("\t{0}", o);
            }
            System.Console.WriteLine();
            System.Console.WriteLine("FILE TIME:");
            System.Console.WriteLine("\tdrawing created (UTC): {0}.{1}", dxf.DrawingVariables.TduCreate, dxf.DrawingVariables.TduCreate.Millisecond.ToString("000"));
            System.Console.WriteLine("\tdrawing last update (UTC): {0}.{1}", dxf.DrawingVariables.TduUpdate, dxf.DrawingVariables.TduUpdate.Millisecond.ToString("000"));
            System.Console.WriteLine("\tdrawing edition time: {0}", dxf.DrawingVariables.TdinDwg);
            System.Console.WriteLine();
            System.Console.WriteLine("APPLICATION REGISTRIES: {0}", dxf.ApplicationRegistries.Count);

            foreach (var o in dxf.ApplicationRegistries)
            {
                System.Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.ApplicationRegistries.GetReferences(o.Name).Count);
            }
            System.Console.WriteLine();

            System.Console.WriteLine("LAYERS: {0}", dxf.Layers.Count);
            foreach (var o in dxf.Layers)
            {
                System.Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.Layers.GetReferences(o).Count);
            }
            System.Console.WriteLine();

            System.Console.WriteLine("LINE TYPES: {0}", dxf.LineTypes.Count);
            foreach (var o in dxf.LineTypes)
            {
                System.Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.LineTypes.GetReferences(o.Name).Count);
            }
            System.Console.WriteLine();

            System.Console.WriteLine("TEXT STYLES: {0}", dxf.TextStyles.Count);
            foreach (var o in dxf.TextStyles)
            {
                System.Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.TextStyles.GetReferences(o.Name).Count);
            }
            System.Console.WriteLine();

            System.Console.WriteLine("DIMENSION STYLES: {0}", dxf.DimensionStyles.Count);
            foreach (var o in dxf.DimensionStyles)
            {
                System.Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.DimensionStyles.GetReferences(o.Name).Count);
            }
            System.Console.WriteLine();

            System.Console.WriteLine("MLINE STYLES: {0}", dxf.MlineStyles.Count);
            foreach (var o in dxf.MlineStyles)
            {
                System.Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.MlineStyles.GetReferences(o.Name).Count);
            }
            System.Console.WriteLine();

            System.Console.WriteLine("UCSs: {0}", dxf.UCSs.Count);
            foreach (var o in dxf.UCSs)
            {
                System.Console.WriteLine("\t{0}", o.Name);
            }
            System.Console.WriteLine();

            System.Console.WriteLine("BLOCKS: {0}", dxf.Blocks.Count);
            foreach (var o in dxf.Blocks)
            {
                System.Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.Blocks.GetReferences(o.Name).Count);
            }
            System.Console.WriteLine();

            System.Console.WriteLine("LAYOUTS: {0}", dxf.Layouts.Count);
            foreach (var o in dxf.Layouts)
            {
                System.Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.Layouts.GetReferences(o.Name).Count);
            }
            System.Console.WriteLine();

            System.Console.WriteLine("IMAGE DEFINITIONS: {0}", dxf.ImageDefinitions.Count);
            foreach (var o in dxf.ImageDefinitions)
            {
                System.Console.WriteLine("\t{0}; File name: {1}; References count: {2}", o.Name, o.FileName, dxf.ImageDefinitions.GetReferences(o.Name).Count);
            }
            System.Console.WriteLine();

            System.Console.WriteLine("GROUPS: {0}", dxf.Groups.Count);
            foreach (var o in dxf.Groups)
            {
                System.Console.WriteLine("\t{0}; Entities count: {1}", o.Name, o.Entities.Count);
            }
            System.Console.WriteLine();

            // the entities lists contain the geometry that has a graphical representation in the drawing across all layouts,
            // to get the entities that belongs to an specific layout you can get the references through the Layouts.GetReferences(name)
            // or check the EntityObject.Owner.Record.Layout property
            System.Console.WriteLine("ENTITIES:");
            System.Console.WriteLine("\t{0}; count: {1}", EntityType.Arc, dxf.Arcs.Count);
            System.Console.WriteLine("\t{0}; count: {1}", EntityType.AttributeDefinition, dxf.AttributeDefinitions.Count);
            System.Console.WriteLine("\t{0}; count: {1}", EntityType.Circle, dxf.Circles.Count);
            System.Console.WriteLine("\t{0}; count: {1}", EntityType.Dimension, dxf.Dimensions.Count);
            System.Console.WriteLine("\t{0}; count: {1}", EntityType.Ellipse, dxf.Ellipses.Count);
            System.Console.WriteLine("\t{0}; count: {1}", EntityType.Face3D, dxf.Faces3d.Count);
            System.Console.WriteLine("\t{0}; count: {1}", EntityType.Hatch, dxf.Hatches.Count);
            System.Console.WriteLine("\t{0}; count: {1}", EntityType.Image, dxf.Images.Count);
            System.Console.WriteLine("\t{0}; count: {1}", EntityType.Insert, dxf.Inserts.Count);
            System.Console.WriteLine("\t{0}; count: {1}", EntityType.LightWeightPolyline, dxf.LwPolylines.Count);
            System.Console.WriteLine("\t{0}; count: {1}", EntityType.Line, dxf.Lines.Count);
            System.Console.WriteLine("\t{0}; count: {1}", EntityType.Mesh, dxf.Meshes.Count);
            System.Console.WriteLine("\t{0}; count: {1}", EntityType.MLine, dxf.MLines.Count);
            System.Console.WriteLine("\t{0}; count: {1}", EntityType.MText, dxf.MTexts.Count);
            System.Console.WriteLine("\t{0}; count: {1}", EntityType.Point, dxf.Points.Count);
            System.Console.WriteLine("\t{0}; count: {1}", EntityType.PolyfaceMesh, dxf.PolyfaceMeshes.Count);
            System.Console.WriteLine("\t{0}; count: {1}", EntityType.Polyline, dxf.Polylines.Count);
            System.Console.WriteLine("\t{0}; count: {1}", EntityType.Solid, dxf.Solids.Count);
            System.Console.WriteLine("\t{0}; count: {1}", EntityType.Spline, dxf.Splines.Count);
            System.Console.WriteLine("\t{0}; count: {1}", EntityType.Text, dxf.Texts.Count);
            System.Console.WriteLine("\t{0}; count: {1}", EntityType.Ray, dxf.Rays.Count);
            System.Console.WriteLine("\t{0}; count: {1}", EntityType.Viewport, dxf.Viewports.Count);
            System.Console.WriteLine("\t{0}; count: {1}", EntityType.XLine, dxf.XLines.Count);
            System.Console.WriteLine();
        }