diff --git a/README.md b/README.md index 63f45a4f..ed8190fc 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,49 @@ # netDxf -netDxf 2.0.3 Copyright(C) 2009-2017 Daniel Carvajal, Licensed under LGPL +netDxf 2.1.0 Copyright(C) 2009-2018 Daniel Carvajal, Licensed under LGPL ## Description netDxf is a .net library programmed in C# to read and write AutoCAD dxf files. It supports AutoCad2000, AutoCad2004, AutoCad2007, AutoCad2010, AutoCad2013, and AutoCad2018 dxf database versions, in both text and binary format. -I tried to keep the use as simple as posible, for example you will not need to fill up the table section with layers, styles or line type definitions. The DxfDocument will take care of that everytime a new item is added and the load and save its done with just one line of code. -If you need more information, you can find the official dxf documentation in -[http://help.autodesk.com/view/ACD/2016/ENU/](http://help.autodesk.com/view/ACD/2016/ENU/) +The library is easy to use and I tried to keep the procedures as straightforward as possible, for example you will not need to fill up the table section with layers, styles or line type definitions. The DxfDocument will take care of that every time a new item is added. + +If you need more information, you can find the official dxf documentation [here](https://help.autodesk.com/view/OARX/2019/ENU/?guid=GUID-235B22E0-A567-4CF6-92D3-38A2306D73F3) Code example: ```c# public static void Main() - { - // by default it will create an AutoCad2000 dxf version - DxfDocument dxf = new DxfDocument(); - // add your entities here - dxf.AddEntity(entity); - // save to file - dxf.Save(filename); +{ + // your dxf file name + string file = "sample.dxf"; + + // by default it will create an AutoCad2000 DXF version + DxfDocument dxf = new DxfDocument(); + // an entity + Line entity = new Line(new Vector2(5, 5), new Vector2(10, 5)); + // add your entities here + dxf.AddEntity(entity); + // save to file + dxf.Save(file); - // load file - DxfDocument dxfLoad = DxfDocument.Load(filename); - } + bool isBinary; + // 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 loaded = DxfDocument.Load(file); +} ``` -### Samples and Demos +## Samples and Demos Are contained in the source code. Well, at the moment they are just tests for the work in progress. -### Dependencies and distribution -* .NET Framework 4.5 +## Dependencies and distribution +* .NET Framework 4.5. netDxf only references the NET libraries System.dll and System.Drawing.dll ## Compiling To compile the source code you will need Visual Studio 2015. - ## Development Status -Stable. -### Supported entities +Stable. See [changelog.txt](https://github.com/haplokuon/netDxf/blob/master/doc/Changelog.txt) or the [wiki page](https://github.com/haplokuon/netDxf/wiki) for information on the latest changes. +## Supported entities * 3dFace * Arc * Circle @@ -53,6 +62,7 @@ Stable. * PolyfaceMesh * Polyline * Ray +* Shape * Solid * Spline * Text @@ -64,4 +74,5 @@ Stable. All entities can be grouped and may contain extended data information. AutoCad Table entities will be imported as Inserts (block references). -The libray will never be able to read some entities like Regions and 3dSolids, since they depend on proprietary data. +Both simple and complex line types are supported. +The libray will never be able to read some entities like Regions and 3dSolids, since they depend on undocumented proprietary data. diff --git a/TestDxfDocument/Program.cs b/TestDxfDocument/Program.cs index 9829e037..62023732 100644 --- a/TestDxfDocument/Program.cs +++ b/TestDxfDocument/Program.cs @@ -13,6 +13,7 @@ using netDxf.Tables; using netDxf.Units; using Attribute = netDxf.Entities.Attribute; +using FontStyle = netDxf.Tables.FontStyle; using Image = netDxf.Entities.Image; using Point = netDxf.Entities.Point; using Trace = netDxf.Entities.Trace; @@ -24,13 +25,20 @@ namespace TestDxfDocument /// public class Program { - public static void Main() - { + { DxfDocument doc = Test(@"sample.dxf"); + + #region Samples for new and modified features 2.1.0 + + //Shape(); + //ComplexLineType(); + //TextStyle(); //ReadWriteFromStream(); //ReadWriteFromStream2(); + #endregion + #region Samples for new and modified features 2.0.1 //DimensionUserTextWithTwoLines(); @@ -206,6 +214,100 @@ public static void Main() #endregion } + #region Samples for new and modified features 2.1.0 + + private static void Shape() + { + // create the shape style from the file where the shape definitions are stored + ShapeStyle style = new ShapeStyle("shape.shx"); + // create the shape entity from the style where the same named "MyShape" is stored (name case is ignored) + Shape shape = new Shape("MyShape", style); + + DxfDocument doc = new DxfDocument(); + // when a shape is added to a DxfDocument it will be checked that the style associated with the shape, + // actually contains a shape definition with the name specified in the shape constructor, in this case "MyShape" + // this is done reading the SHP file associated with the SHX (compiled SHP) file. + // this SHP must be present in the same folder as the SHX or in one of the support folder defined in the DxfDocument. + // in this case a sub-folder of the executable + doc.SupportFolders.Add(@".\Support"); + doc.AddEntity(shape); + doc.Save("sample shape.dxf"); + + // when loading a dxf file that contains shape entities, we need to deal with the same problem when adding a shape entity to the document. + // we need to specified the folder or folder where to look for the SHP file + DxfDocument loaded = DxfDocument.Load("sample shape.dxf", new[] { @".\Support" }); + + } + + private static void ComplexLineType() + { + // complex line types might contain segments with shapes and/or text + // when shape segments are used we need to deal with the same problem as the Shape entity, + // we need a way to find the SHP file equivalent to the SHX file (see Shape() method) + // in this case, for simplicity, the LIN file and the SHP file that contains the definitions for the shapes referenced by the line types + + // create two linetypes from their definitions in the LIN file + // this line type contains a text segment + Linetype lt1 = Linetype.Load(@".\Support\acadiso.lin", "GAS_LINE"); + // this line type contains two shape segments + Linetype lt2 = Linetype.Load(@".\Support\acad.lin", "BATTING"); + + Line line1 = new Line(Vector2.Zero, new Vector2(10, 10)); + line1.Linetype = lt1; + line1.LinetypeScale = 0.1; + + Line line2 = new Line(new Vector2(5,0), new Vector2(15,10)); + line2.Linetype = lt2; + line2.LinetypeScale = 1.5; + + // create a DxfDocument specifying the support folders where we the SHP file is present. + // the line type definitions in the LIN file that contains shape segments stores the name in it, + // but the dxf requires to save the number associated with that shape, and it needs to be found in the SHP file + DxfDocument doc = new DxfDocument(new[] { @".\Support" }); + doc.AddEntity(line1); + doc.AddEntity(line2); + doc.Save("sample complex linetypes.dxf"); + + // more functionality has been added for the linetypes + // similar methods are also present in the Linetype class, the big difference is that, since the linetype list belongs to a document, + // the DxfDocument support folders will be used to find the specified LIN file + // add an individual linetype from a file, it gives you the option to redefine the actual definition in case another with the same name already exists + doc.Linetypes.AddFromFile("acad.lin", "DIVIDE", true); + // add the all linetypes contained in the specified LIN file to the document list, + // it gives you the option to redefine the actual definition in case another with the same name already exists + doc.Linetypes.AddFromFile("acad.lin", false); + // save all linetypes defined in the DxfDocument to a file + doc.Linetypes.Save(@"MyLinetypes.lin", true); + // gets the list of linetype names contained in a LIN file + List names = doc.Linetypes.NamesFromFile("acadiso.lin"); + + // again same problem when loading the SHP files need to be found in one of the support folders + DxfDocument loaded = DxfDocument.Load("sample complex linetypes.dxf", new[] { @".\Support" }); + + } + + private static void TextStyle() + { + // now we can work with text style without specifying the associated file. + // this is applicable only for true type fonts that are installed in the system font folder + // when text styles are created this way the font information, in the dxf, is stored in the extended data of the style + TextStyle style = new TextStyle("MyStyle", "Helvetica", FontStyle.Italic | FontStyle.Bold); + + // create a new text with the new style + MText text = new MText("This is a sample text") + { + Position = new Vector3(5.0, 5.0, 0.0), + Height = 5.0, + Style = style + }; + + DxfDocument doc = new DxfDocument(); + doc.AddEntity(text); + doc.Save("TextStyle.dxf"); + + DxfDocument loaded = DxfDocument.Load("TextStyle.dxf"); + } + private static void ReadWriteFromStream() { // They will return true or false if the operation has been carried out successfully or not. @@ -295,7 +397,9 @@ private static void ReadWriteFromStream2() doc2.Save("doc2.dxf"); } - + + #endregion + #region Samples for new and modified features 2.0.1 private static void DimensionUserTextWithTwoLines() @@ -1084,7 +1188,7 @@ private static void SplineFitPoints() private static void ImageClippingBoundary() { - ImageDefinition imageDef = new ImageDefinition(@".\img\image02.jpg", "MyImage"); + ImageDefinition imageDef = new ImageDefinition("MyImage", @".\img\image02.jpg"); imageDef.ResolutionUnits = ImageResolutionUnits.Centimeters; double width = imageDef.Width/imageDef.HorizontalResolution; double height = imageDef.Height/imageDef.VerticalResolution; @@ -2365,7 +2469,7 @@ private static void BinaryChunkXData() StringBuilder sb = new StringBuilder(); for (int i = 0; i < dataText.Length; i++) { - sb.Append(String.Format("{0:X2}", data[i])); + sb.Append(string.Format("{0:X2}", data[i])); } Console.WriteLine(sb.ToString()); @@ -2948,6 +3052,13 @@ private static void ShowDxfDocumentInformation(DxfDocument dxf) } 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) { @@ -3097,28 +3208,28 @@ private static void ShowDxfDocumentInformation(DxfDocument dxf) 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("\t{0}; File name: {1}; References count: {2}", o.Name, o.File, 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("\t{0}; File name: {1}; References count: {2}", o.Name, o.File, 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("\t{0}; File name: {1}; References count: {2}", o.Name, o.File, 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("\t{0}; File name: {1}; References count: {2}", o.Name, o.File, dxf.UnderlayPdfDefinitions.GetReferences(o.Name).Count); } Console.WriteLine(); @@ -3151,6 +3262,7 @@ private static void ShowDxfDocumentInformation(DxfDocument dxf) 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); @@ -3240,7 +3352,7 @@ private static DxfDocument Test(string file, string output = null) return null; } - DxfDocument dxf = DxfDocument.Load(file); + DxfDocument dxf = DxfDocument.Load(file, new List {@".\Support"}); // 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 @@ -3311,6 +3423,13 @@ private static DxfDocument Test(string file, string output = null) } 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) { @@ -3460,28 +3579,28 @@ private static DxfDocument Test(string file, string output = null) 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("\t{0}; File name: {1}; References count: {2}", o.Name, o.File, 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("\t{0}; File name: {1}; References count: {2}", o.Name, o.File, 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("\t{0}; File name: {1}; References count: {2}", o.Name, o.File, 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("\t{0}; File name: {1}; References count: {2}", o.Name, o.File, dxf.UnderlayPdfDefinitions.GetReferences(o.Name).Count); } Console.WriteLine(); @@ -3576,6 +3695,7 @@ private static DxfDocument Test(string file, string output = null) 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); @@ -3604,7 +3724,7 @@ private static DxfDocument Test(string file, string output = null) // saving to binary dxf dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2013; dxf.Save("binary test.dxf", true); - DxfDocument test = DxfDocument.Load("binary test.dxf"); + DxfDocument test = DxfDocument.Load("binary test.dxf", new List { @".\Support" }); if (outputLog) { @@ -3638,7 +3758,7 @@ private static DxfDocument Test(string file, string output = null) public static void ImageAndClipBoundary() { // a square bitmap - ImageDefinition imageDefinition = new ImageDefinition("image.jpg", "MyImage"); + ImageDefinition imageDefinition = new ImageDefinition("MyImage", "image.jpg"); // image with the same aspect ratio as the original bitmap Image image1 = new Image(imageDefinition, Vector2.Zero, 360, 360 * (imageDefinition.Height / imageDefinition.Width)); @@ -4853,7 +4973,7 @@ private static void WriteImage() //image.Rotation = 30; // you can pass a name that must be unique for the image definiton, by default it will use the file name without the extension - ImageDefinition imageDef2 = new ImageDefinition("img\\image02.jpg", "MyImage"); + ImageDefinition imageDef2 = new ImageDefinition("MyImage", "img\\image02.jpg"); Image image2 = new Image(imageDef2, new Vector3(0, 150, 0), 10, 10); Image image3 = new Image(imageDef2, new Vector3(150, 150, 0), 10, 10); @@ -5472,7 +5592,7 @@ private static void CustomHatchPattern() private static void FilesTest() { - Linetype linetype = Linetype.FromFile("acad.lin", "ACAD_ISO15W100"); + Linetype linetype = Linetype.Load("acad.lin", "ACAD_ISO15W100"); HatchPattern hatch = HatchPattern.FromFile("acad.pat", "zigzag"); } diff --git a/TestDxfDocument/Properties/AssemblyInfo.cs b/TestDxfDocument/Properties/AssemblyInfo.cs index 2de44e44..efdcf67e 100644 --- a/TestDxfDocument/Properties/AssemblyInfo.cs +++ b/TestDxfDocument/Properties/AssemblyInfo.cs @@ -9,8 +9,8 @@ [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("TestDxfDocument")] -[assembly: AssemblyCopyright("Daniel Carvajal © 2016")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/TestDxfDocument/Support/acad.lin b/TestDxfDocument/Support/acad.lin new file mode 100644 index 00000000..b7e8d60c --- /dev/null +++ b/TestDxfDocument/Support/acad.lin @@ -0,0 +1,142 @@ +;; +;; AutoCAD Linetype Definition file +;; Version 3.0 + +;; Copyright 2017 Autodesk, Inc. All rights reserved. +;; +;; Use of this software is subject to the terms of the Autodesk license +;; agreement provided at the time of installation or download, or which +;; otherwise accompanies this software in either electronic or hard copy form. +;; +;; Note: in order to ease migration of this file when upgrading +;; to a future version of AutoCAD, it is recommended that you add +;; your customizations to the User Defined Linetypes section at the +;; end of this file. +;; +*BORDER,Border __ __ . __ __ . __ __ . __ __ . __ __ . +A,.5,-.25,.5,-.25,0,-.25 +*BORDER2,Border (.5x) __.__.__.__.__.__.__.__.__.__.__. +A,.25,-.125,.25,-.125,0,-.125 +*BORDERX2,Border (2x) ____ ____ . ____ ____ . ___ +A,1.0,-.5,1.0,-.5,0,-.5 + +*CENTER,Center ____ _ ____ _ ____ _ ____ _ ____ _ ____ +A,1.25,-.25,.25,-.25 +*CENTER2,Center (.5x) ___ _ ___ _ ___ _ ___ _ ___ _ ___ +A,.75,-.125,.125,-.125 +*CENTERX2,Center (2x) ________ __ ________ __ _____ +A,2.5,-.5,.5,-.5 + +*DASHDOT,Dash dot __ . __ . __ . __ . __ . __ . __ . __ +A,.5,-.25,0,-.25 +*DASHDOT2,Dash dot (.5x) _._._._._._._._._._._._._._._. +A,.25,-.125,0,-.125 +*DASHDOTX2,Dash dot (2x) ____ . ____ . ____ . ___ +A,1.0,-.5,0,-.5 + +*DASHED,Dashed __ __ __ __ __ __ __ __ __ __ __ __ __ _ +A,.5,-.25 +*DASHED2,Dashed (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ +A,.25,-.125 +*DASHEDX2,Dashed (2x) ____ ____ ____ ____ ____ ___ +A,1.0,-.5 + +*DIVIDE,Divide ____ . . ____ . . ____ . . ____ . . ____ +A,.5,-.25,0,-.25,0,-.25 +*DIVIDE2,Divide (.5x) __..__..__..__..__..__..__..__.._ +A,.25,-.125,0,-.125,0,-.125 +*DIVIDEX2,Divide (2x) ________ . . ________ . . _ +A,1.0,-.5,0,-.5,0,-.5 + +*DOT,Dot . . . . . . . . . . . . . . . . . . . . . . . . +A,0,-.25 +*DOT2,Dot (.5x) ........................................ +A,0,-.125 +*DOTX2,Dot (2x) . . . . . . . . . . . . . . +A,0,-.5 + +*HIDDEN,Hidden __ __ __ __ __ __ __ __ __ __ __ __ __ __ +A,.25,-.125 +*HIDDEN2,Hidden (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ +A,.125,-.0625 +*HIDDENX2,Hidden (2x) ____ ____ ____ ____ ____ ____ ____ +A,.5,-.25 + +*PHANTOM,Phantom ______ __ __ ______ __ __ ______ +A,1.25,-.25,.25,-.25,.25,-.25 +*PHANTOM2,Phantom (.5x) ___ _ _ ___ _ _ ___ _ _ ___ _ _ +A,.625,-.125,.125,-.125,.125,-.125 +*PHANTOMX2,Phantom (2x) ____________ ____ ____ _ +A,2.5,-.5,.5,-.5,.5,-.5 + +;; +;; ISO 128 (ISO/DIS 12011) linetypes +;; +;; The size of the line segments for each defined ISO line, is +;; defined for an usage with a pen width of 1 mm. To use them with +;; the other ISO predefined pen widths, the line has to be scaled +;; with the appropriate value (e.g. pen width 0,5 mm -> ltscale 0.5). +;; +*ACAD_ISO02W100,ISO dash __ __ __ __ __ __ __ __ __ __ __ __ __ +A,12,-3 +*ACAD_ISO03W100,ISO dash space __ __ __ __ __ __ +A,12,-18 +*ACAD_ISO04W100,ISO long-dash dot ____ . ____ . ____ . ____ . _ +A,24,-3,0,-3 +*ACAD_ISO05W100,ISO long-dash double-dot ____ .. ____ .. ____ . +A,24,-3,0,-3,0,-3 +*ACAD_ISO06W100,ISO long-dash triple-dot ____ ... ____ ... ____ +A,24,-3,0,-3,0,-3,0,-3 +*ACAD_ISO07W100,ISO dot . . . . . . . . . . . . . . . . . . . . +A,0,-3 +*ACAD_ISO08W100,ISO long-dash short-dash ____ __ ____ __ ____ _ +A,24,-3,6,-3 +*ACAD_ISO09W100,ISO long-dash double-short-dash ____ __ __ ____ +A,24,-3,6,-3,6,-3 +*ACAD_ISO10W100,ISO dash dot __ . __ . __ . __ . __ . __ . __ . +A,12,-3,0,-3 +*ACAD_ISO11W100,ISO double-dash dot __ __ . __ __ . __ __ . __ _ +A,12,-3,12,-3,0,-3 +*ACAD_ISO12W100,ISO dash double-dot __ . . __ . . __ . . __ . . +A,12,-3,0,-3,0,-3 +*ACAD_ISO13W100,ISO double-dash double-dot __ __ . . __ __ . . _ +A,12,-3,12,-3,0,-3,0,-3 +*ACAD_ISO14W100,ISO dash triple-dot __ . . . __ . . . __ . . . _ +A,12,-3,0,-3,0,-3,0,-3 +*ACAD_ISO15W100,ISO double-dash triple-dot __ __ . . . __ __ . . +A,12,-3,12,-3,0,-3,0,-3,0,-3 + +;; Complex linetypes +;; +;; Complex linetypes have been added to this file. +;; These linetypes were defined in LTYPESHP.LIN in +;; Release 13, and are incorporated in ACAD.LIN in +;; Release 14. +;; +;; These linetype definitions use LTYPESHP.SHX. +;; +*FENCELINE1,Fenceline circle ----0-----0----0-----0----0-----0-- +A,.25,-.1,[CIRC1,ltypeshp.shx,x=-.1,s=.1],-.1,1 +*FENCELINE2,Fenceline square ----[]-----[]----[]-----[]----[]--- +A,.25,-.1,[BOX,ltypeshp.shx,x=-.1,s=.1],-.1,1 +*TRACKS,Tracks -|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|- +A,.15,[TRACK1,ltypeshp.shx,s=.25],.15 +*BATTING,Batting SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS +A,.0001,-.1,[BAT,ltypeshp.shx,x=-.1,s=.1],-.2,[BAT,ltypeshp.shx,r=180,x=.1,s=.1],-.1 +*HOT_WATER_SUPPLY,Hot water supply ---- HW ---- HW ---- HW ---- +A,.5,-.2,["HW",STANDARD,S=.1,U=0.0,X=-0.1,Y=-.05],-.2 +*GAS_LINE,Gas line ----GAS----GAS----GAS----GAS----GAS----GAS-- +A,.5,-.2,["GAS",STANDARD,S=.1,U=0.0,X=-0.1,Y=-.05],-.25 +*ZIGZAG,Zig zag /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ +A,.0001,-.2,[ZIG,ltypeshp.shx,x=-.2,s=.2],-.4,[ZIG,ltypeshp.shx,r=180,x=.2,s=.2],-.2 + +;; User Defined Linetypes +;; +;; Add any linetypes that you define to this section of +;; the file to ensure that they migrate properly when +;; upgrading to a future AutoCAD version. If duplicate +;; linetype definitions are found in this file, items +;; in the User Defined Linetypes section take precedence +;; over definitions that appear earlier in the file. +;; + diff --git a/TestDxfDocument/Support/acadiso.lin b/TestDxfDocument/Support/acadiso.lin new file mode 100644 index 00000000..dbbf4a17 --- /dev/null +++ b/TestDxfDocument/Support/acadiso.lin @@ -0,0 +1,177 @@ +;; +;; AutoCAD ISO Linetype Definition file +;; Version 2.0 +;; +;; Copyright 2017 Autodesk, Inc. All rights reserved. +;; +;; Use of this software is subject to the terms of the Autodesk license +;; agreement provided at the time of installation or download, or which +;; otherwise accompanies this software in either electronic or hard copy form. +;; +;; Note: in order to ease migration of this file when upgrading +;; to a future version of AutoCAD, it is recommended that you add +;; your customizations to the User Defined Linetypes section at the +;; end of this file. +;; +;; customized for ISO scaling +;; +*BORDER,Border __ __ . __ __ . __ __ . __ __ . __ __ . +A, 12.7, -6.35, 12.7, -6.35, 0, -6.35 +*BORDER2,Border (.5x) __.__.__.__.__.__.__.__.__.__.__. +A, 6.35, -3.175, 6.35, -3.175, 0, -3.175 +*BORDERX2,Border (2x) ____ ____ . ____ ____ . ___ +A, 25.4, -12.7, 25.4, -12.7, 0, -12.7 + +*CENTER,Center ____ _ ____ _ ____ _ ____ _ ____ _ ____ +A, 31.75, -6.35, 6.35, -6.35 +*CENTER2,Center (.5x) ___ _ ___ _ ___ _ ___ _ ___ _ ___ +A, 19.05, -3.175, 3.175, -3.175 +*CENTERX2,Center (2x) ________ __ ________ __ _____ +A, 63.5, -12.7, 12.7, -12.7 + +*DASHDOT,Dash dot __ . __ . __ . __ . __ . __ . __ . __ +A, 12.7, -6.35, 0, -6.35 +*DASHDOT2,Dash dot (.5x) _._._._._._._._._._._._._._._. +A, 6.35, -3.175, 0, -3.175 +*DASHDOTX2,Dash dot (2x) ____ . ____ . ____ . ___ +A, 25.4, -12.7, 0, -12.7 + +*DASHED,Dashed __ __ __ __ __ __ __ __ __ __ __ __ __ _ +A, 12.7, -6.35 +*DASHED2,Dashed (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ +A, 6.35, -3.175 +*DASHEDX2,Dashed (2x) ____ ____ ____ ____ ____ ___ +A, 25.4, -12.7 + +*DIVIDE,Divide ____ . . ____ . . ____ . . ____ . . ____ +A, 12.7, -6.35, 0, -6.35, 0, -6.35 +*DIVIDE2,Divide (.5x) __..__..__..__..__..__..__..__.._ +A, 6.35, -3.175, 0, -3.175, 0, -3.175 +*DIVIDEX2,Divide (2x) ________ . . ________ . . _ +A, 25.4, -12.7, 0, -12.7, 0, -12.7 + +*DOT,Dot . . . . . . . . . . . . . . . . . . . . . . . . +A, 0, -6.35 +*DOT2,Dot (.5x) ........................................ +A, 0, -3.175 +*DOTX2,Dot (2x) . . . . . . . . . . . . . . +A, 0, -12.7 + +*HIDDEN,Hidden __ __ __ __ __ __ __ __ __ __ __ __ __ __ +A, 6.35, -3.175 +*HIDDEN2,Hidden (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ +A, 3.175, -1.5875 +*HIDDENX2,Hidden (2x) ____ ____ ____ ____ ____ ____ ____ +A, 12.7, -6.35 + +*PHANTOM,Phantom ______ __ __ ______ __ __ ______ +A, 31.75, -6.35, 6.35, -6.35, 6.35, -6.35 +*PHANTOM2,Phantom (.5x) ___ _ _ ___ _ _ ___ _ _ ___ _ _ +A, 15.875, -3.175, 3.175, -3.175, 3.175, -3.175 +*PHANTOMX2,Phantom (2x) ____________ ____ ____ _ +A, 63.5, -12.7, 12.7, -12.7, 12.7, -12.7 + +;; +;; ISO 128 (ISO/DIS 12011) linetypes have been added. +;; +;; The size of the line segments for each defined ISO line, is +;; defined for an usage with a pen width of 1 mm. To use them with +;; the other ISO predefined pen widths, the line has to be scaled +;; with the appropriate value (e.g. pen width 0,5 mm -> ltscale 0.5). +;; +*ACAD_ISO02W100,ISO dash __ __ __ __ __ __ __ __ __ __ __ __ __ +A,12,-3 +*ACAD_ISO03W100,ISO dash space __ __ __ __ __ __ +A,12,-18 +*ACAD_ISO04W100,ISO long-dash dot ____ . ____ . ____ . ____ . _ +A,24,-3,0,-3 +*ACAD_ISO05W100,ISO long-dash double-dot ____ .. ____ .. ____ . +A,24,-3,0,-3,0,-3 +*ACAD_ISO06W100,ISO long-dash triple-dot ____ ... ____ ... ____ +A,24,-3,0,-3,0,-3,0,-3 +*ACAD_ISO07W100,ISO dot . . . . . . . . . . . . . . . . . . . . +A,0,-3 +*ACAD_ISO08W100,ISO long-dash short-dash ____ __ ____ __ ____ _ +A,24,-3,6,-3 +*ACAD_ISO09W100,ISO long-dash double-short-dash ____ __ __ ____ +A,24,-3,6,-3,6,-3 +*ACAD_ISO10W100,ISO dash dot __ . __ . __ . __ . __ . __ . __ . +A,12,-3,0,-3 +*ACAD_ISO11W100,ISO double-dash dot __ __ . __ __ . __ __ . __ _ +A,12,-3,12,-3,0,-3 +*ACAD_ISO12W100,ISO dash double-dot __ . . __ . . __ . . __ . . +A,12,-3,0,-3,0,-3 +*ACAD_ISO13W100,ISO double-dash double-dot __ __ . . __ __ . . _ +A,12,-3,12,-3,0,-3,0,-3 +*ACAD_ISO14W100,ISO dash triple-dot __ . . . __ . . . __ . . . _ +A,12,-3,0,-3,0,-3,0,-3 +*ACAD_ISO15W100,ISO double-dash triple-dot __ __ . . . __ __ . . +A,12,-3,12,-3,0,-3,0,-3,0,-3 + +;; Complex linetypes +;; +;; Complex linetypes have been added to this file. +;; These linetypes were defined in LTYPESHP.LIN in +;; Release 13, and are incorporated in ACAD.LIN in +;; Release 14. +;; +;; These linetype definitions use LTYPESHP.SHX. +;; +*FENCELINE1,Fenceline circle ----0-----0----0-----0----0-----0-- +A,6.35,-2.54,[CIRC1,ltypeshp.shx,x=-2.54,s=2.54],-2.54,25.4 +*FENCELINE2,Fenceline square ----[]-----[]----[]-----[]----[]--- +A,6.35,-2.54,[BOX,ltypeshp.shx,x=-2.54,s=2.54],-2.54,25.4 +*TRACKS,Tracks -|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|- +A,3.81,[TRACK1,ltypeshp.shx,s=6.35],3.81 +*BATTING,Batting SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS +A,.00254,-2.54,[BAT,ltypeshp.shx,x=-2.54,s=2.54],-5.08,[BAT,ltypeshp.shx,r=180,x=2.54,s=2.54],-2.54 +*HOT_WATER_SUPPLY,Hot water supply ---- HW ---- HW ---- HW ---- +A,12.7,-5.08,["HW",STANDARD,S=2.54,U=0.0,X=-2.54,Y=-1.27],-5.08 +*GAS_LINE,Gas line ----GAS----GAS----GAS----GAS----GAS----GAS-- +A,12.7,-5.08,["GAS",STANDARD,S=2.54,U=0.0,X=-2.54,Y=-1.27],-6.35 +*ZIGZAG,Zig zag /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ +A,.00254,-5.08,[ZIG,ltypeshp.shx,x=-5.08,s=5.08],-10.16,[ZIG,ltypeshp.shx,r=180,x=5.08,s=5.08],-5.08 +;; Linetype Definition related to JIS Z 8312 +;; +*JIS_08_11,1SASEN11 ___ _ ___ _ ___ _ ___ _ ___ _ ___ +A,11,-.60,.60,-.60 +*JIS_08_15,1SASEN15 ____ _ ____ _ ____ _ ____ _ ____ +A,15,-.75,.75,-.75 +*JIS_08_25,1SASEN25 ________ __ ________ __ _____ +A,25,-1.125,.75,-1.125 +*JIS_08_37,1SASEN37 ________ __ ________ __ _____ +A,37.5,-1.125,.75,-1.125 +*JIS_08_50,1SASEN50 _______________ __ ____________ +A,50,-1.125,.75,-1.125 +*JIS_02_0.7,HIDDEN0.75 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ +A,.75,-.60 +*JIS_02_1.0,HIDDEN01 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ +A,1,-1 +*JIS_02_1.2,HIDDEN01.25 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ +A,1.25,-1.25 +*JIS_02_2.0,HIDDEN02 __ __ __ __ __ __ __ __ __ __ __ +A,2,-1 +*JIS_02_4.0,HIDDEN04 ____ ____ ____ ____ ____ ____ ____ +A,4,-1.5 +*JIS_09_08,2SASEN8 __ _ _ __ _ _ __ _ _ __ _ _ __ _ _ +A,8,-.55,.55,-.55,.55,-.55 +*JIS_09_15,2SASEN15 ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ +A,15,-.90,.60,-.90,.60,-.90 +*JIS_09_29,2SASEN29 ______@__ __ ______@__ __ ___ +A,29,-1.2,.70,-1.2,.70,-1.2 +*JIS_09_50,2SASEN50 ____________@__ __ _____________ +A,50,-1.2,.70,-1.2,.70,-1.2 +;; + +;; User Defined Linetypes +;; +;; Add any linetypes that you define to this section of +;; the file to ensure that they migrate properly when +;; upgrading to a future AutoCAD version. If duplicate +;; linetype definitions are found in this file, items +;; in the User Defined Linetypes section take precedence +;; over definitions that appear earlier in the file. +;; +;; multiple text in a linetype complex dfinition +*HW_GAS_LINE,Hw-Gas line ----GAS----HW----GAS----HW----GAS----HW-- +A,12.7,-5.08,["GAS",STANDARD,S=2.54,U=0.0,X=-2.54,Y=-1.27],-6.35,12.7,-5.08,["HW",STANDARD,S=2.54,U=0.0,X=-2.54,Y=-1.27],-5.08 diff --git a/TestDxfDocument/Support/ltypeshp.shp b/TestDxfDocument/Support/ltypeshp.shp new file mode 100644 index 00000000..f447e016 --- /dev/null +++ b/TestDxfDocument/Support/ltypeshp.shp @@ -0,0 +1,28 @@ +;;; +;;; +;;; Copyright 2017 Autodesk, Inc. All rights reserved. +;;; +;;; Use of this software is subject to the terms of the Autodesk license +;;; agreement provided at the time of installation or download, or which +;;; otherwise accompanies this software in either electronic or hard copy form. +;;; +;;; ltypeshp.SHP - shapes for complex linetypes +;;; + +*130,6,TRACK1 +014,002,01C,001,01C,0 + +*131,3,ZIG +012,01E,0 + +*132,6,BOX +014,020,02C,028,014,0 + +*133,4,CIRC1 +10,1,-040,0 + +*134,6,BAT +025,10,2,-044,02B,0 + +*135,14,AMZIGZAG +9,(108,0),(15,56),(30,-112),(15,56),(107,0),(0,0),0 diff --git a/TestDxfDocument/Support/ltypeshp.shx b/TestDxfDocument/Support/ltypeshp.shx new file mode 100644 index 00000000..15b81cf1 Binary files /dev/null and b/TestDxfDocument/Support/ltypeshp.shx differ diff --git a/TestDxfDocument/Support/shape.shp b/TestDxfDocument/Support/shape.shp new file mode 100644 index 00000000..e248ce25 --- /dev/null +++ b/TestDxfDocument/Support/shape.shp @@ -0,0 +1,6 @@ +*1,180,MYSHAPE +4,125,4,160,3,200,3,64,002,9,(45,0),(0,0),001,9,(-1,8),(-2,9),(-4,7),(-5,7),(-6,6),(-8,4),(-8,3),(-8,1),(-9,0),(-8,-2) +(-8,-3),(-7,-5),(-6,-6),(-5,-7),(-3,-8),(-2,-8),(0,-9),(1,-8),(3,-8),(4,-7),(6,-7),(6,-5),(8,-4),(8,-2),(9,-1),(8,0),(8,3) +(8,4),(7,5),(5,6),(5,7),(3,8),(1,12),(0,0),002,9,(-109,0),(0,0),001,9,(127,0),(1,0),(0,0),002,9,(-64,64),(0,0),001,9,(0,-127) +(0,-1),(0,0),002,9,(0,0),001,9,(-64,64),(0,0),002,9,(127,0),(1,0),(0,0),001,9,(-64,-64),(0,0),002,9,(0,127),(0,1),(0,0) +001,9,(64,-64),(0,0),002,9,(-127,0),(-1,0),(0,0),001,9,(64,64),(0,0),002,9,(0,-64),(0,0),001,4,64,4,200,3,160,3,125,0 diff --git a/TestDxfDocument/TestDxfDocument.csproj b/TestDxfDocument/TestDxfDocument.csproj index bf29ad8d..e4e60973 100644 --- a/TestDxfDocument/TestDxfDocument.csproj +++ b/TestDxfDocument/TestDxfDocument.csproj @@ -67,10 +67,8 @@ false - - @@ -114,7 +112,26 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + +