├── .editorconfig ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── pull_request_template.md └── workflows │ ├── build.yml │ ├── build_n_test.yml │ └── publish.yml ├── .gitignore ├── .gitmodules ├── ACadSharp.Examples ├── ACadSharp.Examples.csproj ├── Common │ └── NotificationHelper.cs ├── DocumentExamples.cs ├── Entities │ └── InsertExamples.cs ├── IOExamples.cs ├── Program.cs ├── README.md ├── ReaderExamples.cs └── WriterExamples.cs ├── ACadSharp.Tests ├── ACadSharp.Tests.csproj ├── CadDocumentTests.cs ├── CadObjectTests.cs ├── ColorTests.cs ├── Common │ ├── AssertUtils.cs │ ├── CSMathRandom.cs │ ├── CadObjectTestUtils.cs │ ├── DataFactory.cs │ ├── DocumentIntegrity.cs │ ├── EntityComparator.cs │ ├── EntityFactory.cs │ ├── Factory.cs │ └── TableEntryFactory.cs ├── Data │ ├── document_tree.json │ ├── entities.json │ └── header_cases.json ├── DxfMapTests.cs ├── DxfPropertyTests.cs ├── Entities │ ├── EntityTests.cs │ ├── InsertTest.cs │ └── LwPolylineTest.cs ├── IO │ ├── CadReaderTestsBase.cs │ ├── DWG │ │ ├── DwgReaderTests.cs │ │ └── DwgWriterTests.cs │ ├── DXF │ │ ├── DxfReaderTests.cs │ │ └── DxfWriterTests.cs │ ├── IOTests.cs │ ├── IOTestsBase.cs │ └── LocalSampleTests.cs ├── Tables │ ├── BlockRecordTests.cs │ └── TableEntryTests.cs ├── TestModels │ └── CadDocumentTree.cs ├── TestSetup.cs └── TestVariables.cs ├── ACadSharp.sln ├── ACadSharp ├── ACadSharp.csproj ├── ACadVersion.cs ├── AssemblyInfo.cs ├── Attributes │ ├── CadSystemVariableAttribute.cs │ ├── DxfCodeValueAttribute.cs │ ├── DxfCollectionCodeValueAttribute.cs │ ├── DxfNameAttribute.cs │ ├── DxfSubClassAttribute.cs │ └── ICodeValueAttribute.cs ├── Blocks │ ├── Block.cs │ ├── BlockEnd.cs │ └── BlockTypeFlags.cs ├── CadDocument.cs ├── CadObject.cs ├── CadObjectCollection.cs ├── CadSummaryInfo.cs ├── CadSystemVariable.cs ├── CadUtils.cs ├── Classes │ ├── DxfClass.cs │ ├── DxfClassCollection.cs │ └── ProxyFlags.cs ├── CollectionChangedEventArgs.cs ├── Color.cs ├── DwgPreview.cs ├── DxfClassMap.cs ├── DxfCode.cs ├── DxfFileToken.cs ├── DxfMap.cs ├── DxfMapBase.cs ├── DxfProperty.cs ├── DxfPropertyBase.cs ├── DxfSubclassMarker.cs ├── Entities │ ├── Arc.cs │ ├── AttachmentPointType.cs │ ├── AttributeBase.cs │ ├── AttributeDefinition.cs │ ├── AttributeEntity.cs │ ├── AttributeFlags.cs │ ├── BackgroundFillFlags.cs │ ├── BoundaryPathFlags.cs │ ├── Circle.cs │ ├── ColumnType.cs │ ├── Dimension.cs │ ├── DimensionAligned.cs │ ├── DimensionAngular2Line.cs │ ├── DimensionAngular3Pt.cs │ ├── DimensionDiameter.cs │ ├── DimensionLinear.cs │ ├── DimensionOrdinate.cs │ ├── DimensionRadius.cs │ ├── DimensionType.cs │ ├── DrawingDirectionType.cs │ ├── Ellipse.cs │ ├── Entity.cs │ ├── Face3D.cs │ ├── GradientColor.cs │ ├── Hatch.BoundaryPath.Arc.cs │ ├── Hatch.BoundaryPath.Edge.cs │ ├── Hatch.BoundaryPath.Ellipse.cs │ ├── Hatch.BoundaryPath.Line.cs │ ├── Hatch.BoundaryPath.Polyline.cs │ ├── Hatch.BoundaryPath.Spline.cs │ ├── Hatch.BoundaryPath.cs │ ├── Hatch.cs │ ├── HatchGradientPattern.cs │ ├── HatchPattern.cs │ ├── HatchPatternType.cs │ ├── HatchStyleType.cs │ ├── IEntity.cs │ ├── IPolyline.cs │ ├── IVertex.cs │ ├── Insert.cs │ ├── InvisibleEdgeFlags.cs │ ├── KnotParameterization.cs │ ├── Leader.cs │ ├── LeaderCreationType.cs │ ├── LeaderPathType.cs │ ├── LightingType.cs │ ├── Line.cs │ ├── LineSpacingStyleType.cs │ ├── LwPolyLine.cs │ ├── LwPolyline.Vertex.cs │ ├── LwPolylineFlags.cs │ ├── MLine.Vertex.cs │ ├── MLine.cs │ ├── MLineFlags.cs │ ├── MLineJustification.cs │ ├── MText.TextColumn.cs │ ├── MText.cs │ ├── Point.cs │ ├── PolyLine.cs │ ├── PolyLine2D.cs │ ├── PolyLine3D.cs │ ├── PolylineFlags.cs │ ├── Ray.cs │ ├── Seqend.cs │ ├── ShadowMode.cs │ ├── Shape.cs │ ├── SmoothSurfaceType.cs │ ├── Solid.cs │ ├── Solid3D.cs │ ├── Spline.cs │ ├── SplineFlags.cs │ ├── SplineFlags1.cs │ ├── TextEntity.cs │ ├── TextHorizontalAlignment.cs │ ├── TextMirrorFlag.cs │ ├── TextVerticalAlignmentType.cs │ ├── Vertex.cs │ ├── Vertex2D.cs │ ├── Vertex3D.cs │ ├── VertexFlags.cs │ ├── VerticalAlignmentType.cs │ ├── ViewPort.cs │ ├── ViewportStatusFlags.cs │ └── XLine.cs ├── Exceptions │ ├── DwgException.cs │ ├── DwgNotSupportedException.cs │ └── DxfException.cs ├── ExtendedDataCollection.cs ├── Header │ ├── CadHeader.cs │ ├── DimensionAssociation.cs │ ├── ObjectSnapMode.cs │ ├── ObjectSortingFlags.cs │ ├── ShadeEdgeType.cs │ ├── SpaceLineTypeScaling.cs │ └── SplineType.cs ├── IClonable.cs ├── IHandledCadObject.cs ├── INamedCadObject.cs ├── IO │ ├── CadDocumentBuilder.cs │ ├── CadReaderBase.cs │ ├── CadReaderConfiguration.cs │ ├── CadWriterBase.cs │ ├── DWG │ │ ├── CRC.cs │ │ ├── CRC32StreamHandler.cs │ │ ├── CRC8StreamHandler.cs │ │ ├── DwgCheckSumCalculator.cs │ │ ├── DwgDocumentBuilder.cs │ │ ├── DwgHeaderHandlesCollection.cs │ │ ├── DwgReader.cs │ │ ├── DwgReaderConfiguration.cs │ │ ├── DwgSectionIO.cs │ │ ├── DwgStreamReaders │ │ │ ├── Dwg2004LZ77.cs │ │ │ ├── DwgClassesReader.cs │ │ │ ├── DwgHandleReader.cs │ │ │ ├── DwgHeaderReader.cs │ │ │ ├── DwgMergedReader.cs │ │ │ ├── DwgObjectSectionReader.cs │ │ │ ├── DwgR21LZ77.cs │ │ │ ├── DwgStreamReaderAC12.cs │ │ │ ├── DwgStreamReaderAC15.cs │ │ │ ├── DwgStreamReaderAC18.cs │ │ │ ├── DwgStreamReaderAC21.cs │ │ │ ├── DwgStreamReaderAC24.cs │ │ │ ├── DwgStreamReaderBase.cs │ │ │ ├── DwgSummaryInfoReader.cs │ │ │ └── IDwgStreamReader.cs │ │ ├── DwgStreamWriters │ │ │ ├── DwgAppInfodWriter.cs │ │ │ ├── DwgAuxHeaderWriter.cs │ │ │ ├── DwgClassesWriter.cs │ │ │ ├── DwgFileHeaderWriterAC15.cs │ │ │ ├── DwgFileHeaderWriterAC18.cs │ │ │ ├── DwgFileHeaderWriterAC21.cs │ │ │ ├── DwgFileHeaderWriterBase.cs │ │ │ ├── DwgHandleWriter.cs │ │ │ ├── DwgHeaderWriter.cs │ │ │ ├── DwgLZ77AC18Compressor.cs │ │ │ ├── DwgLZ77AC21Compressor.cs │ │ │ ├── DwgObjectWriter.Common.cs │ │ │ ├── DwgObjectWriter.Entities.cs │ │ │ ├── DwgObjectWriter.cs │ │ │ ├── DwgPreviewWriter.cs │ │ │ ├── DwgStreamWriterAC12.cs │ │ │ ├── DwgStreamWriterAC15.cs │ │ │ ├── DwgStreamWriterAC18.cs │ │ │ ├── DwgStreamWriterAC21.cs │ │ │ ├── DwgStreamWriterAC24.cs │ │ │ ├── DwgStreamWriterBase.cs │ │ │ ├── DwgmMergedStreamWriter.cs │ │ │ ├── DwgmMergedStreamWriterAC14.cs │ │ │ ├── ICompressor.cs │ │ │ ├── IDwgFileHeaderWriter.cs │ │ │ └── IDwgStreamWriter.cs │ │ ├── DwgWriter.cs │ │ └── FileHeaders │ │ │ ├── Dwg21CompressedMetadata.cs │ │ │ ├── DwgFileHeader.cs │ │ │ ├── DwgFileHeaderAC15.cs │ │ │ ├── DwgFileHeaderAC18.cs │ │ │ ├── DwgFileHeaderAC21.cs │ │ │ ├── DwgLocalSectionMap.cs │ │ │ ├── DwgSectionDefinition.cs │ │ │ ├── DwgSectionDescriptor.cs │ │ │ ├── DwgSectionHash.cs │ │ │ └── DwgSectionLocatorRecord.cs │ ├── DXF │ │ ├── CadObjectHolder.cs │ │ ├── DxfDocumentBuilder.cs │ │ ├── DxfReader.cs │ │ ├── DxfReaderConfiguration.cs │ │ ├── DxfStreamReader │ │ │ ├── DxfBinaryReader.cs │ │ │ ├── DxfBlockSectionReader.cs │ │ │ ├── DxfEntitiesSectionReader.cs │ │ │ ├── DxfObjectsSectionReader.cs │ │ │ ├── DxfReaderBase.cs │ │ │ ├── DxfSectionReaderBase.cs │ │ │ ├── DxfTablesSectionReader.cs │ │ │ ├── DxfTextReader.cs │ │ │ └── IDxfStreamReader.cs │ │ ├── DxfStreamWriter │ │ │ ├── DxfAsciiWriter.cs │ │ │ ├── DxfBinaryWriter.cs │ │ │ ├── DxfBlocksSectionWriter.cs │ │ │ ├── DxfClassesSectionWriter.cs │ │ │ ├── DxfEntitiesSectionWriter.cs │ │ │ ├── DxfHeaderSectionWriter.cs │ │ │ ├── DxfObjectsSectionWriter.cs │ │ │ ├── DxfSectionWriterBase.cs │ │ │ ├── DxfTablesSectionWriter.cs │ │ │ └── IDxfStreamWriter.cs │ │ └── DxfWriter.cs │ ├── ICadReader.cs │ ├── ICadWriter.cs │ ├── NotificationEventHandler.cs │ └── Templates │ │ ├── CadArcTemplate.cs │ │ ├── CadBlockCtrlObjectTemplate.cs │ │ ├── CadBlockRecordTemplate.cs │ │ ├── CadDictionaryTemplate.cs │ │ ├── CadDimensionStyleTemplate.cs │ │ ├── CadDimensionTemplate.cs │ │ ├── CadEntityTemplate.cs │ │ ├── CadHatchTemplate.CadBoundaryPathTemplate.cs │ │ ├── CadHatchTemplate.cs │ │ ├── CadInsertTemplate.cs │ │ ├── CadLayerTemplate.cs │ │ ├── CadLayoutTemplate.cs │ │ ├── CadLeaderTemplate.cs │ │ ├── CadLineTypeTemplate.cs │ │ ├── CadLwPolylineTemplate.cs │ │ ├── CadMLStyleTemplate.cs │ │ ├── CadMLineTemplate.cs │ │ ├── CadPolyLineTemplate.cs │ │ ├── CadShapeTemplate.cs │ │ ├── CadSortensTableTemplate.cs │ │ ├── CadSplineTemplate.cs │ │ ├── CadTableEntryTemplate.cs │ │ ├── CadTableTemplate.cs │ │ ├── CadTemplate.cs │ │ ├── CadTemplate[T].cs │ │ ├── CadTextEntityTemplate.cs │ │ ├── CadUcsTemplate.cs │ │ ├── CadVPortTemplate.cs │ │ ├── CadVertexTemplate.cs │ │ ├── CadViewTemplate.cs │ │ ├── CadViewportTemplate.cs │ │ ├── CadXRecordTemplate.cs │ │ ├── DwgColorTemplate.cs │ │ ├── DwgGroupTemplate.cs │ │ ├── DwgTextEntityTemplate.cs │ │ ├── DwgViewportEntityControlTemplate.cs │ │ ├── ICadObjectBuilder.cs │ │ └── ICadTableTemplate.cs ├── IObservableCollection.cs ├── ISeqendColleciton.cs ├── LayoutCollection.cs ├── MathUtils.cs ├── Objects │ ├── CadDictionary.cs │ ├── DictionaryCloningFlags.cs │ ├── DictionaryVariable.cs │ ├── Group.cs │ ├── Layout.cs │ ├── LayoutFlags.cs │ ├── MLStyle.Element.cs │ ├── MLStyle.cs │ ├── MLineStyleFlags.cs │ ├── Material.cs │ ├── PaperMargin.cs │ ├── PlotFlags.cs │ ├── PlotPaperUnits.cs │ ├── PlotRotation.cs │ ├── PlotSettings.cs │ ├── ShadePlotMode.cs │ ├── ShadePlotResolutionMode.cs │ ├── SortEntitiesTable.cs │ ├── VisualStyle.cs │ └── XRecrod.cs ├── PropertyReflection.cs ├── ReferenceChangedEventArgs.cs ├── SeqendCollection.cs ├── Tables │ ├── AppId.cs │ ├── ArcLengthSymbolPosition.cs │ ├── BlockRecord.cs │ ├── Collections │ │ ├── AppIdsTable.cs │ │ ├── BlockRecordsTable.cs │ │ ├── DimensionStylesTable.cs │ │ ├── LayersTable.cs │ │ ├── LineTypesTable.cs │ │ ├── Table.cs │ │ ├── TextStylesTable.cs │ │ ├── UCSTable.cs │ │ ├── VPortsTable.cs │ │ └── ViewsTable.cs │ ├── DefaultLightingType.cs │ ├── DimensionStyle.cs │ ├── DimensionTextBackgroundFillMode.cs │ ├── DimensionTextHorizontalAlignment.cs │ ├── DimensionTextVerticalAlignment.cs │ ├── EntryFlags.cs │ ├── FontFlags.cs │ ├── FractionFormat.cs │ ├── GridFlags.cs │ ├── Layer.cs │ ├── LayerFlags.cs │ ├── LineType.cs │ ├── LineTypeSegment.cs │ ├── LinetypeShapeFlags.cs │ ├── StandardFlags.cs │ ├── StyleFlags.cs │ ├── TableEntry.cs │ ├── TextDirection.cs │ ├── TextMovement.cs │ ├── TextStyle.cs │ ├── ToleranceAlignment.cs │ ├── UCS.cs │ ├── UscIconType.cs │ ├── VPort.cs │ ├── View.cs │ ├── ViewModeType.cs │ └── ZeroHandling.cs ├── Transparency.cs └── Types │ ├── DwgReferenceType.cs │ ├── DxfReferenceType.cs │ ├── Lineweight.cs │ ├── ObjectType.cs │ ├── OrthographicType.cs │ ├── PlotType.cs │ ├── RenderMode.cs │ ├── ScaledType.cs │ └── Units │ ├── AngularDirection.cs │ ├── AngularUnitFormat.cs │ ├── LinearUnitFormat.cs │ └── UnitsType.cs ├── ACadSharpInternal.Tests ├── ACadSharpInternal.Tests.csproj ├── DwgFileHeaderExploration.cs ├── DwgHandleWriterTests.cs ├── DwgHeaderWriterTests.cs ├── DwgObjectWriterTests.cs ├── DwgSectionWriterTestBase.cs └── TestSetup.cs ├── Directory.Build.props ├── LICENSE ├── README.md ├── reference ├── ACadFileExploration.xlsx ├── OpenDesign_Specification_for_.dwg_files.pdf └── autocad_2012_pdf_dxf-reference_enu.pdf ├── samples ├── sample_AC1014.dwg ├── sample_AC1015.dwg ├── sample_AC1015_ascii.dxf ├── sample_AC1015_binary.dxf ├── sample_AC1018.dwg ├── sample_AC1018_ascii.dxf ├── sample_AC1018_binary.dxf ├── sample_AC1021.dwg ├── sample_AC1021_ascii.dxf ├── sample_AC1021_binary.dxf ├── sample_AC1024.dwg ├── sample_AC1024_ascii.dxf ├── sample_AC1024_binary.dxf ├── sample_AC1027.dwg ├── sample_AC1027_ascii.dxf ├── sample_AC1027_binary.dxf ├── sample_AC1032.dwg ├── sample_AC1032_ascii.dxf ├── sample_AC1032_binary.dxf └── sample_base │ ├── document_tree.json │ ├── empty.dwg │ ├── sample_base.dwg │ ├── sample_base_backup.dwg │ └── save_samples.lsp └── update_submodules.bat /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: DomCR -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior or an example of the code used. 15 | 16 | **Expected behavior** 17 | A clear and concise description of what you expected to happen if needed. 18 | 19 | **Screenshots** 20 | If applicable, add screenshots to help explain your problem. 21 | 22 | **Additional context** 23 | Add any other context about the problem here. 24 | If the issue is related to an specific dwg/dxf file and if able, attach that file to the issue of an equivalent with the same error. 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | Short description about this PR 4 | 5 | # Tasks done in this PR 6 | * [ ] Something awesome. 7 | * [ ] An evil bug have been defeted. 8 | * [ ] Code cleanup and maintenance has been done. 9 | 10 | # Related Issues / Pull Requests 11 | - Add the links of issues or PR related to this one. 12 | # Notes for reviewer 13 | - Things to consider during the review of this PR. -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: windows-latest 13 | 14 | steps: 15 | - name: Checkout 16 | run: git config --global core.autocrlf true 17 | - uses: actions/checkout@v2 18 | with: 19 | submodules: true 20 | - name: Restore dependencies 21 | run: dotnet restore 22 | - name: Build 23 | run: dotnet build --configuration Release --no-restore 24 | -------------------------------------------------------------------------------- /.github/workflows/build_n_test.yml: -------------------------------------------------------------------------------- 1 | name: Build&Test 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | env: 10 | GITHUB_WORKFLOW: BUILD_TEST 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: windows-latest 16 | 17 | steps: 18 | - name: Checkout 19 | run: git config --global core.autocrlf true 20 | - uses: actions/checkout@v2 21 | with: 22 | submodules: true 23 | - name: Restore dependencies 24 | run: dotnet restore 25 | - name: Build 26 | run: dotnet build --configuration Release --no-restore 27 | - name: Test 28 | run: dotnet test --configuration Release --no-build --verbosity normal 29 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | #name: Publish NuGet package 2 | 3 | #on: 4 | # push: 5 | # tags: 6 | # - '*' 7 | 8 | #jobs: 9 | # build: 10 | 11 | # runs-on: windows-latest 12 | 13 | # steps: 14 | # - name: Checkout 15 | # run: git config --global core.autocrlf true 16 | # - uses: actions/checkout@v2 17 | # with: 18 | # submodules: true 19 | # - name: Restore dependencies 20 | # run: dotnet restore 21 | # - name: Build NuGet package 22 | # run: dotnet pack ./ACadSharp.sln -c Release -o packages 23 | # - name: Publish NuGet package 24 | # run: dotnet nuget push .\packages\ACadSharp*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "CSUtilities"] 2 | path = CSUtilities 3 | url = https://github.com/DomCR/CSUtilities 4 | -------------------------------------------------------------------------------- /ACadSharp.Examples/ACadSharp.Examples.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /ACadSharp.Examples/Common/NotificationHelper.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.IO; 2 | using System; 3 | 4 | namespace ACadSharp.Examples.Common 5 | { 6 | public class NotificationHelper 7 | { 8 | public static void LogConsoleNotification(object sender, NotificationEventArgs e) 9 | { 10 | switch (e.NotificationType) 11 | { 12 | case NotificationType.NotImplemented: 13 | Console.ForegroundColor = ConsoleColor.Gray; 14 | break; 15 | case NotificationType.None: 16 | Console.ForegroundColor = ConsoleColor.White; 17 | break; 18 | case NotificationType.Warning: 19 | Console.ForegroundColor = ConsoleColor.Yellow; 20 | break; 21 | case NotificationType.Error: 22 | case NotificationType.NotSupported: 23 | Console.ForegroundColor = ConsoleColor.Red; 24 | break; 25 | default: 26 | break; 27 | } 28 | 29 | //Write in the console all the messages 30 | Console.WriteLine(e.Message); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ACadSharp.Examples/Entities/InsertExamples.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Entities; 2 | using ACadSharp.Tables; 3 | 4 | namespace ACadSharp.Examples.Entities 5 | { 6 | public static class InsertExamples 7 | { 8 | /// 9 | /// Create an insert referencing a block 10 | /// 11 | public static void CreateInsert() 12 | { 13 | //Create a block record to use as a reference 14 | BlockRecord record = new BlockRecord("my_block"); 15 | record.Entities.Add(new Line()); 16 | record.Entities.Add(new Point()); 17 | 18 | //Create an insert referencing the block record 19 | Insert insert = new Insert(record); 20 | } 21 | 22 | /// 23 | /// Create an insert entity and add it to the model 24 | /// 25 | public static void AddInsertIntoModel() 26 | { 27 | //Create a block record to use as a reference 28 | BlockRecord record = new BlockRecord("my_block"); 29 | record.Entities.Add(new Point()); 30 | 31 | //Create an insert referencing the block record 32 | Insert insert = new Insert(record); 33 | //Set the insert point and scale fields 34 | insert.InsertPoint = new CSMath.XYZ(100, 100, 0); 35 | insert.XScale = 2; 36 | insert.YScale = 2; 37 | 38 | //Add the insert into a document 39 | CadDocument doc = new CadDocument(); 40 | 41 | //Add the insert into the model 42 | doc.Entities.Add(insert); 43 | 44 | //Once the file is saved you will have an instance of my_block scaled by 2 and at the point 100, 100 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /ACadSharp.Examples/IOExamples.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.IO; 2 | using System.Collections.Generic; 3 | 4 | namespace ACadSharp.Examples 5 | { 6 | /// 7 | /// Examples of conversion and saving documents 8 | /// 9 | public class IOExamples 10 | { 11 | /// 12 | /// Read a dwg and save the entities in a new file 13 | /// 14 | /// 15 | /// 16 | public void DwgEntitiesToNewFile(string input, string output) 17 | { 18 | /* --- ATENTION --- 19 | * ACadSharp cannot write a readed dwg/dxf file due a problem in the file structure when the dxf is writen 20 | * the workaround for now is to move the entities and save them in a new file 21 | */ 22 | CadDocument doc = DwgReader.Read(input); 23 | 24 | //New document to transfer the entities 25 | CadDocument transfer = new CadDocument(); 26 | doc.Header.Version = doc.Header.Version; 27 | 28 | //Nove the entities to the created document 29 | List entities = new List(doc.Entities); 30 | foreach (var item in entities) 31 | { 32 | ACadSharp.Entities.Entity e = doc.Entities.Remove(item); 33 | transfer.Entities.Add(e); 34 | } 35 | 36 | //Save the document 37 | using (DxfWriter writer = new DxfWriter(output, doc, false)) 38 | { 39 | writer.OnNotification += Common.NotificationHelper.LogConsoleNotification; 40 | writer.Write(); 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /ACadSharp.Examples/ReaderExamples.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Examples.Common; 2 | using ACadSharp.IO; 3 | 4 | namespace ACadSharp.Examples 5 | { 6 | public static class ReaderExamples 7 | { 8 | /// 9 | /// Read a dxf file 10 | /// 11 | /// dxf file path 12 | public static void ReadDxf(string file) 13 | { 14 | using (DxfReader reader = new DxfReader(file)) 15 | { 16 | reader.OnNotification += NotificationHelper.LogConsoleNotification; 17 | CadDocument doc = reader.Read(); 18 | } 19 | } 20 | 21 | /// 22 | /// Read a dwg file 23 | /// 24 | /// dwg file path 25 | public static void ReadDwg(string file) 26 | { 27 | using (DwgReader reader = new DwgReader(file)) 28 | { 29 | reader.OnNotification += NotificationHelper.LogConsoleNotification; 30 | CadDocument doc = reader.Read(); 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /ACadSharp.Examples/WriterExamples.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Examples.Common; 2 | using ACadSharp.IO; 3 | 4 | namespace ACadSharp.Examples 5 | { 6 | public static class WriterExamples 7 | { 8 | /// 9 | /// Write a binary dxf file 10 | /// 11 | /// file path 12 | /// 13 | /// if the file has to be in binary 14 | public static void WriteDxf(string file, CadDocument doc, bool binary) 15 | { 16 | using (DxfWriter writer = new DxfWriter(file, doc, binary)) 17 | { 18 | writer.OnNotification += NotificationHelper.LogConsoleNotification; 19 | writer.Write(); 20 | } 21 | } 22 | 23 | /// 24 | /// Write a dwg file 25 | /// 26 | /// file path 27 | /// 28 | public static void WriteDwg(string file, CadDocument doc) 29 | { 30 | using (DwgWriter writer = new DwgWriter(file, doc)) 31 | { 32 | writer.OnNotification += NotificationHelper.LogConsoleNotification; 33 | writer.Write(); 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ACadSharp.Tests/ACadSharp.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.1 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /ACadSharp.Tests/CadObjectTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | using ACadSharp.Tests.Common; 4 | using ACadSharp.Tables.Collections; 5 | 6 | namespace ACadSharp.Tests 7 | { 8 | public class CadObjectTests 9 | { 10 | public static readonly TheoryData ACadTypes = new TheoryData(); 11 | 12 | static CadObjectTests() 13 | { 14 | foreach (Type item in DataFactory.GetTypes()) 15 | { 16 | ACadTypes.Add(item); 17 | } 18 | } 19 | 20 | [Theory(Skip = "Factory refactor needed")] 21 | [MemberData(nameof(ACadTypes))] 22 | public void Clone(Type t) 23 | { 24 | CadObject cadObject = Factory.CreateObject(t); 25 | CadObject clone = (CadObject)cadObject.Clone(); 26 | 27 | CadObjectTestUtils.AssertClone(cadObject, clone); 28 | } 29 | 30 | [Theory(Skip = "Factory refactor needed")] 31 | [MemberData(nameof(ACadTypes))] 32 | public void CloneUnattachEvent(Type t) 33 | { 34 | CadObject cadObject = Factory.CreateObject(t); 35 | cadObject.OnReferenceChanged += this.cadObject_OnReferenceChanged; 36 | 37 | CadObject clone = (CadObject)cadObject.Clone(); 38 | 39 | CadObjectTestUtils.AssertClone(cadObject, clone); 40 | } 41 | 42 | private void cadObject_OnReferenceChanged(object sender, ReferenceChangedEventArgs e) 43 | { 44 | //The clone must not have any attachment 45 | throw new InvalidOperationException(); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /ACadSharp.Tests/Common/AssertUtils.cs: -------------------------------------------------------------------------------- 1 | using CSMath; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | 4 | namespace ACadSharp.Tests.Common 5 | { 6 | public static class AssertUtils 7 | { 8 | public static void AreEqual(T expected, T actual, string varname) 9 | { 10 | switch (expected, actual) 11 | { 12 | case (double d1, double d2): 13 | Assert.AreEqual(d1, d2, TestVariables.Delta, $"Different {varname}"); 14 | break; 15 | case (XY xy1, XY xy2): 16 | Assert.IsTrue(xy1.IsEqual(xy2, TestVariables.DecimalPrecision), $"Different {varname}"); 17 | break; 18 | case (XYZ xyz1, XYZ xyz2): 19 | Assert.IsTrue(xyz1.IsEqual(xyz2, TestVariables.DecimalPrecision), $"Different {varname}"); 20 | break; 21 | default: 22 | Assert.AreEqual(expected, actual, $"Different {varname}"); 23 | break; 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ACadSharp.Tests/Common/CadObjectTestUtils.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Entities; 2 | using ACadSharp.Tables; 3 | using Xunit; 4 | 5 | namespace ACadSharp.Tests.Common 6 | { 7 | public class CadObjectTestUtils 8 | { 9 | public static void AssertClone(CadObject original, CadObject clone) 10 | { 11 | //Assert clone 12 | Assert.NotEqual(original, clone); 13 | Assert.True(0 == clone.Handle); 14 | Assert.Null(clone.Document); 15 | } 16 | 17 | public static void AssertEntityClone(Entity original, Entity clone) 18 | { 19 | AssertClone(original, clone); 20 | 21 | Assert.Equal(original.LinetypeScale, clone.LinetypeScale); 22 | 23 | //Assert clone 24 | AssertTableEntryClone(original.Layer, clone.Layer); 25 | AssertTableEntryClone(original.LineType, clone.LineType); 26 | } 27 | 28 | public static void AssertTableEntryClone(TableEntry original, TableEntry clone) 29 | { 30 | AssertClone(original, clone); 31 | 32 | //Assert clone 33 | Assert.True(clone.Name == original.Name); 34 | Assert.True(clone.Flags == original.Flags); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ACadSharp.Tests/Common/DataFactory.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using Xunit; 7 | 8 | namespace ACadSharp.Tests.Common 9 | { 10 | public static class DataFactory 11 | { 12 | public static IEnumerable GetTypes() 13 | { 14 | var d = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.ManifestModule.Name == "ACadSharp.dll"); 15 | 16 | foreach (var item in d.GetTypes().Where(i => !i.IsAbstract && i.IsPublic)) 17 | { 18 | if (item.IsSubclassOf(typeof(T))) 19 | { 20 | yield return (item); 21 | } 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ACadSharp.Tests/DxfPropertyTests.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Entities; 2 | using CSMath; 3 | using Xunit; 4 | 5 | namespace ACadSharp.Tests 6 | { 7 | public class DxfPropertyTests 8 | { 9 | [Fact] 10 | public void SetXYValueTest() 11 | { 12 | Viewport viewport = new Viewport(); 13 | 14 | XY manual = new XY(1, 1); 15 | XY dxfProp = new XY(2, 2); 16 | 17 | viewport.SnapBase = manual; 18 | 19 | DxfClassMap map = DxfClassMap.Create(); 20 | 21 | map.DxfProperties[13].SetValue(viewport, dxfProp.X); 22 | map.DxfProperties[23].SetValue(viewport, dxfProp.Y); 23 | 24 | Assert.Equal(dxfProp, viewport.SnapBase); 25 | } 26 | 27 | [Fact] 28 | public void SetXYZValueTest() 29 | { 30 | Line line = new Line(); 31 | 32 | XYZ manual = new XYZ(1, 1, 1); 33 | XYZ dxfProp = new XYZ(2, 2, 2); 34 | 35 | line.StartPoint = manual; 36 | 37 | DxfClassMap map = DxfClassMap.Create(); 38 | 39 | map.DxfProperties[10].SetValue(line, dxfProp.X); 40 | map.DxfProperties[20].SetValue(line, dxfProp.Y); 41 | map.DxfProperties[30].SetValue(line, dxfProp.Z); 42 | 43 | Assert.Equal(dxfProp, line.StartPoint); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /ACadSharp.Tests/Entities/EntityTests.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Entities; 2 | using ACadSharp.Tests.Common; 3 | using System; 4 | using Xunit; 5 | 6 | namespace ACadSharp.Tests.Entities 7 | { 8 | public class EntityTests 9 | { 10 | public static readonly TheoryData EntityTypes = new TheoryData(); 11 | 12 | static EntityTests() 13 | { 14 | foreach (var item in DataFactory.GetTypes()) 15 | { 16 | EntityTypes.Add(item); 17 | } 18 | } 19 | 20 | [Theory] 21 | [MemberData(nameof(EntityTypes))] 22 | public void Clone(Type entityType) 23 | { 24 | Entity entity = EntityFactory.Create(entityType); 25 | Entity clone = (Entity)entity.Clone(); 26 | 27 | CadObjectTestUtils.AssertEntityClone(entity, clone); 28 | } 29 | 30 | [Theory] 31 | [MemberData(nameof(EntityTypes))] 32 | public void CloneUnattachEvent(Type t) 33 | { 34 | Entity entity = EntityFactory.Create(t); 35 | entity.OnReferenceChanged += this.entity_OnReferenceChanged; 36 | 37 | Entity clone = (Entity)entity.Clone(); 38 | 39 | CadObjectTestUtils.AssertEntityClone(entity, clone); 40 | } 41 | 42 | private void entity_OnReferenceChanged(object sender, ReferenceChangedEventArgs e) 43 | { 44 | //The clone must not have any attachment 45 | throw new InvalidOperationException(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /ACadSharp.Tests/TestSetup.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | 3 | [assembly: CollectionBehavior(DisableTestParallelization = true)] 4 | -------------------------------------------------------------------------------- /ACadSharp.Tests/TestVariables.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Tests 2 | { 3 | public static class TestVariables 4 | { 5 | public const double Delta = 0.00001d; 6 | 7 | public const int DecimalPrecision = 5; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ACadSharp/ACadSharp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0;net5.0;net48;netstandard2.1 5 | DomCr 6 | ACadSharp 7 | C# Dwg Dxf Autocad 8 | https://github.com/DomCR/ACadSharp 9 | MIT 10 | git 11 | https://github.com/DomCR/ACadSharp 12 | Copyright (c) 2022 Albert Domenech 13 | C# library to read/write cad files like dxf/dwg. 14 | True 15 | 16 | 17 | 18 | true 19 | README.md 20 | 1.4.3-alpha 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | True 30 | \ 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /ACadSharp/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | using System.Runtime.InteropServices; 3 | 4 | // In SDK-style projects such as this one, several assembly attributes that were historically 5 | // defined in this file are now automatically added during build and populated with 6 | // values defined in project properties. For details of which attributes are included 7 | // and how to customise this process see: https://aka.ms/assembly-info-properties 8 | 9 | 10 | // Setting ComVisible to false makes the types in this assembly not visible to COM 11 | // components. If you need to access a type in this assembly from COM, set the ComVisible 12 | // attribute to true on that type. 13 | 14 | [assembly: ComVisible(false)] 15 | 16 | // The following GUID is for the ID of the typelib if this project is exposed to COM. 17 | 18 | [assembly: Guid("aa6052a6-647a-498d-86d0-4cce487747a9")] 19 | 20 | [assembly: InternalsVisibleTo("ACadSharpInternal.Tests")] 21 | -------------------------------------------------------------------------------- /ACadSharp/Attributes/CadSystemVariableAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ACadSharp.Attributes 7 | { 8 | [System.AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)] 9 | public sealed class CadSystemVariableAttribute : Attribute, ICodeValueAttribute 10 | { 11 | /// 12 | /// System variable name 13 | /// 14 | public string Name { get; } 15 | 16 | /// 17 | public DxfCode[] ValueCodes { get; } 18 | 19 | /// 20 | public DxfReferenceType ReferenceType { get; } 21 | 22 | public CadSystemVariableAttribute(string variable, params int[] codes) 23 | { 24 | this.Name = variable; 25 | this.ValueCodes = codes.Select(c => (DxfCode)c).ToArray(); 26 | } 27 | 28 | public CadSystemVariableAttribute(string variable, params DxfCode[] codes) 29 | { 30 | this.Name = variable; 31 | this.ValueCodes = codes; 32 | } 33 | 34 | public CadSystemVariableAttribute(DxfReferenceType referenceType, string variable, params int[] codes) 35 | { 36 | this.ReferenceType = referenceType; 37 | this.Name = variable; 38 | this.ValueCodes = codes.Select(c => (DxfCode)c).ToArray(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ACadSharp/Attributes/DxfCodeValueAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace ACadSharp.Attributes 5 | { 6 | [System.AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)] 7 | public sealed class DxfCodeValueAttribute : Attribute, ICodeValueAttribute 8 | { 9 | /// 10 | public DxfCode[] ValueCodes { get; } 11 | 12 | /// 13 | public DxfReferenceType ReferenceType { get; } 14 | 15 | public DxfCodeValueAttribute(params int[] codes) 16 | { 17 | this.ValueCodes = codes.Select(c => (DxfCode)c).ToArray(); 18 | } 19 | 20 | public DxfCodeValueAttribute(DxfReferenceType referenceType, params int[] codes) : this(codes) 21 | { 22 | this.ReferenceType = referenceType; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ACadSharp/Attributes/DxfCollectionCodeValueAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace ACadSharp.Attributes 5 | { 6 | [System.AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)] 7 | sealed class DxfCollectionCodeValueAttribute : Attribute, ICodeValueAttribute 8 | { 9 | /// 10 | public DxfCode[] ValueCodes { get; } 11 | 12 | /// 13 | public DxfReferenceType ReferenceType { get; } 14 | 15 | public DxfCollectionCodeValueAttribute(params int[] codes) 16 | { 17 | this.ValueCodes = codes.Select(c => (DxfCode)c).ToArray(); 18 | } 19 | 20 | public DxfCollectionCodeValueAttribute(DxfReferenceType referenceType, params int[] codes) : this(codes) 21 | { 22 | this.ReferenceType = referenceType; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ACadSharp/Attributes/DxfNameAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.Attributes 4 | { 5 | /// 6 | /// Mark the class as a dxf class equivalent 7 | /// 8 | [System.AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = false)] 9 | public sealed class DxfNameAttribute : Attribute 10 | { 11 | /// 12 | /// Dxf name 13 | /// 14 | public string Name { get; } 15 | 16 | public DxfNameAttribute(string name) 17 | { 18 | this.Name = name; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ACadSharp/Attributes/DxfSubClassAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.Attributes 4 | { 5 | /// 6 | /// Mark the class as a dxf class equivalent 7 | /// 8 | [System.AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] 9 | public sealed class DxfSubClassAttribute : Attribute 10 | { 11 | /// 12 | /// Dxf class name 13 | /// 14 | public string ClassName { get; } 15 | 16 | /// 17 | /// Flag to mark the classes that don't contain any properties by itself, they are only a base for the subclasses 18 | /// 19 | public bool IsEmpty { get; } 20 | 21 | public DxfSubClassAttribute(string className) 22 | { 23 | this.ClassName = className; 24 | } 25 | 26 | public DxfSubClassAttribute(string className, bool isEmpty) : this(className) 27 | { 28 | this.IsEmpty = isEmpty; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ACadSharp/Attributes/ICodeValueAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Attributes 2 | { 3 | public interface ICodeValueAttribute 4 | { 5 | /// 6 | /// Dxf codes binding the property 7 | /// 8 | public DxfCode[] ValueCodes { get; } 9 | 10 | /// 11 | /// Reference type for this dxf property 12 | /// 13 | public DxfReferenceType ReferenceType { get; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ACadSharp/Blocks/BlockEnd.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using ACadSharp.Entities; 3 | using ACadSharp.Tables; 4 | 5 | namespace ACadSharp.Blocks 6 | { 7 | /// 8 | /// Represents a entity 9 | /// 10 | /// 11 | /// Object name
12 | /// Dxf class name 13 | ///
14 | [DxfName(DxfFileToken.EndBlock)] 15 | [DxfSubClass(DxfSubclassMarker.BlockEnd)] 16 | public class BlockEnd : Entity 17 | { 18 | public override string ObjectName => DxfFileToken.EndBlock; 19 | 20 | public override ObjectType ObjectType => ObjectType.ENDBLK; 21 | 22 | public BlockEnd(BlockRecord record) : base() 23 | { 24 | this.Owner = record; 25 | } 26 | 27 | /// 28 | public override CadObject Clone() 29 | { 30 | BlockEnd clone = (BlockEnd)base.Clone(); 31 | clone.Owner = new BlockRecord((this.Owner as BlockRecord).Name); 32 | return clone; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ACadSharp/Blocks/BlockTypeFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.Blocks 4 | { 5 | /// 6 | /// Block-type flags (bit-coded values, may be combined). 7 | /// 8 | [Flags] 9 | public enum BlockTypeFlags 10 | { 11 | /// 12 | /// None 13 | /// 14 | None = 0, 15 | 16 | /// 17 | /// This is an anonymous block generated by hatching, associative dimensioning, other internal operations, or an application. 18 | /// 19 | Anonymous = 1, 20 | 21 | /// 22 | /// This block has non-constant attribute definitions 23 | /// (this bit is not set if the block has any attribute definitions that are constant, or has no attribute definitions at all). 24 | /// 25 | NonConstantAttributeDefinitions = 2, 26 | 27 | /// 28 | /// This block is an external reference. 29 | /// 30 | XRef = 4, 31 | 32 | /// 33 | /// This block is an external reference overlay. 34 | /// 35 | XRefOverlay = 8, 36 | 37 | /// 38 | /// This block is externally dependent. 39 | /// 40 | XrefDependent = 16, 41 | 42 | /// 43 | /// This is a resolved external reference, or dependent of an external reference (ignored on input). 44 | /// 45 | XrefResolved = 32, 46 | 47 | /// 48 | /// This definition is a referenced external reference (ignored on input). 49 | /// 50 | Referenced = 64 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /ACadSharp/CadSummaryInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace ACadSharp 6 | { 7 | public class CadSummaryInfo 8 | { 9 | public string Title { get; set; } = string.Empty; 10 | 11 | public string Subject { get; set; } = string.Empty; 12 | 13 | public string Author { get; set; } = string.Empty; 14 | 15 | public string Keywords { get; set; } = string.Empty; 16 | 17 | public string Comments { get; set; } = string.Empty; 18 | 19 | public string LastSavedBy { get; set; } = string.Empty; 20 | 21 | public string RevisionNumber { get; set; } = string.Empty; 22 | 23 | public string HyperlinkBase { get; set; } = string.Empty; 24 | 25 | public DateTime CreatedDate { get; set; } = DateTime.Now; 26 | 27 | public DateTime ModifiedDate { get; set; } = DateTime.Now; 28 | 29 | public Dictionary Properties { get; set; } = new Dictionary(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ACadSharp/CadSystemVariable.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using System.Reflection; 3 | 4 | namespace ACadSharp 5 | { 6 | public class CadSystemVariable : DxfPropertyBase 7 | { 8 | public string Name { get { return this._attributeData.Name; } } 9 | 10 | public CadSystemVariable(PropertyInfo property) : base(property) 11 | { 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ACadSharp/Classes/DxfClassCollection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | namespace ACadSharp.Classes 7 | { 8 | public class DxfClassCollection : ICollection 9 | { 10 | public int Count => _list.Count; 11 | 12 | public bool IsReadOnly => false; 13 | 14 | public Dictionary _list = new Dictionary(); 15 | 16 | public void Add(DxfClass item) 17 | { 18 | if (_list.ContainsKey(item.DxfName)) 19 | return; 20 | 21 | _list.Add(item.DxfName, item); 22 | } 23 | 24 | public void Clear() 25 | { 26 | _list.Clear(); 27 | } 28 | 29 | public bool Contains(DxfClass item) 30 | { 31 | return _list.Values.Contains(item); 32 | } 33 | 34 | public void CopyTo(DxfClass[] array, int arrayIndex) 35 | { 36 | throw new NotImplementedException(); 37 | } 38 | 39 | public IEnumerator GetEnumerator() 40 | { 41 | return _list.Values.GetEnumerator(); 42 | } 43 | 44 | public bool Remove(DxfClass item) 45 | { 46 | return this._list.Remove(item.DxfName); 47 | } 48 | 49 | IEnumerator IEnumerable.GetEnumerator() 50 | { 51 | return this._list.Values.GetEnumerator(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /ACadSharp/CollectionChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp 4 | { 5 | public class CollectionChangedEventArgs : EventArgs 6 | { 7 | /// 8 | /// Item that is beeing added or removed from the collection 9 | /// 10 | public CadObject Item { get; } 11 | 12 | public CollectionChangedEventArgs(CadObject item) 13 | { 14 | this.Item = item; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ACadSharp/DwgPreview.cs: -------------------------------------------------------------------------------- 1 | #region copyright 2 | //Copyright 2021, Albert Domenech. 3 | //All rights reserved. 4 | //This source code is licensed under the MIT license. 5 | //See LICENSE file in the project root for full license information. 6 | #endregion 7 | namespace ACadSharp 8 | { 9 | public class DwgPreview 10 | { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ACadSharp/DxfMapBase.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Reflection; 5 | 6 | namespace ACadSharp 7 | { 8 | public abstract class DxfMapBase 9 | { 10 | public string Name { get; set; } 11 | 12 | public Dictionary DxfProperties { get; } = new Dictionary(); 13 | 14 | protected static void addClassProperties(DxfMapBase map, Type type) 15 | { 16 | foreach (var item in cadObjectMapDxf(type)) 17 | { 18 | map.DxfProperties.Add(item.Key, item.Value); 19 | } 20 | } 21 | 22 | protected static IEnumerable> cadObjectMapDxf(Type type) 23 | { 24 | foreach (PropertyInfo p in type.GetProperties(BindingFlags.Public 25 | | BindingFlags.Instance 26 | | BindingFlags.DeclaredOnly)) 27 | { 28 | DxfCodeValueAttribute att = p.GetCustomAttribute(); 29 | if (att == null) 30 | continue; 31 | 32 | if (att.ReferenceType == DxfReferenceType.Count) 33 | { 34 | 35 | } 36 | 37 | foreach (var item in att.ValueCodes) 38 | { 39 | yield return new KeyValuePair((int)item, new DxfProperty((int)item, p)); 40 | } 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /ACadSharp/DxfProperty.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using System; 3 | using System.Linq; 4 | using System.Reflection; 5 | 6 | namespace ACadSharp 7 | { 8 | public class DxfProperty : DxfPropertyBase 9 | { 10 | /// 11 | /// Creates a dxf property referenced to an object property 12 | /// 13 | /// 14 | /// The property must have the 15 | /// 16 | /// 17 | /// 18 | public DxfProperty(PropertyInfo property) : base(property) { } 19 | 20 | /// 21 | /// Creates a dxf property referenced to an object property 22 | /// 23 | /// 24 | /// The property must have the 25 | /// 26 | /// assigned value for this property, only useful if the property has multiple codes assigned 27 | /// 28 | /// 29 | public DxfProperty(int code, PropertyInfo property) : this(property) 30 | { 31 | if (!this._attributeData.ValueCodes.Contains((DxfCode)code)) 32 | throw new ArgumentException($"The {nameof(DxfCodeValueAttribute)} does not have match with the code {code}", nameof(property)); 33 | 34 | this._assignedCode = code; 35 | } 36 | 37 | public DxfCode[] GetCollectionCodes() 38 | { 39 | return this._property.GetCustomAttribute()?.ValueCodes; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ACadSharp/Entities/AttachmentPointType.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Entities 2 | { 3 | /// 4 | /// Attachment point for Multiline text. 5 | /// 6 | public enum AttachmentPointType : short 7 | { 8 | /// Top left. 9 | TopLeft = 1, 10 | 11 | /// Top center. 12 | TopCenter = 2, 13 | 14 | /// Top right. 15 | TopRight = 3, 16 | 17 | /// Middle left. 18 | MiddleLeft = 4, 19 | 20 | /// Middle center. 21 | MiddleCenter = 5, 22 | 23 | /// Middle right. 24 | MiddleRight = 6, 25 | 26 | /// Bottom left. 27 | BottomLeft = 7, 28 | 29 | /// Bottom center. 30 | BottomCenter = 8, 31 | 32 | /// Bottom right. 33 | BottomRight = 9, 34 | } 35 | } -------------------------------------------------------------------------------- /ACadSharp/Entities/AttributeDefinition.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | 3 | namespace ACadSharp.Entities 4 | { 5 | /// 6 | /// Represents a entity. 7 | /// 8 | /// 9 | /// Object name
10 | /// Dxf class name 11 | ///
12 | [DxfName(DxfFileToken.EntityAttributeDefinition)] 13 | [DxfSubClass(DxfSubclassMarker.AttributeDefinition)] 14 | public class AttributeDefinition : AttributeBase 15 | { 16 | /// 17 | public override ObjectType ObjectType => ObjectType.ATTDEF; 18 | 19 | /// 20 | public override string ObjectName => DxfFileToken.EntityAttributeDefinition; 21 | 22 | /// 23 | /// Prompt text for this attribute. 24 | /// 25 | [DxfCodeValue(3)] 26 | public string Prompt { get; set; } = string.Empty; 27 | 28 | public AttributeDefinition() : base() { } 29 | 30 | public AttributeDefinition(AttributeEntity entity) : this() 31 | { 32 | this.matchAttributeProperties(entity); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ACadSharp/Entities/AttributeEntity.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | 3 | namespace ACadSharp.Entities 4 | { 5 | /// 6 | /// Represents a entity. 7 | /// 8 | /// 9 | /// Object name
10 | /// Dxf class name 11 | ///
12 | [DxfName(DxfFileToken.EntityAttribute)] 13 | [DxfSubClass(DxfSubclassMarker.Attribute)] 14 | public class AttributeEntity : AttributeBase 15 | { 16 | /// 17 | public override ObjectType ObjectType => ObjectType.ATTRIB; 18 | 19 | /// 20 | public override string ObjectName => DxfFileToken.EntityAttribute; 21 | 22 | /// 23 | /// Default constructor 24 | /// 25 | public AttributeEntity() : base() { } 26 | 27 | public AttributeEntity(AttributeDefinition definition) : this() 28 | { 29 | this.matchAttributeProperties(definition); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ACadSharp/Entities/AttributeFlags.cs: -------------------------------------------------------------------------------- 1 | #region copyright 2 | //Copyright 2021, Albert Domenech. 3 | //All rights reserved. 4 | //This source code is licensed under the MIT license. 5 | //See LICENSE file in the project root for full license information. 6 | #endregion 7 | using System; 8 | 9 | namespace ACadSharp.Entities 10 | { 11 | /// 12 | ///Attribute flags. 13 | /// 14 | [Flags] 15 | public enum AttributeFlags 16 | { 17 | /// 18 | /// No flags. 19 | /// 20 | None = 0, 21 | /// 22 | /// Attribute is invisible (does not appear). 23 | /// 24 | Hidden = 1, 25 | /// 26 | /// This is a constant attribute. 27 | /// 28 | Constant = 2, 29 | /// 30 | /// Verification is required on input of this attribute. 31 | /// 32 | Verify = 4, 33 | /// 34 | /// Attribute is preset (no prompt during insertion). 35 | /// 36 | Preset = 8 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ACadSharp/Entities/BackgroundFillFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.Entities 4 | { 5 | /// 6 | /// Represents a background fill flags 7 | /// 8 | [Flags] 9 | public enum BackgroundFillFlags : byte 10 | { 11 | /// 12 | /// None 13 | /// 14 | None = 0, 15 | 16 | /// 17 | /// Use the background color 18 | /// 19 | UseBackgroundFillColor = 1, 20 | 21 | /// 22 | /// Use the drawing window color 23 | /// 24 | UseDrawingWindowColor = 2, 25 | 26 | /// 27 | /// Adds a text frame 28 | /// 29 | /// 30 | /// Introduced in AutoCAD 2018 31 | /// 32 | TextFrame = 16, // 0x10 33 | } 34 | } -------------------------------------------------------------------------------- /ACadSharp/Entities/Circle.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using CSMath; 3 | 4 | namespace ACadSharp.Entities 5 | { 6 | /// 7 | /// Represents a entity. 8 | /// 9 | /// 10 | /// Object name
11 | /// Dxf class name 12 | ///
13 | [DxfName(DxfFileToken.EntityCircle)] 14 | [DxfSubClass(DxfSubclassMarker.Circle)] 15 | public class Circle : Entity 16 | { 17 | /// 18 | public override ObjectType ObjectType => ObjectType.CIRCLE; 19 | 20 | /// 21 | public override string ObjectName => DxfFileToken.EntityCircle; 22 | 23 | /// 24 | /// Specifies the three-dimensional normal unit vector for the object. 25 | /// 26 | [DxfCodeValue(210, 220, 230)] 27 | public XYZ Normal { get; set; } = XYZ.AxisZ; 28 | 29 | /// 30 | /// Specifies the distance a 2D AutoCAD object is extruded above or below its elevation. 31 | /// 32 | [DxfCodeValue(39)] 33 | public double Thickness { get; set; } = 0.0; 34 | 35 | /// 36 | /// Specifies the center of an arc, circle, ellipse, view, or viewport. 37 | /// 38 | [DxfCodeValue(10, 20, 30)] 39 | public XYZ Center { get; set; } = XYZ.Zero; 40 | 41 | /// 42 | /// Specifies the radius of an arc, circle, or position marker. 43 | /// 44 | [DxfCodeValue(40)] 45 | public double Radius { get; set; } = 1.0; 46 | 47 | /// 48 | /// Default constructor 49 | /// 50 | public Circle() : base() { } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /ACadSharp/Entities/ColumnType.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Entities 2 | { 3 | /// 4 | /// Represents the type of columns. 5 | /// 6 | public enum ColumnType : short 7 | { 8 | NoColumns, 9 | 10 | StaticColumns, 11 | 12 | DynamicColumns, 13 | } 14 | } -------------------------------------------------------------------------------- /ACadSharp/Entities/DimensionAligned.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using CSMath; 3 | 4 | namespace ACadSharp.Entities 5 | { 6 | /// 7 | /// Represents a entity. 8 | /// 9 | /// 10 | /// Object name
11 | /// Dxf class name 12 | ///
13 | [DxfName(DxfFileToken.EntityDimension)] 14 | [DxfSubClass(DxfSubclassMarker.AlignedDimension)] 15 | public class DimensionAligned : Dimension 16 | { 17 | /// 18 | public override ObjectType ObjectType => ObjectType.DIMENSION_ALIGNED; 19 | 20 | /// 21 | public override string ObjectName => DxfFileToken.EntityDimension; 22 | 23 | /// 24 | /// Insertion point for clones of a dimension—Baseline and Continue (in OCS) 25 | /// 26 | [DxfCodeValue(13, 23, 33)] 27 | public XYZ FirstPoint { get; set; } 28 | 29 | /// 30 | /// Definition point for linear and angular dimensions(in WCS) 31 | /// 32 | [DxfCodeValue(14, 24, 34)] 33 | public XYZ SecondPoint { get; set; } 34 | 35 | /// 36 | /// Linear dimension types with an oblique angle have an optional group code 52. 37 | /// When added to the rotation angle of the linear dimension(group code 50), 38 | /// it gives the angle of the extension lines 39 | /// 40 | [DxfCodeValue(52)] 41 | public double ExtLineRotation { get; set; } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ACadSharp/Entities/DimensionAngular2Line.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using CSMath; 3 | 4 | namespace ACadSharp.Entities 5 | { 6 | /// 7 | /// Represents a entity. 8 | /// 9 | /// 10 | /// Object name
11 | /// Dxf class name 12 | ///
13 | [DxfName(DxfFileToken.EntityDimension)] 14 | [DxfSubClass(DxfSubclassMarker.Angular2LineDimension)] 15 | public class DimensionAngular2Line : Dimension 16 | { 17 | /// 18 | public override ObjectType ObjectType => ObjectType.DIMENSION_ANG_2_Ln; 19 | 20 | /// 21 | public override string ObjectName => DxfFileToken.EntityDimension; 22 | 23 | /// 24 | /// Definition point for linear and angular dimensions (in WCS) 25 | /// 26 | [DxfCodeValue(13, 23, 33)] 27 | public XYZ FirstPoint { get; set; } 28 | 29 | /// 30 | /// Definition point for linear and angular dimensions (in WCS) 31 | /// 32 | [DxfCodeValue(14, 24, 34)] 33 | public XYZ SecondPoint { get; set; } 34 | 35 | /// 36 | /// Definition point for diameter, radius, and angular dimensions (in WCS) 37 | /// 38 | [DxfCodeValue(15, 25, 35)] 39 | public XYZ AngleVertex { get; set; } 40 | 41 | /// 42 | /// Point defining dimension arc for angular dimensions (in OCS) 43 | /// 44 | [DxfCodeValue(16, 26, 36)] 45 | public XYZ DimensionArc { get; set; } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /ACadSharp/Entities/DimensionAngular3Pt.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using CSMath; 3 | 4 | namespace ACadSharp.Entities 5 | { 6 | /// 7 | /// Represents a entity. 8 | /// 9 | /// 10 | /// Object name
11 | /// Dxf class name 12 | ///
13 | [DxfName(DxfFileToken.EntityDimension)] 14 | [DxfSubClass(DxfSubclassMarker.Angular3PointDimension)] 15 | public class DimensionAngular3Pt : Dimension 16 | { 17 | /// 18 | public override ObjectType ObjectType => ObjectType.DIMENSION_ANG_3_Pt; 19 | 20 | /// 21 | public override string ObjectName => DxfFileToken.EntityDimension; 22 | 23 | /// 24 | /// Definition point for linear and angular dimensions (in WCS) 25 | /// 26 | [DxfCodeValue(13, 23, 33)] 27 | public XYZ FirstPoint { get; set; } 28 | 29 | /// 30 | /// Definition point for linear and angular dimensions (in WCS) 31 | /// 32 | [DxfCodeValue(14, 24, 34)] 33 | public XYZ SecondPoint { get; set; } 34 | 35 | /// 36 | /// Definition point for diameter, radius, and angular dimensions (in WCS) 37 | /// 38 | [DxfCodeValue(15, 25, 35)] 39 | public XYZ AngleVertex { get; set; } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ACadSharp/Entities/DimensionDiameter.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using CSMath; 3 | 4 | namespace ACadSharp.Entities 5 | { 6 | /// 7 | /// Represents a entity. 8 | /// 9 | /// 10 | /// Object name
11 | /// Dxf class name 12 | ///
13 | [DxfName(DxfFileToken.EntityDimension)] 14 | [DxfSubClass(DxfSubclassMarker.DiametricDimension)] 15 | public class DimensionDiameter : Dimension 16 | { 17 | /// 18 | public override ObjectType ObjectType => ObjectType.DIMENSION_DIAMETER; 19 | 20 | /// 21 | public override string ObjectName => DxfFileToken.EntityDimension; 22 | 23 | /// 24 | /// Definition point for diameter, radius, and angular dimensions(in WCS) 25 | /// 26 | [DxfCodeValue(15, 25, 35)] 27 | public XYZ AngleVertex { get; set; } 28 | 29 | /// 30 | /// Leader length for radius and diameter dimensions 31 | /// 32 | [DxfCodeValue(40)] 33 | public double LeaderLength { get; set; } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ACadSharp/Entities/DimensionLinear.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | 3 | namespace ACadSharp.Entities 4 | { 5 | /// 6 | /// Represents a entity. 7 | /// 8 | /// 9 | /// Object name
10 | /// Dxf class name 11 | ///
12 | [DxfName(DxfFileToken.EntityDimension)] 13 | [DxfSubClass(DxfSubclassMarker.LinearDimension)] 14 | public class DimensionLinear : DimensionAligned 15 | { 16 | public override ObjectType ObjectType => ObjectType.DIMENSION_LINEAR; 17 | 18 | public override string ObjectName => DxfFileToken.EntityDimension; 19 | 20 | /// 21 | /// Angle of rotated, horizontal, or vertical dimensions 22 | /// 23 | [DxfCodeValue(DxfReferenceType.IsAngle, 50)] 24 | public double Rotation { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ACadSharp/Entities/DimensionOrdinate.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using CSMath; 3 | 4 | namespace ACadSharp.Entities 5 | { 6 | /// 7 | /// Represents a entity. 8 | /// 9 | /// 10 | /// Object name
11 | /// Dxf class name 12 | ///
13 | [DxfName(DxfFileToken.EntityDimension)] 14 | [DxfSubClass(DxfSubclassMarker.OrdinateDimension)] 15 | public class DimensionOrdinate : Dimension 16 | { 17 | /// 18 | public override ObjectType ObjectType => ObjectType.DIMENSION_ORDINATE; 19 | 20 | /// 21 | public override string ObjectName => DxfFileToken.EntityDimension; 22 | 23 | //100 Subclass marker(AcDbOrdinateDimension) 24 | 25 | /// 26 | /// Definition point for linear and angular dimensions (in WCS) 27 | /// 28 | [DxfCodeValue(13, 23, 33)] 29 | public XYZ FeatureLocation { get; set; } 30 | 31 | /// 32 | /// Definition point for linear and angular dimensions (in WCS) 33 | /// 34 | [DxfCodeValue(14, 24, 34)] 35 | public XYZ LeaderEndpoint { get; set; } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ACadSharp/Entities/DimensionRadius.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using CSMath; 3 | 4 | namespace ACadSharp.Entities 5 | { 6 | /// 7 | /// Represents a entity. 8 | /// 9 | /// 10 | /// Object name
11 | /// Dxf class name 12 | ///
13 | [DxfName(DxfFileToken.EntityDimension)] 14 | [DxfSubClass(DxfSubclassMarker.RadialDimension)] 15 | public class DimensionRadius : Dimension 16 | { 17 | /// 18 | public override ObjectType ObjectType => ObjectType.DIMENSION_RADIUS; 19 | 20 | /// 21 | public override string ObjectName => DxfFileToken.EntityDimension; 22 | 23 | /// 24 | /// Definition point for diameter, radius, and angular dimensions(in WCS) 25 | /// 26 | [DxfCodeValue(15, 25, 35)] 27 | public XYZ AngleVertex { get; set; } 28 | 29 | /// 30 | /// Leader length for radius and diameter dimensions 31 | /// 32 | [DxfCodeValue(40)] 33 | public double LeaderLength { get; set; } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ACadSharp/Entities/DimensionType.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Entities 2 | { 3 | /// 4 | /// Dimension type 5 | /// 6 | public enum DimensionType 7 | { 8 | /// 9 | /// Rotated, horizontal, or vertical 10 | /// 11 | Linear = 0, 12 | 13 | /// 14 | /// Aligned 15 | /// 16 | Aligned = 1, 17 | 18 | /// 19 | /// Angular 2 lines 20 | /// 21 | Angular = 2, 22 | 23 | /// 24 | /// Diameter 25 | /// 26 | Diameter = 3, 27 | 28 | /// 29 | /// Radius 30 | /// 31 | Radius = 4, 32 | 33 | /// 34 | /// Angular 3 points 35 | /// 36 | Angular3Point = 5, 37 | 38 | /// 39 | /// Ordinate 40 | /// 41 | Ordinate = 6, 42 | 43 | /// 44 | /// Indicates that the block reference(group code 2) is referenced by this dimension only 45 | /// 46 | BlockReference = 32, 47 | 48 | /// 49 | /// Ordinate type.This is a bit value (bit 7) used only with integer value 6. If set, ordinate is X-type; if not set, ordinate is Y-type 50 | /// 51 | OrdinateBit = 64, 52 | 53 | /// 54 | /// This is a bit value(bit 8) added to the other group 70 values if the dimension text has been positioned at a user-defined location rather than at the default location 55 | /// 56 | UserDefinedLocation = 128 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /ACadSharp/Entities/DrawingDirectionType.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Entities 2 | { 3 | /// 4 | /// Multiline text drawing direction. 5 | /// 6 | public enum DrawingDirectionType : short 7 | { 8 | /// Left to right. 9 | LeftToRight = 1, 10 | 11 | /// Right to left. 12 | RightToLeft = 2, 13 | 14 | /// Top to bottom. 15 | TopToBottom = 3, 16 | 17 | /// Bottom to top. 18 | BottomToTop = 4, 19 | 20 | /// By Style. 21 | ByStyle = 5, 22 | } 23 | } -------------------------------------------------------------------------------- /ACadSharp/Entities/GradientColor.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | 3 | namespace ACadSharp.Entities 4 | { 5 | public class GradientColor 6 | { 7 | /// 8 | /// Gradient value 9 | /// 10 | /// 11 | /// The value must be in the range 0-1 12 | /// 13 | [DxfCodeValue(463)] 14 | public double Value { get; set; } 15 | 16 | /// 17 | /// Color for this gradient 18 | /// 19 | [DxfCodeValue(421)] 20 | public Color Color { get; set; } 21 | 22 | public GradientColor Clone() 23 | { 24 | return (GradientColor)this.MemberwiseClone(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ACadSharp/Entities/Hatch.BoundaryPath.Arc.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using CSMath; 3 | 4 | namespace ACadSharp.Entities 5 | { 6 | public partial class Hatch 7 | { 8 | public partial class BoundaryPath 9 | { 10 | public class Arc : Edge 11 | { 12 | /// 13 | public override EdgeType Type => EdgeType.CircularArc; 14 | 15 | /// 16 | /// Center point (in OCS) 17 | /// 18 | [DxfCodeValue(10, 20)] 19 | public XY Center { get; set; } 20 | 21 | /// 22 | /// Radius 23 | /// 24 | /// 25 | /// For the ellispe this is the length of minor axis (percentage of major axis length) 26 | /// 27 | [DxfCodeValue(40)] 28 | public double Radius { get; set; } 29 | 30 | /// 31 | /// Start angle 32 | /// 33 | [DxfCodeValue(50)] 34 | public double StartAngle { get; set; } 35 | 36 | /// 37 | /// End angle 38 | /// 39 | [DxfCodeValue(51)] 40 | public double EndAngle { get; set; } 41 | 42 | /// 43 | /// Is counterclockwise flag 44 | /// 45 | [DxfCodeValue(73)] 46 | public bool CounterClockWise { get; set; } 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /ACadSharp/Entities/Hatch.BoundaryPath.Edge.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Entities 2 | { 3 | public partial class Hatch 4 | { 5 | public partial class BoundaryPath 6 | { 7 | public enum EdgeType 8 | { 9 | /// 10 | /// Not included in the documentation 11 | /// 12 | Polyline = 0, 13 | Line = 1, 14 | CircularArc = 2, 15 | EllipticArc = 3, 16 | Spline = 4, 17 | } 18 | 19 | public abstract class Edge 20 | { 21 | /// 22 | /// Edge type 23 | /// 24 | public abstract EdgeType Type { get; } 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ACadSharp/Entities/Hatch.BoundaryPath.Ellipse.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using CSMath; 3 | 4 | namespace ACadSharp.Entities 5 | { 6 | public partial class Hatch 7 | { 8 | public partial class BoundaryPath 9 | { 10 | public class Ellipse : Arc 11 | { 12 | /// 13 | public override EdgeType Type => EdgeType.EllipticArc; 14 | 15 | /// 16 | /// Endpoint of major axis relative to center point (in OCS) 17 | /// 18 | [DxfCodeValue(11, 21)] 19 | public XY MajorAxisEndPoint { get; set; } 20 | 21 | /// 22 | /// Length of minor axis (percentage of major axis length) 23 | /// 24 | [DxfCodeValue(40)] 25 | public double MinorToMajorRatio { get; set; } 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ACadSharp/Entities/Hatch.BoundaryPath.Line.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using CSMath; 3 | 4 | namespace ACadSharp.Entities 5 | { 6 | public partial class Hatch 7 | { 8 | public partial class BoundaryPath 9 | { 10 | public class Line : Edge 11 | { 12 | public override EdgeType Type => EdgeType.Line; 13 | 14 | /// 15 | /// Start point (in OCS) 16 | /// 17 | [DxfCodeValue(10, 20)] 18 | public XY Start { get; set; } 19 | 20 | /// 21 | /// Endpoint (in OCS) 22 | /// 23 | [DxfCodeValue(11, 21)] 24 | public XY End { get; set; } 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ACadSharp/Entities/Hatch.BoundaryPath.Polyline.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using CSMath; 3 | using System.Collections.Generic; 4 | 5 | namespace ACadSharp.Entities 6 | { 7 | public partial class Hatch 8 | { 9 | public partial class BoundaryPath 10 | { 11 | public class Polyline : Edge 12 | { 13 | /// 14 | public override EdgeType Type => EdgeType.Polyline; 15 | 16 | /// 17 | /// Has bulge flag 18 | /// 19 | [DxfCodeValue(72)] 20 | public bool HasBulge { get { return Bulge != 0; } } 21 | 22 | /// 23 | /// Is closed flag 24 | /// 25 | [DxfCodeValue(73)] 26 | public bool IsClosed { get; set; } 27 | 28 | /// 29 | /// Bulge 30 | /// 31 | /// 32 | /// optional, default = 0 33 | /// 34 | [DxfCodeValue(42)] 35 | public double Bulge { get; set; } = 0.0; 36 | 37 | /// 38 | /// Position values are only X and Y 39 | /// 40 | [DxfCodeValue(93)] 41 | public List Vertices { get; set; } = new List(); 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /ACadSharp/Entities/Hatch.BoundaryPath.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using System.Collections.Generic; 3 | 4 | namespace ACadSharp.Entities 5 | { 6 | public partial class Hatch 7 | { 8 | public partial class BoundaryPath 9 | { 10 | /// 11 | /// Boundary path type flag 12 | /// 13 | [DxfCodeValue(92)] 14 | public BoundaryPathFlags Flags { get; set; } 15 | 16 | /// 17 | /// Number of edges in this boundary path 18 | /// 19 | /// 20 | /// only if boundary is not a polyline 21 | /// 22 | [DxfCodeValue(DxfReferenceType.Count, 93)] 23 | public List Edges { get; set; } = new List(); 24 | 25 | /// 26 | /// Source boundary objects 27 | /// 28 | [DxfCodeValue(DxfReferenceType.Count, 97)] 29 | public List Entities { get; set; } = new List(); 30 | 31 | public BoundaryPath Clone() 32 | { 33 | throw new System.NotImplementedException(); 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ACadSharp/Entities/HatchPattern.cs: -------------------------------------------------------------------------------- 1 | using CSMath; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace ACadSharp.Entities 6 | { 7 | //TODO: FIX the hatch mess!!!! 8 | public class HatchPattern 9 | { 10 | public readonly static HatchPattern Solid = new HatchPattern("SOLID"); 11 | 12 | public class Line 13 | { 14 | public double Angle { get; internal set; } 15 | public XY BasePoint { get; internal set; } 16 | public XY Offset { get; internal set; } 17 | public List DashLengths { get; set; } = new List(); 18 | 19 | public Line Clone() 20 | { 21 | Line clone = (Line)this.MemberwiseClone(); 22 | clone.DashLengths = new List(this.DashLengths); 23 | return clone; 24 | } 25 | } 26 | 27 | public string Name { get; set; } 28 | public double Angle { get; set; } 29 | public double Scale { get; set; } 30 | 31 | public List Lines { get; set; } = new List(); 32 | 33 | public HatchPattern(string name) 34 | { 35 | Name = name; 36 | } 37 | 38 | public HatchPattern Clone() 39 | { 40 | HatchPattern clone = (HatchPattern)this.MemberwiseClone(); 41 | 42 | clone.Lines.Clear(); 43 | foreach (var item in this.Lines) 44 | { 45 | clone.Lines.Add(item.Clone()); 46 | } 47 | 48 | return clone; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /ACadSharp/Entities/HatchPatternType.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Entities 2 | { 3 | /// 4 | /// Hatch pattern fill type. 5 | /// 6 | public enum HatchPatternType 7 | { 8 | /// 9 | /// Pattern fill. 10 | /// 11 | PatternFill = 0, 12 | /// 13 | /// Solid fill. 14 | /// 15 | SolidFill = 1, 16 | /// 17 | /// Custom hatch pattern from a pattern file. 18 | /// 19 | Custom = 2, 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ACadSharp/Entities/HatchStyleType.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Entities 2 | { 3 | /// 4 | /// Hatch pattern style. 5 | /// 6 | public enum HatchStyleType 7 | { 8 | /// 9 | /// Hatch "odd parity" area. 10 | /// 11 | Normal = 0, 12 | /// 13 | /// Hatch outermost area only. 14 | /// 15 | Outer = 1, 16 | /// 17 | /// Hatch through entire area. 18 | /// 19 | Ignore = 2 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ACadSharp/Entities/IPolyline.cs: -------------------------------------------------------------------------------- 1 | using CSMath; 2 | using System.Collections.Generic; 3 | 4 | namespace ACadSharp.Entities 5 | { 6 | public interface IPolyline : IEntity 7 | { 8 | /// 9 | /// Indicates that the polyline is closed 10 | /// 11 | bool IsClosed { get; } 12 | 13 | IEnumerable Vertices { get; } 14 | 15 | /// 16 | /// The current elevation of the object. 17 | /// 18 | double Elevation { get; } 19 | 20 | /// 21 | /// Specifies the three-dimensional normal unit vector for the object. 22 | /// 23 | XYZ Normal { get; } 24 | 25 | /// 26 | /// Specifies the distance a 2D AutoCAD object is extruded above or below its elevation. 27 | /// 28 | double Thickness { get; } 29 | 30 | IEnumerable Explode(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ACadSharp/Entities/IVertex.cs: -------------------------------------------------------------------------------- 1 | using CSMath; 2 | 3 | namespace ACadSharp.Entities 4 | { 5 | public interface IVertex 6 | { 7 | /// 8 | /// Location point (in OCS when 2D, and WCS when 3D) 9 | /// 10 | IVector Location { get; } 11 | 12 | /// 13 | /// The bulge is the tangent of one fourth the included angle for an arc segment, made negative if the arc goes clockwise from the start point to the endpoint.A bulge of 0 indicates a straight segment, and a bulge of 1 is a semicircle 14 | /// 15 | double Bulge { get; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ACadSharp/Entities/InvisibleEdgeFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.Entities 4 | { 5 | /// 6 | /// Defines which edges are hidden. 7 | /// 8 | [Flags] 9 | public enum InvisibleEdgeFlags 10 | { 11 | /// 12 | /// No flags equivalent to all edges are visible. 13 | /// 14 | None = 0, 15 | /// 16 | /// First edge is invisible. 17 | /// 18 | First = 1, 19 | /// 20 | /// Second edge is invisible. 21 | /// 22 | Second = 2, 23 | /// 24 | /// Third edge is invisible. 25 | /// 26 | Third = 4, 27 | /// 28 | /// Fourth edge is invisible. 29 | /// 30 | Fourth = 8 31 | } 32 | } -------------------------------------------------------------------------------- /ACadSharp/Entities/KnotParameterization.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Entities 2 | { 3 | /// 4 | /// Knot parameterization 5 | /// 6 | public enum KnotParameterization : ushort 7 | { 8 | /// 9 | /// Chord 10 | /// 11 | Chord = 0, 12 | 13 | /// 14 | /// Square root 15 | /// 16 | SquareRoot = 1, 17 | 18 | /// 19 | /// Uniform 20 | /// 21 | Uniform = 2, 22 | 23 | /// 24 | /// Custom 25 | /// 26 | Custom = 15, 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ACadSharp/Entities/LeaderCreationType.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Entities 2 | { 3 | /// 4 | /// Leader creation type 5 | /// 6 | public enum LeaderCreationType : short 7 | { 8 | /// 9 | /// Created with text annotation 10 | /// 11 | CreatedWithTextAnnotation = 0, 12 | 13 | /// 14 | /// Created with tolerance annotation 15 | /// 16 | CreatedWithToleranceAnnotation = 1, 17 | 18 | /// 19 | /// Created with block reference annotation 20 | /// 21 | CreatedWithBlockReferenceAnnotation = 2, 22 | 23 | /// 24 | /// Created without any annotation 25 | /// 26 | CreatedWithoutAnnotation = 3 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ACadSharp/Entities/LeaderPathType.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Entities 2 | { 3 | /// 4 | /// Controls the way the leader is drawn. 5 | /// 6 | public enum LeaderPathType 7 | { 8 | /// 9 | /// Draws the leader line as a set of straight line segments 10 | /// 11 | StraightLineSegments = 0, 12 | 13 | /// 14 | /// Draws the leader line as a spline 15 | /// 16 | Spline = 1 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ACadSharp/Entities/LightingType.cs: -------------------------------------------------------------------------------- 1 | #region copyright 2 | //Copyright 2021, Albert Domenech. 3 | //All rights reserved. 4 | //This source code is licensed under the MIT license. 5 | //See LICENSE file in the project root for full license information. 6 | #endregion 7 | 8 | namespace ACadSharp.Entities 9 | { 10 | /// Represents lighting type. 11 | public enum LightingType : byte 12 | { 13 | /// One distant light. 14 | OneDistantLight, 15 | /// Two distant lights. 16 | TwoDistantLights, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ACadSharp/Entities/Line.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using CSMath; 3 | 4 | namespace ACadSharp.Entities 5 | { 6 | /// 7 | /// Represents a entity. 8 | /// 9 | /// 10 | /// Object name
11 | /// Dxf class name 12 | ///
13 | [DxfName(DxfFileToken.EntityLine)] 14 | [DxfSubClass(DxfSubclassMarker.Line)] 15 | public class Line : Entity 16 | { 17 | /// 18 | public override ObjectType ObjectType => ObjectType.LINE; 19 | 20 | /// 21 | public override string ObjectName => DxfFileToken.EntityLine; 22 | 23 | /// 24 | /// Specifies the distance a 2D AutoCAD object is extruded above or below its elevation. 25 | /// 26 | [DxfCodeValue(39)] 27 | public double Thickness { get; set; } = 0.0; 28 | 29 | /// 30 | /// Specifies the three-dimensional normal unit vector for the object. 31 | /// 32 | [DxfCodeValue(210, 220, 230)] 33 | public XYZ Normal { get; set; } = XYZ.AxisZ; 34 | 35 | /// 36 | /// A 3D coordinate representing the start point of the object. 37 | /// 38 | [DxfCodeValue(10, 20, 30)] 39 | public XYZ StartPoint { get; set; } = XYZ.Zero; 40 | 41 | /// 42 | /// A 3D coordinate representing the end point of the object. 43 | /// 44 | [DxfCodeValue(11, 21, 31)] 45 | public XYZ EndPoint { get; set; } = XYZ.Zero; 46 | 47 | /// 48 | /// Default constructor 49 | /// 50 | public Line() : base() { } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /ACadSharp/Entities/LineSpacingStyleType.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Entities 2 | { 3 | /// 4 | /// Line spacing style for Multiline text and Dimensions. 5 | /// 6 | public enum LineSpacingStyleType : short 7 | { 8 | /// None. 9 | None, 10 | 11 | /// Taller characters will override. 12 | AtLeast, 13 | 14 | /// Taller characters will not override. 15 | Exact, 16 | } 17 | } -------------------------------------------------------------------------------- /ACadSharp/Entities/LwPolylineFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.Entities 4 | { 5 | /// 6 | /// Polyline flag (bit-coded) 7 | /// 8 | [Flags] 9 | public enum LwPolylineFlags 10 | { 11 | Default = 0, 12 | Closed = 1, 13 | Plinegen = 128 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ACadSharp/Entities/MLineFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.Entities 4 | { 5 | /// 6 | /// Flags (bit-coded values) 7 | /// 8 | [Flags] 9 | public enum MLineFlags 10 | { 11 | /// 12 | /// Has at least one vertex (code 72 is greater than 0) 13 | /// 14 | Has = 1, 15 | 16 | /// 17 | /// Closed 18 | /// 19 | Closed = 2, 20 | 21 | /// 22 | /// Suppress start caps 23 | /// 24 | NoStartCaps = 4, 25 | 26 | /// 27 | /// Suppress end caps 28 | /// 29 | NoEndCaps = 8 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ACadSharp/Entities/MLineJustification.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Entities 2 | { 3 | /// 4 | /// Justification 5 | /// 6 | public enum MLineJustification 7 | { 8 | /// 9 | /// Top 10 | /// 11 | Top = 0, 12 | 13 | /// 14 | /// Zero 15 | /// 16 | Zero = 1, 17 | 18 | /// 19 | /// Bottom 20 | /// 21 | Bottom = 2 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ACadSharp/Entities/MText.TextColumn.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using System.Collections.Generic; 3 | 4 | namespace ACadSharp.Entities 5 | { 6 | public partial class MText 7 | { 8 | public class TextColumn 9 | { 10 | /// 11 | /// Text column type 12 | /// 13 | [DxfCodeValue(75)] 14 | public ColumnType ColumnType { get; set; } 15 | 16 | /// 17 | /// Number of columns 18 | /// 19 | [DxfCodeValue(76)] 20 | public int ColumnCount { get { return this.ColumnHeights.Count; } } 21 | 22 | /// 23 | /// Gets or sets a value indicating whether flow is reversed 24 | /// 25 | [DxfCodeValue(78)] 26 | public bool ColumnFlowReversed { get; set; } 27 | 28 | /// 29 | /// Gets or sets a value indicating whether height is automatic 30 | /// 31 | [DxfCodeValue(79)] 32 | public bool ColumnAutoHeight { get; set; } 33 | 34 | /// 35 | /// Width of the column. 36 | /// 37 | [DxfCodeValue(48)] 38 | public double ColumnWidth { get; set; } 39 | 40 | /// 41 | /// Column gutter. 42 | /// 43 | [DxfCodeValue(49)] 44 | public double ColumnGutter { get; set; } 45 | 46 | /// 47 | /// Column heights. 48 | /// 49 | [DxfCodeValue(50)] 50 | public List ColumnHeights { get; } = new List(); 51 | 52 | public TextColumn Clone() 53 | { 54 | return this.MemberwiseClone() as TextColumn; 55 | } 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /ACadSharp/Entities/Point.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using ACadSharp.IO.Templates; 3 | using CSMath; 4 | 5 | namespace ACadSharp.Entities 6 | { 7 | /// 8 | /// Represents a entity. 9 | /// 10 | /// 11 | /// Object name
12 | /// Dxf class name 13 | ///
14 | [DxfName(DxfFileToken.EntityPoint)] 15 | [DxfSubClass(DxfSubclassMarker.Point)] 16 | public class Point : Entity 17 | { 18 | /// 19 | public override ObjectType ObjectType => ObjectType.POINT; 20 | 21 | /// 22 | public override string ObjectName => DxfFileToken.EntityPoint; 23 | 24 | /// 25 | /// Point location(in WCS) 26 | /// 27 | [DxfCodeValue(10, 20, 30)] 28 | public XYZ Location { get; set; } = XYZ.Zero; 29 | 30 | /// 31 | /// Specifies the distance a 2D AutoCAD object is extruded above or below its elevation. 32 | /// 33 | [DxfCodeValue(39)] 34 | public double Thickness { get; set; } = 0.0; 35 | 36 | /// 37 | /// Specifies the three-dimensional normal unit vector for the object. 38 | /// 39 | [DxfCodeValue(210, 220, 230)] 40 | public XYZ Normal { get; set; } = XYZ.AxisZ; 41 | 42 | /// 43 | /// Specifies the rotation angle for the object. 44 | /// 45 | /// 46 | /// The rotation angle in radians. 47 | /// 48 | [DxfCodeValue(DxfReferenceType.IsAngle, 50)] 49 | public double Rotation { get; set; } = 0.0; 50 | 51 | public Point() : base() { } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /ACadSharp/Entities/PolyLine2D.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace ACadSharp.Entities 6 | { 7 | /// 8 | /// Represents a entity. 9 | /// 10 | /// 11 | /// Object name
12 | /// Dxf class name 13 | ///
14 | [DxfName(DxfFileToken.EntityPolyline)] 15 | [DxfSubClass(DxfSubclassMarker.Polyline)] 16 | public class Polyline2D : Polyline 17 | { 18 | /// 19 | public override ObjectType ObjectType => ObjectType.POLYLINE_2D; 20 | 21 | public Polyline2D() : base() 22 | { 23 | this.Vertices.OnAdd += this.verticesOnAdd; 24 | } 25 | 26 | public override IEnumerable Explode() 27 | { 28 | return Polyline.explode(this); 29 | } 30 | 31 | private void verticesOnAdd(object sender, CollectionChangedEventArgs e) 32 | { 33 | if (e.Item is not Vertex2D) 34 | { 35 | this.Vertices.Remove((Vertex)e.Item); 36 | throw new ArgumentException($"Wrong vertex type for {DxfSubclassMarker.Polyline}"); 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ACadSharp/Entities/PolyLine3D.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace ACadSharp.Entities 6 | { 7 | /// 8 | /// Represents a entity. 9 | /// 10 | /// 11 | /// Object name
12 | /// Dxf class name 13 | ///
14 | [DxfName(DxfFileToken.EntityPolyline)] 15 | [DxfSubClass(DxfSubclassMarker.Polyline3d)] 16 | public class Polyline3D : Polyline 17 | { 18 | /// 19 | public override ObjectType ObjectType => ObjectType.POLYLINE_3D; 20 | 21 | public Polyline3D() : base() 22 | { 23 | this.Vertices.OnAdd += this.verticesOnAdd; 24 | } 25 | 26 | /// 27 | public override IEnumerable Explode() 28 | { 29 | return Polyline.explode(this); 30 | } 31 | 32 | private void verticesOnAdd(object sender, CollectionChangedEventArgs e) 33 | { 34 | if (e.Item is not Vertex3D) 35 | { 36 | this.Vertices.Remove((Vertex)e.Item); 37 | throw new ArgumentException($"Wrong vertex type for {DxfSubclassMarker.Polyline3d}"); 38 | } 39 | else if (e.Item is Vertex3D v && v.Bulge != 0) 40 | { 41 | throw new ArgumentException($"Bulge value cannot be different than 0 for a Vertex3D in a 3D Polyline"); 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /ACadSharp/Entities/PolylineFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.Entities 4 | { 5 | /// 6 | /// Defines the polyline flags. 7 | /// 8 | [Flags] 9 | public enum PolylineFlags 10 | { 11 | /// 12 | /// Default, open polyline. 13 | /// 14 | Default = 0, 15 | /// 16 | /// This is a closed polyline (or a polygon mesh closed in the M direction). 17 | /// 18 | ClosedPolylineOrClosedPolygonMeshInM = 1, 19 | /// 20 | /// Curve-fit vertexes have been added. 21 | /// 22 | CurveFit = 2, 23 | /// 24 | /// Spline-fit vertexes have been added. 25 | /// 26 | SplineFit = 4, 27 | /// 28 | /// This is a 3D polyline. 29 | /// 30 | Polyline3D = 8, 31 | /// 32 | /// This is a 3D polygon mesh. 33 | /// 34 | PolygonMesh = 16, 35 | /// 36 | /// The polygon mesh is closed in the N direction. 37 | /// 38 | ClosedPolygonMeshInN = 32, 39 | /// 40 | /// The polyline is a polyface mesh. 41 | /// 42 | PolyfaceMesh = 64, 43 | /// 44 | /// The line type pattern is generated continuously around the vertexes of this polyline. 45 | /// 46 | ContinuousLinetypePattern = 128 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /ACadSharp/Entities/Ray.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using CSMath; 3 | 4 | namespace ACadSharp.Entities 5 | { 6 | /// 7 | /// Represents a entity. 8 | /// 9 | /// 10 | /// Object name
11 | /// Dxf class name 12 | ///
13 | [DxfName(DxfFileToken.EntityRay)] 14 | [DxfSubClass(DxfSubclassMarker.Ray)] 15 | public class Ray : Entity 16 | { 17 | public override ObjectType ObjectType => ObjectType.RAY; 18 | public override string ObjectName => DxfFileToken.EntityRay; 19 | 20 | /// 21 | /// Start point(in WCS) 22 | /// 23 | [DxfCodeValue(10, 20, 30)] 24 | public XYZ StartPoint { get; set; } = XYZ.Zero; 25 | 26 | /// 27 | /// Unit direction vector(in WCS) 28 | /// 29 | [DxfCodeValue(11, 21, 31)] 30 | public XYZ Direction { get; set; } = XYZ.Zero; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ACadSharp/Entities/Seqend.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | 3 | namespace ACadSharp.Entities 4 | { 5 | /// 6 | /// Represents a entity 7 | /// 8 | /// 9 | /// Object name
10 | ///
11 | [DxfName(DxfFileToken.EntitySeqend)] 12 | public class Seqend : Entity 13 | { 14 | /// 15 | public override ObjectType ObjectType => ObjectType.SEQEND; 16 | 17 | /// 18 | public override string ObjectName => DxfFileToken.EntitySeqend; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ACadSharp/Entities/ShadowMode.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Entities 2 | { 3 | /// 4 | /// Starting with AutoCAD 2016-based products, this property is obsolete but still supported for backwards compatibility. 5 | /// 6 | public enum ShadowMode 7 | { 8 | CastsAndReceivesShadows = 0, 9 | CastsShadows = 1, 10 | ReceivesShadows = 2, 11 | IgnoresShadows = 3, 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /ACadSharp/Entities/SmoothSurfaceType.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Entities 2 | { 3 | /// 4 | /// Curves and smooth surface type. 5 | /// 6 | public enum SmoothSurfaceType : short 7 | { 8 | /// 9 | /// No smooth surface fitted. 10 | /// 11 | NoSmooth = 0, 12 | /// 13 | /// Quadratic B-spline curve. 14 | /// 15 | Quadratic = 5, 16 | /// 17 | /// Cubic B-spline curve. 18 | /// 19 | Cubic = 6, 20 | /// 21 | /// Bezier surface. 22 | /// 23 | BezierSurface = 8 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ACadSharp/Entities/Solid3D.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | 3 | namespace ACadSharp.Entities 4 | { 5 | /// 6 | /// Represents a entity. 7 | /// 8 | /// 9 | /// Object name
10 | /// Dxf class name 11 | ///
12 | [DxfName(DxfFileToken.Entity3DSolid)] 13 | [DxfSubClass(DxfSubclassMarker.ModelerGeometry)] 14 | public class Solid3D : Entity 15 | { 16 | /// 17 | public override ObjectType ObjectType => ObjectType.SOLID3D; 18 | 19 | /// 20 | public override string ObjectName => DxfFileToken.Entity3DSolid; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ACadSharp/Entities/SplineFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.Entities 4 | { 5 | /// 6 | /// Defines the spline flags 7 | /// 8 | [Flags] 9 | public enum SplineFlags : ushort 10 | { 11 | /// 12 | /// None 13 | /// 14 | None = 0, 15 | 16 | /// 17 | /// Closed 18 | /// 19 | Closed = 1, 20 | 21 | /// 22 | /// Periodic 23 | /// 24 | Periodic = 2, 25 | 26 | /// 27 | /// Rational 28 | /// 29 | Rational = 4, 30 | 31 | /// 32 | /// Planar 33 | /// 34 | Planar = 8, 35 | 36 | /// 37 | /// Linear (planar flag is also set) 38 | /// 39 | Linear = 16, 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ACadSharp/Entities/SplineFlags1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.Entities 4 | { 5 | /// 6 | /// Defines the spline flags 1 7 | /// 8 | [Flags] 9 | public enum SplineFlags1 : ushort 10 | { 11 | /// 12 | /// None 13 | /// 14 | None = 0, 15 | 16 | /// 17 | /// Method fit points 18 | /// 19 | MethodFitPoints = 1, 20 | 21 | /// 22 | /// CV frame show 23 | /// 24 | CVFrameShow = 2, 25 | 26 | /// 27 | /// Is closed 28 | /// 29 | IsClosed = 4, 30 | 31 | /// 32 | /// Use knot parameter 33 | /// 34 | UseKnotParameter = 8, 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ACadSharp/Entities/TextHorizontalAlignment.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Entities 2 | { 3 | public enum TextHorizontalAlignment : short 4 | { 5 | Left = 0, 6 | Center = 1, 7 | Right = 2, 8 | /// 9 | /// Aligned (if vertical alignment = 0) 10 | /// 11 | Aligned = 3, 12 | /// 13 | /// Middle (if vertical alignment = 0) 14 | /// 15 | Middle = 4, 16 | /// 17 | /// Fit (if vertical alignment = 0) 18 | /// 19 | Fit = 5, 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ACadSharp/Entities/TextMirrorFlag.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.Entities 4 | { 5 | [Flags] 6 | public enum TextMirrorFlag : short 7 | { 8 | None = 0, 9 | /// 10 | /// Mirrored in X 11 | /// 12 | Backward = 2, 13 | 14 | /// 15 | /// Mirrored in Y 16 | /// 17 | UpsideDown = 4, 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ACadSharp/Entities/TextVerticalAlignmentType.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Entities 2 | { 3 | /// 4 | /// Text vertical justification. 5 | /// 6 | public enum TextVerticalAlignmentType : short 7 | { 8 | /// 9 | /// Text aligned to baseline. 10 | /// 11 | Baseline = 0, 12 | 13 | /// 14 | /// Bottom 15 | /// 16 | Bottom = 1, 17 | 18 | /// 19 | /// Middle 20 | /// 21 | Middle = 2, 22 | 23 | /// 24 | /// Top 25 | /// 26 | Top = 3, 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ACadSharp/Entities/Vertex2D.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | 3 | namespace ACadSharp.Entities 4 | { 5 | /// 6 | /// Represents a entity 7 | /// 8 | /// 9 | /// Object name
10 | /// Dxf class name 11 | ///
12 | [DxfName(DxfFileToken.EntityVertex)] 13 | [DxfSubClass(DxfSubclassMarker.PolylineVertex)] 14 | public class Vertex2D : Vertex 15 | { 16 | public override ObjectType ObjectType => ObjectType.VERTEX_2D; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ACadSharp/Entities/Vertex3D.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | 3 | namespace ACadSharp.Entities 4 | { 5 | /// 6 | /// Represents a entity 7 | /// 8 | /// 9 | /// Object name
10 | /// Dxf class name 11 | ///
12 | [DxfName(DxfFileToken.EntityVertex)] 13 | [DxfSubClass(DxfSubclassMarker.Polyline3dVertex)] 14 | public class Vertex3D : Vertex 15 | { 16 | public override ObjectType ObjectType => ObjectType.VERTEX_3D; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ACadSharp/Entities/VertexFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.Entities 4 | { 5 | /// 6 | /// Defines the vertex flags. 7 | /// 8 | [Flags] 9 | public enum VertexFlags 10 | { 11 | /// 12 | /// Default. 13 | /// 14 | Default = 0, 15 | /// 16 | /// Extra vertex created by curve-fitting. 17 | /// 18 | CurveFittingExtraVertex = 1, 19 | /// 20 | /// Curve-fit tangent defined for this vertex. 21 | /// A curve-fit tangent direction of 0 may be omitted from DXF output but is significant if this bit is set. 22 | /// 23 | CurveFitTangent = 2, 24 | /// 25 | /// Not used. 26 | /// 27 | NotUsed = 4, 28 | /// 29 | /// Spline vertex created by spline-fitting. 30 | /// 31 | SplineVertexFromSplineFitting = 8, 32 | /// 33 | /// Spline frame control point. 34 | /// 35 | SplineFrameControlPoint = 16, 36 | /// 37 | /// 3D polyline vertex. 38 | /// 39 | PolylineVertex3D = 32, 40 | /// 41 | /// 3D polygon mesh. 42 | /// 43 | PolygonMesh3D = 64, 44 | /// 45 | /// Polyface mesh vertex. 46 | /// 47 | PolyfaceMeshVertex = 128 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ACadSharp/Entities/VerticalAlignmentType.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Entities 2 | { 3 | /// 4 | /// Text vertical justification. 5 | /// 6 | public enum VerticalAlignmentType : short 7 | { 8 | /// 9 | /// Top 10 | /// 11 | Top = 0, 12 | 13 | /// 14 | /// Middle 15 | /// 16 | Middle = 1, 17 | 18 | /// 19 | /// Bottom 20 | /// 21 | Bottom = 2, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ACadSharp/Entities/XLine.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using CSMath; 3 | 4 | namespace ACadSharp.Entities 5 | { 6 | /// 7 | /// Represents a entity. 8 | /// 9 | /// 10 | /// Object name
11 | /// Dxf class name 12 | ///
13 | [DxfName(DxfFileToken.EntityXline)] 14 | [DxfSubClass(DxfSubclassMarker.XLine)] 15 | public class XLine : Entity 16 | { 17 | /// 18 | public override ObjectType ObjectType => ObjectType.XLINE; 19 | 20 | /// 21 | public override string ObjectName => DxfFileToken.EntityXline; 22 | 23 | /// 24 | /// First point(in WCS) 25 | /// 26 | [DxfCodeValue(10, 20, 30)] 27 | public XYZ FirstPoint { get; set; } 28 | 29 | /// 30 | /// Unit direction vector(in WCS) 31 | /// 32 | [DxfCodeValue(11, 21, 31)] 33 | public XYZ Direction { get; set; } 34 | 35 | public XLine() : base() { } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ACadSharp/Exceptions/DwgException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.Exceptions 4 | { 5 | [Serializable] 6 | public class DwgException : Exception 7 | { 8 | public DwgException(string message) : base(message) { } 9 | 10 | public DwgException(string message, Exception inner) : base(message, inner) { } 11 | 12 | protected DwgException( 13 | System.Runtime.Serialization.SerializationInfo info, 14 | System.Runtime.Serialization.StreamingContext context) : base(info, context) { } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ACadSharp/Exceptions/DwgNotSupportedException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.Exceptions 4 | { 5 | [Serializable] 6 | public class DwgNotSupportedException : NotSupportedException 7 | { 8 | public DwgNotSupportedException() : base($"Dwg version not recognised") { } 9 | 10 | public DwgNotSupportedException(ACadVersion version) : base($"Dwg version not supported: {version}") { } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /ACadSharp/Exceptions/DxfException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace ACadSharp.Exceptions 6 | { 7 | [Serializable] 8 | public class DxfException : Exception 9 | { 10 | /// 11 | /// Invalid Dxf code 12 | /// 13 | /// 14 | /// 15 | public DxfException(int code, long line) : base($"Invalid dxf code with value {code}, at line {line}.") { } 16 | 17 | /// 18 | /// Generic exception 19 | /// 20 | /// 21 | /// 22 | public DxfException(string message, long line) : base($"{message}, at line {line}.") { } 23 | 24 | public DxfException(string message) : base(message) { } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ACadSharp/Header/DimensionAssociation.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Header 2 | { 3 | /// 4 | /// Controls the associativity of dimension objects. 5 | /// 6 | public enum DimensionAssociation : short 7 | { 8 | /// 9 | /// Creates exploded dimensions; there is no association between elements of the dimension, and the lines, arcs, arrowheads, and text of a dimension are drawn as separate objects 10 | /// 11 | CreateExplodedDimensions = 0, 12 | /// 13 | /// Creates non-associative dimension objects; the elements of the dimension are formed into a single object, and if the definition point on the object moves, then the dimension value is updated 14 | /// 15 | CreateNonAssociativeDimensions = 1, 16 | /// 17 | /// Creates associative dimension objects; the elements of the dimension are formed into a single object and one or more definition points of the dimension are coupled with association points on geometric objects 18 | /// 19 | CreateAssociativeDimensions = 2 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ACadSharp/Header/ObjectSortingFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.Header 4 | { 5 | /// 6 | /// Bitmask flags to set the various object sorting types defined in AutoCAD. 7 | /// 8 | [Flags] 9 | public enum ObjectSortingFlags : byte 10 | { 11 | /// 12 | /// Disables SORTENTS. 13 | /// 14 | Disabled = 0, 15 | /// 16 | /// Sorts for object selection. 17 | /// 18 | Selection = 1, 19 | /// 20 | /// Sorts for object snap. 21 | /// 22 | Snap = 2, 23 | /// 24 | /// Sorts for redraws. 25 | /// 26 | Redraw = 4, 27 | /// 28 | /// Sorts for MSLIDE command slide creation. 29 | /// 30 | Slide = 8, 31 | /// 32 | /// Sorts for REGEN commands. 33 | /// 34 | Regen = 16, // 0x10 35 | /// 36 | /// Sorts for plotting. 37 | /// 38 | Plotting = 32, // 0x20 39 | /// 40 | /// Sorts for PostScript output. 41 | /// 42 | Postscript = 64, // 0x40 43 | /// 44 | /// Enable all sorting methods. 45 | /// 46 | All = Postscript | Plotting | Regen | Slide | Redraw | Snap | Selection, // 0x7F 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /ACadSharp/Header/ShadeEdgeType.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Header 2 | { 3 | /// 4 | /// Edge shape type 5 | /// 6 | public enum ShadeEdgeType : short 7 | { 8 | /// 9 | /// Faces shaded, edges not highlighted 10 | /// 11 | FacesShadedEdgesNotHighlighted, 12 | /// 13 | /// Faces shaded, edges highlighted in black 14 | /// 15 | FacesShadedEdgesHighlightedInBlack, 16 | /// 17 | /// Faces not filled, edges in entity color 18 | /// 19 | FacesNotFilledEdgesInEntityColor, 20 | /// 21 | /// Faces in entity color, edges in black 22 | /// 23 | FacesInEntityColorEdgesInBlack, 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ACadSharp/Header/SpaceLineTypeScaling.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Header 2 | { 3 | /// 4 | /// Controls paper space linetype scaling. 5 | /// 6 | public enum SpaceLineTypeScaling : short 7 | { 8 | /// 9 | /// Viewport scaling governs linetype scaling. 10 | /// 11 | Viewport = 0, 12 | /// 13 | /// No special linetype scaling. 14 | /// 15 | Normal = 1, 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ACadSharp/Header/SplineType.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Header 2 | { 3 | /// 4 | /// Spline type 5 | /// 6 | public enum SplineType : short 7 | { 8 | /// 9 | /// None 10 | /// 11 | None = 0, 12 | /// 13 | /// Quadratic B spline 14 | /// 15 | QuadraticBSpline = 5, 16 | /// 17 | /// Cubic B Spline 18 | /// 19 | CubicBSpline = 6, 20 | /// 21 | /// Bezier curve 22 | /// 23 | Bezier = 8, 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ACadSharp/IClonable.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp 2 | { 3 | /// 4 | /// 5 | /// 6 | /// 7 | public interface ICloneable 8 | { 9 | T Clone(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /ACadSharp/IHandledCadObject.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp 2 | { 3 | /// 4 | /// Defines a CadObject with a unique handle 5 | /// 6 | public interface IHandledCadObject 7 | { 8 | /// 9 | /// Unique handle for this object 10 | /// 11 | ulong Handle { get; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ACadSharp/INamedCadObject.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp 2 | { 3 | /// 4 | /// Defines a CadObject with a unique name 5 | /// 6 | public interface INamedCadObject 7 | { 8 | /// 9 | /// Name identifier for this object 10 | /// 11 | string Name { get; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ACadSharp/IO/CadReaderBase.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Header; 2 | using CSUtilities.IO; 3 | using System; 4 | using System.IO; 5 | 6 | namespace ACadSharp.IO 7 | { 8 | public abstract class CadReaderBase : ICadReader 9 | { 10 | public event NotificationEventHandler OnNotification; 11 | 12 | internal readonly StreamIO _fileStream; 13 | 14 | protected CadReaderBase(NotificationEventHandler notification) 15 | { 16 | this.OnNotification += notification; 17 | } 18 | 19 | protected CadReaderBase(string filename, NotificationEventHandler notification = null) : this(notification) 20 | { 21 | this._fileStream = new StreamIO(filename, FileMode.Open, FileAccess.Read); 22 | } 23 | 24 | protected CadReaderBase(Stream stream, NotificationEventHandler notification = null) : this(notification) 25 | { 26 | this._fileStream = new StreamIO(stream); 27 | } 28 | 29 | /// 30 | public abstract CadDocument Read(); 31 | 32 | /// 33 | public abstract CadHeader ReadHeader(); 34 | 35 | /// 36 | public virtual void Dispose() 37 | { 38 | this._fileStream.Dispose(); 39 | } 40 | 41 | protected void triggerNotification(string message, NotificationType notificationType, Exception ex = null) 42 | { 43 | this.onNotificationEvent(null, new NotificationEventArgs(message, notificationType, ex)); 44 | } 45 | 46 | protected void onNotificationEvent(object sender, NotificationEventArgs e) 47 | { 48 | this.OnNotification?.Invoke(this, e); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /ACadSharp/IO/CadReaderConfiguration.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.IO 2 | { 3 | public abstract class CadReaderConfiguration 4 | { 5 | /// 6 | /// The reader will try to continue when an exception is thrown 7 | /// 8 | /// 9 | /// The result file may be incomplete or with some objects missing due the error 10 | /// 11 | public bool Failsafe { get; set; } = true; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ACadSharp/IO/CadWriterBase.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.IO 2 | { 3 | public abstract class CadWriterBase : ICadWriter 4 | { 5 | public event NotificationEventHandler OnNotification; 6 | 7 | /// 8 | /// Notifies the writer to close the stream once the operation is completed 9 | /// 10 | /// 11 | /// true 12 | /// 13 | public bool CloseStream { get; set; } = true; 14 | 15 | /// 16 | public abstract void Write(); 17 | 18 | /// 19 | public abstract void Dispose(); 20 | 21 | protected void validateDocument() 22 | { 23 | //TODO: Implement the document validation to check the structure 24 | } 25 | 26 | protected void triggerNotification(object sender, NotificationEventArgs e) 27 | { 28 | this.OnNotification?.Invoke(this, e); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/DwgCheckSumCalculator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.IO.DWG 4 | { 5 | internal class DwgCheckSumCalculator 6 | { 7 | public static readonly byte[] MagicSequence; 8 | 9 | static DwgCheckSumCalculator() 10 | { 11 | DwgCheckSumCalculator.MagicSequence = new byte[256]; 12 | int randSeed = 1; 13 | for (int i = 0; i < 256; i++) 14 | { 15 | randSeed *= 0x343FD; 16 | randSeed += 0x269EC3; 17 | DwgCheckSumCalculator.MagicSequence[i] = (byte)(randSeed >> 0x10); 18 | } 19 | } 20 | 21 | public static int CompressionCalculator(int length) 22 | { 23 | return 0x1F - (length + 0x20 - 1) % 0x20; 24 | } 25 | 26 | public static uint Calculate(uint seed, byte[] buffer, int offset, int size) 27 | { 28 | uint sum1 = seed & 0xFFFFu; 29 | uint sum2 = seed >> 16; 30 | int index = offset; 31 | while (size != 0) 32 | { 33 | int chunkSize = Math.Min(0x15B0, size); 34 | size -= chunkSize; 35 | 36 | for (int i = 0; i < chunkSize; i++) 37 | { 38 | sum1 += buffer[index]; 39 | sum2 += sum1; 40 | index++; 41 | } 42 | 43 | sum1 %= 0xFFF1; 44 | sum2 %= 0xFFF1; 45 | } 46 | return (sum2 << 0x10) | (sum1 & 0xFFFF); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/DwgReaderConfiguration.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.IO 2 | { 3 | public class DwgReaderConfiguration : CadReaderConfiguration 4 | { 5 | /// 6 | /// Use the Standard Cycling Redundancy Check to verify the integrity of the file. 7 | /// 8 | /// 9 | /// DWG file format uses a modification of a standard Cyclic Redundancy Check as an error detecting mechanism, 10 | /// if this flag is enabled the reader will perform this verification to detect any possible error, but it will greatly increase the reading time. 11 | /// 12 | public bool CrcCheck { get; set; } = false; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/DwgStreamReaders/DwgStreamReaderAC12.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace ACadSharp.IO.DWG 4 | { 5 | internal class DwgStreamReaderAC12 : DwgStreamReaderBase 6 | { 7 | public DwgStreamReaderAC12(Stream stream, bool resetPosition) : base(stream, resetPosition) { } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/DwgStreamReaders/DwgStreamReaderAC15.cs: -------------------------------------------------------------------------------- 1 | using CSMath; 2 | using System.IO; 3 | 4 | namespace ACadSharp.IO.DWG 5 | { 6 | internal class DwgStreamReaderAC15 : DwgStreamReaderAC12 7 | { 8 | public DwgStreamReaderAC15(Stream stream, bool resetPosition) : base(stream, resetPosition) { } 9 | 10 | public override XYZ ReadBitExtrusion() 11 | { 12 | //For R2000, this is a single bit, followed optionally by 3BD. 13 | //If the single bit is 1, 14 | //the extrusion value is assumed to be 0,0,1 and no explicit extrusion is stored. 15 | //If the single bit is 0, 16 | //then it will be followed by 3BD. 17 | return ReadBit() ? XYZ.AxisZ : Read3BitDouble(); 18 | } 19 | 20 | public override double ReadBitThickness() 21 | { 22 | //For R2000+, this is a single bit followed optionally by a BD. 23 | //If the bit is one, the thickness value is assumed to be 0.0. 24 | //If the bit is 0, then a BD that represents the thickness follows. 25 | return ReadBit() ? 0.0 : ReadBitDouble(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/DwgStreamReaders/DwgStreamReaderAC21.cs: -------------------------------------------------------------------------------- 1 | using CSUtilities.Converters; 2 | using System.IO; 3 | using System.Text; 4 | 5 | namespace ACadSharp.IO.DWG 6 | { 7 | internal class DwgStreamReaderAC21 : DwgStreamReaderAC18 8 | { 9 | public DwgStreamReaderAC21(Stream stream, bool resetPosition) : base(stream, resetPosition) { } 10 | 11 | public override string ReadTextUnicode() 12 | { 13 | short textLength = this.ReadShort(); 14 | string value; 15 | if (textLength == 0) 16 | { 17 | value = string.Empty; 18 | } 19 | else 20 | { 21 | //Correct the text length by shifting 1 bit 22 | short length = (short)(textLength << 1); 23 | //Read the string and get rid of the empty bytes 24 | value = this.ReadString(length, Encoding.Unicode).Replace("\0", ""); 25 | } 26 | return value; 27 | } 28 | 29 | public override string ReadVariableText() 30 | { 31 | int textLength = this.ReadBitShort(); 32 | string value; 33 | if (textLength == 0) 34 | { 35 | value = string.Empty; 36 | } 37 | else 38 | { 39 | //Correct the text length by shifting 1 bit 40 | short length = (short)(textLength << 1); 41 | //Read the string and get rid of the empty bytes 42 | value = this.ReadString(length, Encoding.Unicode).Replace("\0", ""); 43 | } 44 | return value; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/DwgStreamReaders/DwgStreamReaderAC24.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace ACadSharp.IO.DWG 4 | { 5 | internal class DwgStreamReaderAC24 : DwgStreamReaderAC21 6 | { 7 | public DwgStreamReaderAC24(Stream stream, bool resetPosition) : base(stream, resetPosition) { } 8 | 9 | public override ObjectType ReadObjectType() 10 | { 11 | //A bit pair, followed by either 1 or 2 bytes, depending on the bit pair value: 12 | byte pair = this.Read2Bits(); 13 | short value = 0; 14 | 15 | switch (pair) 16 | { 17 | //Read the following byte 18 | case 0: 19 | value = this.ReadByte(); 20 | break; 21 | //Read following byte and add 0x1f0. 22 | case 1: 23 | value = (short)(0x1F0 + this.ReadByte()); 24 | break; 25 | //Read the following two bytes (raw short) 26 | case 2: 27 | value = this.ReadShort(); 28 | break; 29 | //The value 3 should never occur, but interpret the same as 2 nevertheless. 30 | case 3: 31 | value = this.ReadShort(); 32 | break; 33 | } 34 | 35 | return (ObjectType)value; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/DwgStreamWriters/DwgAppInfodWriter.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Text; 3 | 4 | namespace ACadSharp.IO.DWG 5 | { 6 | internal class DwgAppInfoWriter : DwgSectionIO 7 | { 8 | public override string SectionName => DwgSectionDefinition.AppInfo; 9 | 10 | private IDwgStreamWriter writer; 11 | 12 | private byte[] _emptyArr = new byte[16]; 13 | 14 | public DwgAppInfoWriter(ACadVersion version, Stream stream) : base(version) 15 | { 16 | this.writer = DwgStreamWriterBase.GetStreamHandler(version, stream, Encoding.Unicode); 17 | } 18 | 19 | public void Write() 20 | { 21 | //UInt32 4 Unknown(ODA writes 2) 22 | writer.WriteInt(2); 23 | //String 2 + 2 * n + 2 App info name, ODA writes “AppInfoDataList” 24 | writer.WriteTextUnicode("AppInfoDataList"); 25 | //UInt32 4 Unknown(ODA writes 3) 26 | writer.WriteInt(3); 27 | //Byte[] 16 Version data(checksum, ODA writes zeroes) 28 | writer.WriteBytes(_emptyArr); 29 | //String 2 + 2 * n + 2 Version 30 | writer.WriteTextUnicode("_version_"); 31 | //Byte[] 16 Comment data(checksum, ODA writes zeroes) 32 | writer.WriteBytes(_emptyArr); 33 | //String 2 + 2 * n + 2 Comment 34 | writer.WriteTextUnicode("This is a comment from ACadSharp"); 35 | //Byte[] 16 Product data(checksum, ODA writes zeroes) 36 | writer.WriteBytes(_emptyArr); 37 | //String 2 + 2 * n + 2 Product 38 | writer.WriteTextUnicode(""); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/DwgStreamWriters/DwgFileHeaderWriterAC21.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace ACadSharp.IO.DWG 4 | { 5 | internal class DwgFileHeaderWriterAC21 : DwgFileHeaderWriterAC18 6 | { 7 | protected override int _fileHeaderSize { get { return 0x480; } } 8 | 9 | protected override ICompressor compressor => new DwgLZ77AC21Compressor(); 10 | 11 | public DwgFileHeaderWriterAC21(Stream stream, CadDocument model) : base(stream, model) 12 | { 13 | } 14 | 15 | protected override void craeteLocalSection(DwgSectionDescriptor descriptor, byte[] buffer, int decompressedSize, ulong offset, int totalSize, bool isCompressed) 16 | { 17 | MemoryStream descriptorStream = this.applyCompression(buffer, decompressedSize, offset, totalSize, isCompressed); 18 | 19 | this.writeMagicNumber(); 20 | 21 | //Implementation for the LZ77 compressor for AC1021 22 | //modify the localsection writer to match this specific version 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/DwgStreamWriters/DwgLZ77AC21Compressor.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace ACadSharp.IO.DWG 4 | { 5 | /// 6 | /// 7 | /// 8 | internal class DwgLZ77AC21Compressor : ICompressor 9 | { 10 | public void Compress(byte[] source, int offset, int totalSize, Stream dest) 11 | { 12 | throw new System.NotImplementedException(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/DwgStreamWriters/DwgPreviewWriter.cs: -------------------------------------------------------------------------------- 1 | using CSUtilities.IO; 2 | using CSUtilities.Text; 3 | using System.IO; 4 | using System.Text; 5 | 6 | namespace ACadSharp.IO.DWG 7 | { 8 | internal class DwgPreviewWriter : DwgSectionIO 9 | { 10 | public override string SectionName => DwgSectionDefinition.Preview; 11 | 12 | private IDwgStreamWriter _swriter; 13 | 14 | private readonly byte[] _startSentinel = new byte[16] 15 | { 16 | 0x1F,0x25,0x6D,0x07,0xD4,0x36,0x28,0x28,0x9D,0x57,0xCA,0x3F,0x9D,0x44,0x10,0x2B 17 | }; 18 | 19 | private readonly byte[] _endSentinel = new byte[16] 20 | { 21 | 0xE0, 0xDA, 0x92, 0xF8, 0x2B, 0xC9, 0xD7, 0xD7, 0x62, 0xA8, 0x35, 0xC0, 0x62, 0xBB, 0xEF, 0xD4 22 | }; 23 | 24 | public DwgPreviewWriter(ACadVersion version, Stream stream) : base(version) 25 | { 26 | this._swriter = DwgStreamWriterBase.GetStreamHandler(version, stream, TextEncoding.Windows1252()); 27 | } 28 | 29 | public void Write() 30 | { 31 | this._swriter.WriteBytes(_startSentinel); 32 | this._swriter.WriteRawLong(1); 33 | this._swriter.WriteByte(0); 34 | this._swriter.WriteBytes(_endSentinel); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/DwgStreamWriters/DwgStreamWriterAC12.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Text; 3 | 4 | namespace ACadSharp.IO.DWG 5 | { 6 | internal class DwgStreamWriterAC12 : DwgStreamWriterBase 7 | { 8 | public DwgStreamWriterAC12(Stream stream, Encoding encoding) : base(stream, encoding) 9 | { 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/DwgStreamWriters/DwgStreamWriterAC15.cs: -------------------------------------------------------------------------------- 1 | using CSMath; 2 | using System.IO; 3 | using System.Text; 4 | 5 | namespace ACadSharp.IO.DWG 6 | { 7 | internal class DwgStreamWriterAC15 : DwgStreamWriterAC12 8 | { 9 | public DwgStreamWriterAC15(Stream stream, Encoding encoding) : base(stream, encoding) 10 | { 11 | } 12 | 13 | public override void WriteBitExtrusion(XYZ normal) 14 | { 15 | //For R2000, this is a single bit, followed optionally by 3BD. 16 | if (normal == XYZ.AxisZ) 17 | { 18 | //If the single bit is 1, 19 | //the extrusion value is assumed to be 0,0,1 and no explicit extrusion is stored. 20 | base.WriteBit(value: true); 21 | return; 22 | } 23 | 24 | //If the single bit is 0, 25 | base.WriteBit(value: false); 26 | //then it will be followed by 3BD. 27 | base.Write3BitDouble(normal); 28 | } 29 | 30 | public override void WriteBitThickness(double thickness) 31 | { 32 | //For R2000+, this is a single bit followed optionally by a BD. 33 | //If the bit is one, the thickness value is assumed to be 0.0. 34 | //If the bit is 0, then a BD that represents the thickness follows. 35 | if (thickness == 0.0) 36 | { 37 | base.WriteBit(value: true); 38 | return; 39 | } 40 | 41 | base.WriteBit(value: false); 42 | base.WriteBitDouble(thickness); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/DwgStreamWriters/DwgStreamWriterAC18.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Text; 3 | 4 | namespace ACadSharp.IO.DWG 5 | { 6 | internal class DwgStreamWriterAC18 : DwgStreamWriterAC15 7 | { 8 | public DwgStreamWriterAC18(Stream stream, Encoding encoding) : base(stream, encoding) 9 | { 10 | } 11 | 12 | public override void WriteCmColor(Color value) 13 | { 14 | //TODO: Finish writer color implementation 15 | 16 | //CMC: 17 | //BS: color index(always 0) 18 | this.WriteBitShort(0); 19 | 20 | //BL: RGB value 21 | this.WriteBitLong(0); 22 | 23 | //RC: Color Byte 24 | this.WriteByte(0); 25 | 26 | //(&1 => color name follows(TV), 27 | //&2 => book name follows(TV)) 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/DwgStreamWriters/DwgStreamWriterAC21.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Text; 3 | 4 | namespace ACadSharp.IO.DWG 5 | { 6 | internal class DwgStreamWriterAC21 : DwgStreamWriterAC18 7 | { 8 | public DwgStreamWriterAC21(Stream stream, Encoding encoding) : base(stream, encoding) 9 | { 10 | } 11 | 12 | public override void WriteVariableText(string value) 13 | { 14 | if (string.IsNullOrEmpty(value)) 15 | { 16 | base.WriteBitShort(0); 17 | return; 18 | } 19 | base.WriteBitShort((short)value.Length); 20 | base.WriteBytes(Encoding.Unicode.GetBytes(value)); 21 | } 22 | 23 | public override void WriteTextUnicode(string value) 24 | { 25 | this.WriteRawShort((short)(value.Length + 1)); 26 | byte[] bytes = Encoding.Unicode.GetBytes(value); 27 | 28 | this.WriteBytes(bytes); 29 | base.Stream.WriteByte(0); 30 | base.Stream.WriteByte(0); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/DwgStreamWriters/DwgStreamWriterAC24.cs: -------------------------------------------------------------------------------- 1 | using CSUtilities.Converters; 2 | using System.IO; 3 | using System.Text; 4 | 5 | namespace ACadSharp.IO.DWG 6 | { 7 | internal class DwgStreamWriterAC24 : DwgStreamWriterAC21 8 | { 9 | public DwgStreamWriterAC24(Stream stream, Encoding encoding) : base(stream, encoding) 10 | { 11 | } 12 | 13 | public override void WriteObjectType(ObjectType value) 14 | { 15 | //A bit pair, followed by either 1 or 2 bytes 16 | //Amount of bytes depens on the value 17 | if ((short)value <= 255) 18 | { 19 | //Read the following byte 20 | this.Write2Bits(0); 21 | this.WriteByte((byte)value); 22 | } 23 | else if ((short)value >= 0x1F0 && (short)value <= 0x2EF) 24 | { 25 | //Read following byte and add 0x1f0. 26 | this.Write2Bits(1); 27 | this.WriteByte((byte)(value - 0x1F0)); 28 | } 29 | else 30 | { 31 | //Read the following two bytes (raw short) 32 | this.Write2Bits(2); 33 | this.WriteBytes(LittleEndianConverter.Instance.GetBytes((short)value)); 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/DwgStreamWriters/DwgmMergedStreamWriterAC14.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace ACadSharp.IO.DWG 4 | { 5 | internal class DwgmMergedStreamWriterAC14 : DwgmMergedStreamWriter, IDwgStreamWriter 6 | { 7 | public DwgmMergedStreamWriterAC14(Stream stream, IDwgStreamWriter main, IDwgStreamWriter handle) 8 | : base(stream, main, main, handle) 9 | { 10 | } 11 | 12 | public override void WriteSpearShift() 13 | { 14 | int pos = (int)this.Main.PositionInBits; 15 | 16 | if (this._savedPosition) 17 | { 18 | this.Main.WriteSpearShift(); 19 | this.Main.SetPositionInBits(this.PositionInBits); 20 | this.Main.WriteRawLong(pos); 21 | this.Main.WriteShiftValue(); 22 | this.Main.SetPositionInBits(pos); 23 | } 24 | 25 | this.HandleWriter.WriteSpearShift(); 26 | this.Main.WriteBytes(((MemoryStream)this.HandleWriter.Stream).GetBuffer()); 27 | this.Main.WriteSpearShift(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/DwgStreamWriters/ICompressor.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace ACadSharp.IO.DWG 4 | { 5 | internal interface ICompressor 6 | { 7 | void Compress(byte[] source, int offset, int totalSize, Stream dest); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/DwgStreamWriters/IDwgFileHeaderWriter.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.IO.DWG 2 | { 3 | internal interface IDwgFileHeaderWriter 4 | { 5 | int HandleSectionOffset { get; } 6 | 7 | void AddSection(string name, System.IO.MemoryStream stream, bool isCompressed, int decompsize = 0x7400); 8 | 9 | void WriteFile(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/FileHeaders/DwgFileHeaderAC15.cs: -------------------------------------------------------------------------------- 1 | using CSUtilities.Text; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace ACadSharp.IO.DWG 6 | { 7 | internal class DwgFileHeaderAC15 : DwgFileHeader 8 | { 9 | public static readonly byte[] EndSentinel = new byte[16] { 0x95, 0xA0, 0x4E, 0x28, 0x99, 0x82, 0x1A, 0xE5, 0x5E, 0x41, 0xE0, 0x5F, 0x9D, 0x3A, 0x4D, 0x00 }; 10 | 11 | public CodePage DrawingCodePage { get; set; } 12 | 13 | public Dictionary Records { get; set; } = new Dictionary(); 14 | 15 | public DwgFileHeaderAC15() : base() { } 16 | 17 | public DwgFileHeaderAC15(ACadVersion version) : base(version) { } 18 | 19 | public override void AddSection(string name) 20 | { 21 | throw new NotImplementedException(); 22 | } 23 | 24 | public override DwgSectionDescriptor GetDescriptor(string name) 25 | { 26 | throw new NotImplementedException(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/FileHeaders/DwgFileHeaderAC21.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.IO.DWG 2 | { 3 | internal class DwgFileHeaderAC21 : DwgFileHeaderAC18 4 | { 5 | public Dwg21CompressedMetadata CompressedMetadata { get; set; } 6 | 7 | public DwgFileHeaderAC21() : base() { } 8 | 9 | public DwgFileHeaderAC21(ACadVersion version) : base(version) { } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/FileHeaders/DwgLocalSectionMap.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.IO.DWG 2 | { 3 | public class DwgLocalSectionMap 4 | { 5 | public int Compression { get; set; } = 2; 6 | 7 | public bool IsEmpty { get; internal set; } 8 | 9 | public ulong Offset { get; internal set; } 10 | 11 | public ulong CompressedSize { get; internal set; } 12 | 13 | public int PageNumber { get; internal set; } 14 | 15 | public ulong DecompressedSize { get; internal set; } 16 | 17 | public long Seeker { get; internal set; } 18 | 19 | public long Size { get; internal set; } 20 | 21 | public ulong Checksum { get; internal set; } 22 | 23 | public ulong CRC { get; internal set; } 24 | 25 | public long PageSize { get; internal set; } 26 | 27 | public uint ODA { get; internal set; } 28 | 29 | public int SectionMap { get; set; } 30 | 31 | public DwgLocalSectionMap() { } 32 | 33 | public DwgLocalSectionMap(int value) 34 | { 35 | this.SectionMap = value; 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/FileHeaders/DwgSectionDescriptor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace ACadSharp.IO.DWG 5 | { 6 | internal class DwgSectionDescriptor 7 | { 8 | public long PageType { get; } = 0x4163043B; 9 | 10 | public string Name { get; set; } 11 | 12 | public ulong CompressedSize { get; set; } 13 | 14 | public int PageCount { get; set; } 15 | 16 | public ulong DecompressedSize { get; set; } = 0x7400; 17 | 18 | /// 19 | /// Is only used for the version and or above. 20 | /// 21 | public int CompressedCode 22 | { 23 | get => this._compressed; 24 | set => this._compressed = value == 1 || value == 2 ? value : 25 | throw new Exception(); 26 | } 27 | 28 | private int _compressed = 2; 29 | 30 | /// 31 | /// Is only used for the version and or above. 32 | /// 33 | public bool IsCompressed { get { return this._compressed == 2; } } 34 | 35 | public int SectionId { get; set; } 36 | 37 | public int Encrypted { get; set; } 38 | 39 | public ulong? HashCode { get; internal set; } 40 | 41 | public ulong? Encoding { get; internal set; } 42 | 43 | public List LocalSections { get; set; } = new List(); 44 | 45 | public DwgSectionDescriptor() { } 46 | 47 | public DwgSectionDescriptor(string name) 48 | { 49 | this.Name = name; 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/FileHeaders/DwgSectionHash.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.IO.DWG 2 | { 3 | internal enum DwgSectionHash 4 | { 5 | AcDb_Unknown = 0x00000000, 6 | AcDb_Security = 0x4a0204ea, 7 | AcDb_FileDepList = 0x6c4205ca, 8 | AcDb_VBAProject = 0x586e0544, 9 | AcDb_AppInfo = 0x3fa0043e, 10 | AcDb_Preview = 0x40aa0473, 11 | AcDb_SummaryInfo = 0x717a060f, 12 | AcDb_RevHistory = 0x60a205b3, 13 | AcDb_AcDbObjects = 0x674c05a9, 14 | AcDb_ObjFreeSpace = 0x77e2061f, 15 | AcDb_Template = 0x4a1404ce, 16 | AcDb_Handles = 0x3f6e0450, 17 | AcDb_Classes = 0x3f54045f, 18 | AcDb_AuxHeader = 0x54f0050a, 19 | AcDb_Header = 0x32b803d9, 20 | AcDb_Signature = -0x00000001, 21 | } 22 | } -------------------------------------------------------------------------------- /ACadSharp/IO/DWG/FileHeaders/DwgSectionLocatorRecord.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace ACadSharp.IO.DWG 4 | { 5 | internal class DwgSectionLocatorRecord 6 | { 7 | /// 8 | /// Number of the record or id. 9 | /// 10 | public int? Number { get; set; } 11 | 12 | /// 13 | /// Offset where the record is. 14 | /// 15 | public long Seeker { get; set; } 16 | 17 | /// 18 | /// Size in bytes of this record. 19 | /// 20 | public long Size { get; set; } 21 | 22 | public DwgSectionLocatorRecord() { } 23 | 24 | public DwgSectionLocatorRecord(int? number) 25 | { 26 | this.Number = number; 27 | } 28 | 29 | public DwgSectionLocatorRecord(int? number, int seeker, int size) 30 | { 31 | this.Number = number; 32 | this.Seeker = seeker; 33 | this.Size = size; 34 | } 35 | 36 | /// 37 | /// Check if the position is in the record. 38 | /// 39 | /// 40 | /// 41 | public bool IsInTheRecord(int position) 42 | { 43 | return position >= this.Seeker && position < this.Seeker + this.Size; 44 | } 45 | 46 | public override string ToString() 47 | { 48 | return $"Number : {this.Number} | Seeker : {this.Seeker} | Size : {this.Size}"; 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /ACadSharp/IO/DXF/CadObjectHolder.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Entities; 2 | using System.Collections.Generic; 3 | 4 | namespace ACadSharp.IO 5 | { 6 | internal class CadObjectHolder 7 | { 8 | public Queue Entities { get; } = new Queue(); 9 | 10 | public Queue Objects { get; } = new Queue(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /ACadSharp/IO/DXF/DxfReaderConfiguration.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.IO 2 | { 3 | public class DxfReaderConfiguration : CadReaderConfiguration 4 | { 5 | /// 6 | /// Clears the cache after the reading 7 | /// 8 | public bool ClearChache { get; set; } = true; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ACadSharp/IO/DXF/DxfStreamReader/DxfEntitiesSectionReader.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.IO.Templates; 2 | using System; 3 | 4 | namespace ACadSharp.IO.DXF 5 | { 6 | internal class DxfEntitiesSectionReader : DxfSectionReaderBase 7 | { 8 | public DxfEntitiesSectionReader(IDxfStreamReader reader, DxfDocumentBuilder builder) 9 | : base(reader, builder) 10 | { 11 | } 12 | 13 | public override void Read() 14 | { 15 | //Advance to the first value in the section 16 | this._reader.ReadNext(); 17 | 18 | //Loop until the section ends 19 | while (this._reader.LastValueAsString != DxfFileToken.EndSection) 20 | { 21 | CadEntityTemplate template = null; 22 | 23 | try 24 | { 25 | template = this.readEntity(); 26 | } 27 | catch (Exception) 28 | { 29 | if (!this._builder.Configuration.Failsafe) 30 | throw; 31 | 32 | while (this._reader.LastDxfCode != DxfCode.Start) 33 | this._reader.ReadNext(); 34 | } 35 | 36 | if (template == null) 37 | continue; 38 | 39 | //Add the object and the template to the builder 40 | this._builder.AddTemplate(template); 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /ACadSharp/IO/DXF/DxfStreamReader/IDxfStreamReader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace ACadSharp.IO.DXF 6 | { 7 | internal interface IDxfStreamReader 8 | { 9 | DxfCode LastDxfCode { get; } 10 | 11 | GroupCodeValueType LastGroupCodeValue { get; } 12 | 13 | int LastCode { get; } 14 | 15 | object LastValue { get; } 16 | 17 | /// 18 | /// Current line or offset in the file 19 | /// 20 | int Position { get; } 21 | 22 | /// 23 | /// Last value read in the dxf file without any transformation 24 | /// 25 | string LastValueAsString { get; } 26 | 27 | bool LastValueAsBool { get; } 28 | 29 | ushort LastValueAsShort { get; } 30 | 31 | int LastValueAsInt { get; } 32 | 33 | long LastValueAsLong { get; } 34 | 35 | double LastValueAsDouble { get; } 36 | 37 | ulong LastValueAsHandle { get; } 38 | 39 | byte[] LastValueAsBinaryChunk { get; } 40 | 41 | /// 42 | /// Find a dxf entry in the file. 43 | /// 44 | /// 45 | void Find(string dxfEntry); 46 | 47 | void ReadNext(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ACadSharp/IO/DXF/DxfStreamWriter/DxfClassesSectionWriter.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.IO.DXF 2 | { 3 | internal class DxfClassesSectionWriter : DxfSectionWriterBase 4 | { 5 | public override string SectionName { get { return DxfFileToken.ClassesSection; } } 6 | 7 | public DxfClassesSectionWriter(IDxfStreamWriter writer, CadDocument document, CadObjectHolder holder) : base(writer, document, holder) 8 | { 9 | } 10 | 11 | protected override void writeSection() 12 | { 13 | foreach (Classes.DxfClass c in this._document.Classes) 14 | { 15 | this._writer.Write(0, DxfFileToken.ClassEntry); 16 | this._writer.Write(1, c.DxfName); 17 | this._writer.Write(2, c.CppClassName); 18 | this._writer.Write(3, c.ApplicationName); 19 | this._writer.Write(90, (int)c.ProxyFlags); 20 | this._writer.Write(91, c.InstanceCount); 21 | this._writer.Write(280, c.WasZombie); 22 | this._writer.Write(281, c.IsAnEntity); 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ACadSharp/IO/DXF/DxfStreamWriter/DxfEntitiesSectionWriter.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Entities; 2 | using System.Linq; 3 | 4 | namespace ACadSharp.IO.DXF 5 | { 6 | internal class DxfEntitiesSectionWriter : DxfSectionWriterBase 7 | { 8 | public override string SectionName { get { return DxfFileToken.EntitiesSection; } } 9 | 10 | public DxfEntitiesSectionWriter(IDxfStreamWriter writer, CadDocument document, CadObjectHolder holder) : base(writer, document, holder) 11 | { 12 | } 13 | 14 | protected override void writeSection() 15 | { 16 | while (this.Holder.Entities.Any()) 17 | { 18 | Entity item = this.Holder.Entities.Dequeue(); 19 | 20 | this.writeMappedObject(item); 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ACadSharp/IO/DXF/DxfStreamWriter/DxfHeaderSectionWriter.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace ACadSharp.IO.DXF 4 | { 5 | internal class DxfHeaderSectionWriter : DxfSectionWriterBase 6 | { 7 | public override string SectionName { get { return DxfFileToken.HeaderSection; } } 8 | 9 | public DxfHeaderSectionWriter(IDxfStreamWriter writer, CadDocument document, CadObjectHolder holder) : base(writer, document, holder) 10 | { 11 | } 12 | 13 | protected override void writeSection() 14 | { 15 | Dictionary map = Header.CadHeader.GetHeaderMap(); 16 | 17 | foreach (KeyValuePair item in map) 18 | { 19 | if (item.Value.ReferenceType.HasFlag(DxfReferenceType.Ignored)) 20 | continue; 21 | 22 | this._writer.Write(DxfCode.CLShapeText, item.Key); 23 | 24 | if (item.Key == "$HANDSEED") //Not very elegant but by now... 25 | { 26 | this._writer.Write(DxfCode.Handle, this._document.Header.HandleSeed); 27 | continue; 28 | } 29 | 30 | foreach (var csv in item.Value.DxfCodes) 31 | { 32 | object value = item.Value.GetValue(csv, this._document.Header); 33 | 34 | if (value == null) 35 | continue; 36 | 37 | this._writer.Write((DxfCode)csv, value); 38 | } 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ACadSharp/IO/DXF/DxfStreamWriter/IDxfStreamWriter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace ACadSharp.IO.DXF 5 | { 6 | internal interface IDxfStreamWriter : IDisposable 7 | { 8 | void Write(DxfCode code, object value); 9 | 10 | void Write(int code, object value); 11 | 12 | void Flush(); 13 | 14 | void Close(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ACadSharp/IO/ICadReader.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Header; 2 | using CSUtilities.IO; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace ACadSharp.IO 10 | { 11 | public interface ICadReader : IDisposable 12 | { 13 | /// 14 | /// Read the Cad header section of the file 15 | /// 16 | CadHeader ReadHeader(); 17 | 18 | /// 19 | /// Read the cad document 20 | /// 21 | CadDocument Read(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ACadSharp/IO/ICadWriter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.IO 4 | { 5 | public interface ICadWriter : IDisposable 6 | { 7 | /// 8 | /// Write the 9 | /// 10 | void Write(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /ACadSharp/IO/NotificationEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace ACadSharp.IO 6 | { 7 | public delegate void NotificationEventHandler(object sender, NotificationEventArgs e); 8 | 9 | public enum NotificationType 10 | { 11 | NotImplemented = -1, 12 | None = 0, 13 | NotSupported = 1, 14 | Warning = 2, 15 | Error = 3, 16 | } 17 | 18 | public class NotificationEventArgs : EventArgs 19 | { 20 | public string Message { get; } 21 | 22 | public NotificationType NotificationType { get; } 23 | 24 | public Exception Exception { get; } 25 | 26 | public NotificationEventArgs(string message, NotificationType notificationType = NotificationType.None, Exception exception = null) 27 | { 28 | this.Message = message; 29 | this.NotificationType = notificationType; 30 | this.Exception = exception; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ACadSharp/IO/Templates/CadArcTemplate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using ACadSharp.Entities; 3 | using ACadSharp.IO.DXF; 4 | using ACadSharp.Tables; 5 | 6 | namespace ACadSharp.IO.Templates 7 | { 8 | internal class CadArcTemplate : CadEntityTemplate 9 | { 10 | 11 | public CadArcTemplate(Entity entity) : base(entity) { } 12 | 13 | 14 | public override void Build(CadDocumentBuilder builder) 15 | { 16 | base.Build(builder); 17 | 18 | if (builder is DxfDocumentBuilder && this.CadObject is Arc arc) 19 | { 20 | arc.StartAngle *= MathUtils.DegToRad; 21 | arc.EndAngle *= MathUtils.DegToRad; 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ACadSharp/IO/Templates/CadBlockCtrlObjectTemplate.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Tables; 2 | using ACadSharp.Tables.Collections; 3 | 4 | namespace ACadSharp.IO.Templates 5 | { 6 | internal class CadBlockCtrlObjectTemplate : CadTableTemplate 7 | { 8 | public ulong? ModelSpaceHandle { get; set; } 9 | 10 | public ulong? PaperSpaceHandle { get; set; } 11 | 12 | public CadBlockCtrlObjectTemplate(BlockRecordsTable blocks) : base(blocks) { } 13 | 14 | public override void Build(CadDocumentBuilder builder) 15 | { 16 | base.Build(builder); 17 | 18 | if (builder.TryGetCadObject(this.ModelSpaceHandle, out BlockRecord modelSpace)) 19 | { 20 | this.CadObject.Add(modelSpace); 21 | } 22 | 23 | if (builder.TryGetCadObject(this.PaperSpaceHandle, out BlockRecord paperSpace)) 24 | { 25 | this.CadObject.Add(paperSpace); 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ACadSharp/IO/Templates/CadDictionaryTemplate.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Objects; 2 | using System.Collections.Generic; 3 | 4 | namespace ACadSharp.IO.Templates 5 | { 6 | internal class CadDictionaryTemplate : CadTemplate 7 | { 8 | public Dictionary Entries { get; set; } = new Dictionary(); 9 | 10 | public CadDictionaryTemplate(CadDictionary dictionary) : base(dictionary) { } 11 | 12 | public override void Build(CadDocumentBuilder builder) 13 | { 14 | base.Build(builder); 15 | 16 | if (this.OwnerHandle.HasValue && this.OwnerHandle == 0) 17 | { 18 | builder.DocumentToBuild.RootDictionary = this.CadObject; 19 | } 20 | 21 | foreach (var item in this.Entries) 22 | { 23 | if (builder.TryGetCadObject(item.Value, out CadObject entry)) 24 | { 25 | this.CadObject.Add(item.Key, entry); 26 | } 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ACadSharp/IO/Templates/CadHatchTemplate.CadBoundaryPathTemplate.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Entities; 2 | using System.Collections.Generic; 3 | 4 | namespace ACadSharp.IO.Templates 5 | { 6 | internal partial class CadHatchTemplate 7 | { 8 | public class CadBoundaryPathTemplate : ICadObjectTemplate 9 | { 10 | public Hatch.BoundaryPath Path { get; set; } = new Hatch.BoundaryPath(); 11 | 12 | public List Handles { get; set; } = new List(); 13 | 14 | public CadBoundaryPathTemplate() { } 15 | 16 | public void Build(CadDocumentBuilder builder) 17 | { 18 | foreach (var handle in this.Handles) 19 | { 20 | if (builder.TryGetCadObject(handle, out Entity entity)) 21 | { 22 | this.Path.Entities.Add(entity); 23 | } 24 | } 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ACadSharp/IO/Templates/CadHatchTemplate.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Entities; 2 | using ACadSharp.IO.DWG; 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | namespace ACadSharp.IO.Templates 7 | { 8 | internal partial class CadHatchTemplate : CadEntityTemplate 9 | { 10 | public string HatchPatternName { get; set; } 11 | 12 | public List PathTempaltes = new List(); 13 | 14 | public CadHatchTemplate(Hatch hatch) : base(hatch) { } 15 | 16 | public override void Build(CadDocumentBuilder builder) 17 | { 18 | base.Build(builder); 19 | 20 | //TODO: Finish the hatch template 21 | Hatch hatch = CadObject as Hatch; 22 | 23 | if (!string.IsNullOrEmpty(this.HatchPatternName)) 24 | { 25 | 26 | } 27 | 28 | foreach (CadBoundaryPathTemplate t in PathTempaltes) 29 | { 30 | (this.CadObject as Hatch).Paths.Add(t.Path); 31 | t.Build(builder); 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ACadSharp/IO/Templates/CadLeaderTemplate.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Entities; 2 | 3 | namespace ACadSharp.IO.Templates 4 | { 5 | internal class CadLeaderTemplate : CadEntityTemplate 6 | { 7 | public CadLeaderTemplate(Leader entity) : base(entity) { } 8 | 9 | public double Dimasz { get; internal set; } 10 | public ulong DIMSTYLEHandle { get; internal set; } 11 | public ulong AnnotationHandle { get; internal set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ACadSharp/IO/Templates/CadLwPolylineTemplate.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Entities; 2 | using CSMath; 3 | using System.Linq; 4 | 5 | namespace ACadSharp.IO.Templates 6 | { 7 | internal class CadLwPolylineTemplate : CadEntityTemplate 8 | { 9 | public CadLwPolylineTemplate() : base(new LwPolyline()) { } 10 | 11 | public override bool CheckDxfCode(int dxfcode, object value) 12 | { 13 | bool found = base.CheckDxfCode(dxfcode, value); 14 | if (found) 15 | return found; 16 | 17 | LwPolyline lw = this.CadObject as LwPolyline; 18 | 19 | LwPolyline.Vertex last = lw.Vertices.LastOrDefault(); 20 | 21 | switch (dxfcode) 22 | { 23 | case 10: 24 | lw.Vertices.Add(new LwPolyline.Vertex(new CSMath.XY((double)value, 0))); 25 | return true; 26 | case 20: 27 | if (last is not null) 28 | { 29 | last.Location = new CSMath.XY(last.Location.X, (double)value); 30 | } 31 | return true; 32 | case 40: 33 | if (last is not null) 34 | { 35 | last.StartWidth = (double)value; 36 | } 37 | return true; 38 | case 41: 39 | if (last is not null) 40 | { 41 | last.EndWidth = (double)value; 42 | } 43 | return true; 44 | case 42: 45 | if (last is not null) 46 | { 47 | last.Bulge = (double)value; 48 | } 49 | return true; 50 | } 51 | 52 | return found; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /ACadSharp/IO/Templates/CadShapeTemplate.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Entities; 2 | 3 | namespace ACadSharp.IO.Templates 4 | { 5 | internal class CadShapeTemplate : CadEntityTemplate 6 | { 7 | public ushort? ShapeIndex { get; set; } 8 | public ulong? ShapeFileHandle { get; set; } 9 | 10 | public CadShapeTemplate(Shape shape) : base(shape) { } 11 | 12 | public override void Build(CadDocumentBuilder builder) 13 | { 14 | base.Build(builder); 15 | 16 | //TODO: Finish shape template 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ACadSharp/IO/Templates/CadTableEntryTemplate.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.IO.DWG; 2 | using ACadSharp.Tables; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace ACadSharp.IO.Templates 8 | { 9 | internal class CadTableEntryTemplate : CadTemplate 10 | where T : TableEntry 11 | { 12 | public CadTableEntryTemplate(T entry) : base(entry) { } 13 | 14 | public override void Build(CadDocumentBuilder builder) 15 | { 16 | base.Build(builder); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ACadSharp/IO/Templates/CadTableTemplate.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Tables; 2 | using ACadSharp.Tables.Collections; 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | namespace ACadSharp.IO.Templates 7 | { 8 | internal class CadTableTemplate : CadTemplate>, ICadTableTemplate 9 | where T : TableEntry 10 | { 11 | public List EntryHandles { get; } = new List(); 12 | 13 | public CadTableTemplate(Table tableControl) : base(tableControl) { } 14 | 15 | public override void Build(CadDocumentBuilder builder) 16 | { 17 | base.Build(builder); 18 | 19 | foreach (ulong handle in this.EntryHandles) 20 | { 21 | if (!builder.TryGetCadObject(handle, out T entry)) 22 | continue; 23 | 24 | try 25 | { 26 | this.CadObject.Add(entry); 27 | } 28 | catch (ArgumentException ex) 29 | { 30 | builder.Notify(new NotificationEventArgs(ex.Message)); 31 | } 32 | catch (Exception) 33 | { 34 | builder.Notify(new NotificationEventArgs($"Error adding the entry [handle : {handle}] [type : {typeof(T)}]")); 35 | } 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ACadSharp/IO/Templates/CadTemplate[T].cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.IO.Templates 2 | { 3 | internal class CadTemplate : CadTemplate 4 | where T : CadObject 5 | { 6 | public new T CadObject { get { return (T)base.CadObject; } set { base.CadObject = value; } } 7 | 8 | public CadTemplate(T cadObject) : base(cadObject) { } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ACadSharp/IO/Templates/CadTextEntityTemplate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using ACadSharp.Entities; 3 | using ACadSharp.IO.DXF; 4 | using ACadSharp.Tables; 5 | 6 | namespace ACadSharp.IO.Templates 7 | { 8 | internal class CadTextEntityTemplate : CadEntityTemplate 9 | { 10 | public ulong StyleHandle { get; set; } 11 | 12 | public CadTextEntityTemplate(Entity entity) : base(entity) { } 13 | 14 | public override bool CheckDxfCode(int dxfcode, object value) 15 | { 16 | switch (dxfcode) 17 | { 18 | //Multiple options 19 | case 280: 20 | //return true; 21 | default: 22 | return false; 23 | } 24 | } 25 | 26 | public override void Build(CadDocumentBuilder builder) 27 | { 28 | base.Build(builder); 29 | 30 | switch (this.CadObject) 31 | { 32 | case TextEntity text: 33 | text.Style = builder.GetCadObject(this.StyleHandle); 34 | 35 | // When the rotation is read in a DXF, the value is in decimal, but when the value 36 | // is read in a DWG, it is in radians. Convert only on DXFs. Issue #80 37 | if (builder is DxfDocumentBuilder) 38 | text.Rotation *= MathUtils.DegToRad; 39 | 40 | break; 41 | case MText mtext: 42 | mtext.Style = builder.GetCadObject(this.StyleHandle); 43 | break; 44 | default: 45 | throw new System.ArgumentException("Unknown type"); 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ACadSharp/IO/Templates/CadUcsTemplate.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Tables; 2 | 3 | namespace ACadSharp.IO.Templates 4 | { 5 | internal class CadUcsTemplate : CadTableEntryTemplate 6 | { 7 | public CadUcsTemplate(UCS entry) : base(entry) { } 8 | 9 | public override bool CheckDxfCode(int dxfcode, object value) 10 | { 11 | bool found = base.CheckDxfCode(dxfcode, value); 12 | if (found) 13 | return true; 14 | 15 | switch (dxfcode) 16 | { 17 | //NOTE: Undocumented code 18 | case 79: 19 | found = true; 20 | break; 21 | default: 22 | break; 23 | } 24 | 25 | return found; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ACadSharp/IO/Templates/CadVertexTemplate.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Entities; 2 | 3 | namespace ACadSharp.IO.Templates 4 | { 5 | internal class CadVertexTemplate : CadEntityTemplate 6 | { 7 | public CadVertexTemplate() : base(new VertexPlaceholder()) 8 | { 9 | } 10 | 11 | internal void SetVertexObject(Vertex vertex) 12 | { 13 | vertex.Handle = this.CadObject.Handle; 14 | vertex.Owner = this.CadObject.Owner; 15 | 16 | vertex.XDictionary = this.CadObject.XDictionary; 17 | 18 | //polyLine.Reactors = this.CadObject.Reactors; 19 | //polyLine.ExtendedData = this.CadObject.ExtendedData; 20 | 21 | vertex.Color = this.CadObject.Color; 22 | vertex.LineWeight = this.CadObject.LineWeight; 23 | vertex.LinetypeScale = this.CadObject.LinetypeScale; 24 | vertex.IsInvisible = this.CadObject.IsInvisible; 25 | vertex.Transparency = this.CadObject.Transparency; 26 | 27 | VertexPlaceholder placeholder = this.CadObject as VertexPlaceholder; 28 | 29 | vertex.Location = placeholder.Location; 30 | vertex.StartWidth = placeholder.StartWidth; 31 | vertex.EndWidth = placeholder.EndWidth; 32 | vertex.Bulge = placeholder.Bulge; 33 | vertex.Flags = placeholder.Flags; 34 | vertex.CurveTangent = placeholder.CurveTangent; 35 | vertex.Id = placeholder.Id; 36 | 37 | this.CadObject = vertex; 38 | } 39 | 40 | public class VertexPlaceholder : Vertex 41 | { 42 | public override ObjectType ObjectType { get { return ObjectType.INVALID; } } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /ACadSharp/IO/Templates/CadViewTemplate.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Tables; 2 | 3 | namespace ACadSharp.IO.Templates 4 | { 5 | internal class CadViewTemplate : CadTableEntryTemplate 6 | { 7 | public ulong? VisualStyleHandle { get; set; } 8 | 9 | public ulong? NamedUcsHandle { get; set; } 10 | 11 | public ulong? UcsHandle { get; set; } 12 | 13 | public CadViewTemplate(View entry) : base(entry) { } 14 | 15 | public override bool AddHandle(int dxfcode, ulong handle) 16 | { 17 | bool value = base.AddHandle(dxfcode, handle); 18 | if (value) 19 | return value; 20 | 21 | switch (dxfcode) 22 | { 23 | case 348: 24 | VisualStyleHandle = handle; 25 | value = true; 26 | break; 27 | } 28 | 29 | return value; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ACadSharp/IO/Templates/CadXRecordTemplate.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Objects; 2 | 3 | namespace ACadSharp.IO.Templates 4 | { 5 | internal class CadXRecordTemplate : CadTemplate 6 | { 7 | public CadXRecordTemplate(XRecrod cadObject) : base(cadObject) { } 8 | 9 | public override bool CheckDxfCode(int dxfcode, object value) 10 | { 11 | switch (dxfcode) 12 | { 13 | //NOTE: Undocumented codes 14 | case 370: 15 | case 440: 16 | return true; 17 | } 18 | 19 | //1-369 (except 5 and 105) 20 | //These values can be used by an application in any way 21 | 22 | //TODO: Finsih cadXrecordtemplate 23 | 24 | if (dxfcode == 5 || dxfcode == 105 || dxfcode > 369) 25 | return false; 26 | else 27 | return true; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ACadSharp/IO/Templates/DwgColorTemplate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.IO.Templates 4 | { 5 | internal class DwgColorTemplate : CadTemplate 6 | { 7 | public string Name { get; set; } 8 | public string BookName { get; set; } 9 | 10 | public DwgColorTemplate(DwgColor color) : base(color) { } 11 | 12 | public override void Build(CadDocumentBuilder builder) 13 | { 14 | base.Build(builder); 15 | 16 | //throw new NotImplementedException(); 17 | } 18 | 19 | public class DwgColor : CadObject 20 | { 21 | public override ObjectType ObjectType => ObjectType.INVALID; 22 | public Color Color { get; set; } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ACadSharp/IO/Templates/DwgGroupTemplate.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.IO.DWG; 2 | using ACadSharp.Objects; 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | namespace ACadSharp.IO.Templates 7 | { 8 | internal class DwgGroupTemplate : CadTemplate 9 | { 10 | public List Handles { get; set; } = new List(); 11 | 12 | public DwgGroupTemplate(Group group) : base(group) { } 13 | 14 | public override void Build(CadDocumentBuilder builder) 15 | { 16 | base.Build(builder); 17 | 18 | foreach (var handle in this.Handles) 19 | { 20 | CadObject member = builder.GetCadObject(handle); 21 | if (member != null) 22 | { 23 | this.CadObject.Members.Add(handle, member); 24 | } 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ACadSharp/IO/Templates/DwgTextEntityTemplate.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Entities; 2 | using ACadSharp.IO.DWG; 3 | using ACadSharp.Tables; 4 | 5 | namespace ACadSharp.IO.Templates 6 | { 7 | internal class DwgTextEntityTemplate : CadEntityTemplate 8 | { 9 | public ulong StyleHandle { get; set; } 10 | 11 | public DwgTextEntityTemplate(Entity entity) : base(entity) { } 12 | 13 | public override bool CheckDxfCode(int dxfcode, object value) 14 | { 15 | switch (dxfcode) 16 | { 17 | //Multiple options 18 | case 280: 19 | //return true; 20 | default: 21 | return false; 22 | } 23 | } 24 | 25 | public override void Build(CadDocumentBuilder builder) 26 | { 27 | base.Build(builder); 28 | 29 | switch (this.CadObject) 30 | { 31 | case TextEntity text: 32 | text.Style = builder.GetCadObject(this.StyleHandle); 33 | break; 34 | case MText mtext: 35 | mtext.Style = builder.GetCadObject(this.StyleHandle); 36 | break; 37 | default: 38 | throw new System.ArgumentException("Unknown type"); 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ACadSharp/IO/Templates/DwgViewportEntityControlTemplate.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Entities; 2 | using ACadSharp.IO.DWG; 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | namespace ACadSharp.IO.Templates 7 | { 8 | internal class DwgViewportEntityControlTemplate : CadTemplate 9 | { 10 | public List EntryHandles { get; } = new List(); 11 | 12 | public DwgViewportEntityControlTemplate() : base(null) { } 13 | 14 | public override void Build(CadDocumentBuilder builder) 15 | { 16 | base.Build(builder); 17 | 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ACadSharp/IO/Templates/ICadObjectBuilder.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.IO.DWG; 2 | 3 | namespace ACadSharp.IO.Templates 4 | { 5 | internal interface ICadObjectTemplate 6 | { 7 | void Build(CadDocumentBuilder builder); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ACadSharp/IO/Templates/ICadTableTemplate.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace ACadSharp.IO.Templates 4 | { 5 | internal interface ICadTableTemplate : ICadObjectTemplate 6 | { 7 | public CadObject CadObject { get; set; } 8 | 9 | List EntryHandles { get; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /ACadSharp/IObservableCollection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace ACadSharp 5 | { 6 | public interface IObservableCollection : IEnumerable 7 | where T : CadObject 8 | { 9 | /// 10 | /// Event triggerrs when an object is added to the collection 11 | /// 12 | event EventHandler OnAdd; 13 | 14 | /// 15 | /// Event triggerrs when an object is removed from the collection 16 | /// 17 | event EventHandler OnRemove; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ACadSharp/ISeqendColleciton.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Entities; 2 | 3 | namespace ACadSharp 4 | { 5 | public interface ISeqendColleciton 6 | { 7 | Seqend Seqend { get; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ACadSharp/LayoutCollection.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Entities; 2 | using ACadSharp.Objects; 3 | using System; 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | 7 | namespace ACadSharp 8 | { 9 | [Obsolete] 10 | public class LayoutCollection : IObservableCollection 11 | { 12 | public event EventHandler OnAdd; 13 | public event EventHandler OnRemove; 14 | 15 | public CadDocument Owner { get; } 16 | 17 | private readonly Dictionary _entries = new Dictionary(); 18 | 19 | public LayoutCollection(CadDocument document) 20 | { 21 | this.Owner = document; 22 | document.RegisterCollection(this); 23 | } 24 | 25 | public void Add(Layout layout) 26 | { 27 | this._entries.Add(layout.Handle, layout); 28 | 29 | OnAdd?.Invoke(this, new CollectionChangedEventArgs(layout)); 30 | } 31 | 32 | public void AddRange(IEnumerable items) 33 | { 34 | foreach (var item in items) 35 | { 36 | this.Add(item); 37 | } 38 | } 39 | 40 | public bool Remove(Layout item) 41 | { 42 | throw new NotImplementedException(); 43 | } 44 | 45 | public IEnumerator GetEnumerator() 46 | { 47 | return this._entries.Values.GetEnumerator(); 48 | } 49 | 50 | IEnumerator IEnumerable.GetEnumerator() 51 | { 52 | return this._entries.Values.GetEnumerator(); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /ACadSharp/MathUtils.cs: -------------------------------------------------------------------------------- 1 | using CSMath; 2 | using System; 3 | 4 | namespace ACadSharp 5 | { 6 | public static class MathUtils 7 | { 8 | /// 9 | /// Factor for converting radians to degrees. 10 | /// 11 | public const double RadToDeg = (180 / Math.PI); 12 | 13 | /// 14 | /// Factor for converting degrees to radians. 15 | /// 16 | public const double DegToRad = (Math.PI / 180); 17 | 18 | public static XY GetCenter(XY start, XY end, double bulge) 19 | { 20 | return GetCenter(start, end, bulge, out _); 21 | } 22 | 23 | public static XY GetCenter(XY start, XY end, double bulge, out double radius) 24 | { 25 | double theta = 4 * Math.Atan(Math.Abs(bulge)); 26 | double c = start.DistanceFrom(end) / 2.0; 27 | radius = c / Math.Sin(theta / 2.0); 28 | 29 | double gamma = (Math.PI - theta) / 2; 30 | double phi = XY.GetAngle(start, end) + Math.Sign(bulge) * gamma; 31 | return new XY(start.X + radius * Math.Cos(phi), start.Y + radius * Math.Sin(phi)); 32 | } 33 | 34 | /// 35 | /// 36 | /// 37 | /// 38 | /// 39 | /// 40 | /// 41 | /// 42 | /// 43 | public static T GetCenter(T start, T end, double bulge) 44 | where T : IVector, new() 45 | { 46 | //Needs a plane of reference in case is in 3D 47 | throw new NotImplementedException(); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /ACadSharp/Objects/DictionaryCloningFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.Objects 4 | { 5 | /// 6 | /// Duplicate record cloning flag (determines how to merge duplicate entries). 7 | /// 8 | [Flags] 9 | public enum DictionaryCloningFlags : short 10 | { 11 | /// 12 | /// Not applicable. 13 | /// 14 | NotApplicable = 0, 15 | /// 16 | /// Keep existing. 17 | /// 18 | KeepExisting = 1, 19 | /// 20 | /// Use clone. 21 | /// 22 | UseClone = 2, 23 | /// 24 | /// External reference name. 25 | /// 26 | XrefName = 3, 27 | /// 28 | /// Name. 29 | /// 30 | Name = 4, 31 | /// 32 | /// Unmangle name. 33 | /// 34 | UnmangleName = 5 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ACadSharp/Objects/DictionaryVariable.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | 3 | namespace ACadSharp.Objects 4 | { 5 | /// 6 | /// Represents a object. 7 | /// 8 | /// 9 | /// Object name
10 | /// Dxf class name 11 | ///
12 | [DxfName(DxfFileToken.ObjectDictionaryVar)] 13 | [DxfSubClass(DxfSubclassMarker.DictionaryVariables)] 14 | public class DictionaryVariable : CadObject 15 | { 16 | /// 17 | public override ObjectType ObjectType => ObjectType.UNLISTED; 18 | 19 | /// 20 | public override string ObjectName => DxfFileToken.ObjectDictionaryVar; 21 | 22 | /// 23 | /// Value of variable 24 | /// 25 | [DxfCodeValue(1)] 26 | public string Value { get; set; } 27 | 28 | /// 29 | /// Object schema number (currently set to 0) 30 | /// 31 | [DxfCodeValue(280)] 32 | public int ObjectSchemaNumber { get; internal set; } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /ACadSharp/Objects/Group.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using System.Collections.Generic; 3 | 4 | namespace ACadSharp.Objects 5 | { 6 | public class Group : CadObject 7 | { 8 | public override ObjectType ObjectType => ObjectType.GROUP; 9 | 10 | public override string ObjectName => DxfFileToken.TableGroup; 11 | 12 | /// 13 | /// Group description. 14 | /// 15 | [DxfCodeValue(300)] 16 | public string Description { get; set; } 17 | 18 | //70 “Unnamed” flag: 1 = Unnamed; 0 = Named 19 | 20 | [DxfCodeValue(71)] 21 | public bool Selectable { get; set; } 22 | 23 | //340 Hard-pointer handle to entity in group(one entry per object) 24 | public Dictionary Members { get; set; } = new Dictionary(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ACadSharp/Objects/LayoutFlags.cs: -------------------------------------------------------------------------------- 1 | #region copyright 2 | //Copyright 2021, Albert Domenech. 3 | //All rights reserved. 4 | //This source code is licensed under the MIT license. 5 | //See LICENSE file in the project root for full license information. 6 | #endregion 7 | using System; 8 | 9 | namespace ACadSharp.Objects 10 | { 11 | /// 12 | /// Layout flags 13 | /// 14 | [Flags] 15 | public enum LayoutFlags : short 16 | { 17 | /// 18 | /// None 19 | /// 20 | None = 0, 21 | /// 22 | /// Indicates the PSLTSCALE value for this layout when this layout is current 23 | /// 24 | PaperSpaceLinetypeScaling = 1, 25 | /// 26 | /// Indicates the LIMCHECK value for this layout when this layout is current 27 | /// 28 | LimitsChecking = 2, 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ACadSharp/Objects/MLStyle.Element.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using ACadSharp.Tables; 3 | 4 | namespace ACadSharp.Objects 5 | { 6 | public partial class MLStyle 7 | { 8 | public class Element 9 | { 10 | /// 11 | /// Element offset 12 | /// 13 | [DxfCodeValue(49)] 14 | public double Offset { get; set; } 15 | 16 | /// 17 | /// Element color 18 | /// 19 | [DxfCodeValue(62)] 20 | public Color Color { get; set; } = Color.ByBlock; 21 | 22 | /// 23 | /// Element linetype 24 | /// 25 | [DxfCodeValue(6)] 26 | public LineType LineType { get; set; } = LineType.ByLayer; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ACadSharp/Objects/MLineStyleFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.Objects 4 | { 5 | /// 6 | /// Flags (bit-coded). 7 | /// 8 | [Flags] 9 | public enum MLineStyleFlags 10 | { 11 | /// 12 | /// None 13 | /// 14 | None = 0, 15 | 16 | /// 17 | /// Fill on 18 | /// 19 | FillOn = 1, 20 | 21 | /// 22 | /// Display miters at the joints (inner vertexes) 23 | /// 24 | DisplayJoints = 2, 25 | 26 | /// 27 | /// Start square (line) cap 28 | /// 29 | StartSquareCap = 16, 30 | 31 | /// 32 | /// Start inner arcs cap 33 | /// 34 | StartInnerArcsCap = 32, 35 | 36 | /// 37 | /// Start round (outer arcs) cap 38 | /// 39 | StartRoundCap = 64, 40 | 41 | /// 42 | /// End square (line) cap 43 | /// 44 | EndSquareCap = 256, 45 | 46 | /// 47 | /// End inner arcs cap 48 | /// 49 | EndInnerArcsCap = 512, 50 | 51 | /// 52 | /// End round (outer arcs) cap 53 | /// 54 | EndRoundCap = 1024 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /ACadSharp/Objects/PaperMargin.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Objects 2 | { 3 | /// 4 | /// Represents the unprintable margins of a paper. 5 | /// 6 | public struct PaperMargin 7 | { 8 | /// 9 | /// Gets or set the size, in millimeters, of unprintable margin on left side of paper. 10 | /// 11 | public double Left { get; set; } 12 | 13 | /// 14 | /// Gets or set the size, in millimeters, of unprintable margin on bottom side of paper. 15 | /// 16 | public double Bottom { get; set; } 17 | 18 | /// 19 | /// Gets or set the size, in millimeters, of unprintable margin on right side of paper. 20 | /// 21 | public double Right { get; set; } 22 | 23 | /// 24 | /// Gets or set the size, in millimeters, of unprintable margin on top side of paper. 25 | /// 26 | public double Top { get; set; } 27 | 28 | /// 29 | /// Initializes a new instance of . 30 | /// 31 | /// Margin on left side of paper. 32 | /// Margin on bottom side of paper. 33 | /// Margin on right side of paper. 34 | /// Margin on top side of paper. 35 | public PaperMargin(double left, double bottom, double right, double top) 36 | { 37 | Left = left; 38 | Bottom = bottom; 39 | Right = right; 40 | Top = top; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ACadSharp/Objects/PlotPaperUnits.cs: -------------------------------------------------------------------------------- 1 | #region copyright 2 | //Copyright 2021, Albert Domenech. 3 | //All rights reserved. 4 | //This source code is licensed under the MIT license. 5 | //See LICENSE file in the project root for full license information. 6 | #endregion 7 | namespace ACadSharp.Objects 8 | { 9 | /// 10 | /// Plot paper units 11 | /// 12 | public enum PlotPaperUnits 13 | { 14 | /// 15 | /// Inches 16 | /// 17 | Inches = 0, 18 | 19 | /// 20 | /// Millimeters 21 | /// 22 | Milimeters = 1, 23 | 24 | /// 25 | /// Pixels, only applicable for raster outputs 26 | /// 27 | Pixels = 2 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ACadSharp/Objects/PlotRotation.cs: -------------------------------------------------------------------------------- 1 | #region copyright 2 | //Copyright 2021, Albert Domenech. 3 | //All rights reserved. 4 | //This source code is licensed under the MIT license. 5 | //See LICENSE file in the project root for full license information. 6 | #endregion 7 | namespace ACadSharp.Objects 8 | { 9 | /// 10 | /// Plot rotation 11 | /// 12 | public enum PlotRotation 13 | { 14 | /// 15 | /// No rotation. 16 | /// 17 | NoRotation = 0, 18 | 19 | /// 20 | /// 90 degrees counterclockwise. 21 | /// 22 | Degrees90 = 1, 23 | 24 | /// 25 | /// Upside-down. 26 | /// 27 | Degrees180 = 2, 28 | 29 | /// 30 | /// 90 degrees clockwise. 31 | /// 32 | Degrees270 = 3 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /ACadSharp/Objects/ShadePlotMode.cs: -------------------------------------------------------------------------------- 1 | #region copyright 2 | //Copyright 2021, Albert Domenech. 3 | //All rights reserved. 4 | //This source code is licensed under the MIT license. 5 | //See LICENSE file in the project root for full license information. 6 | #endregion 7 | namespace ACadSharp.Objects 8 | { 9 | /// 10 | /// Defines the shade plot mode 11 | /// 12 | public enum ShadePlotMode 13 | { 14 | /// 15 | /// As displayed. 16 | /// 17 | AsDisplayed = 0, 18 | 19 | /// 20 | /// Wireframe. 21 | /// 22 | Wireframe = 1, 23 | 24 | /// 25 | /// Hidden. 26 | /// 27 | Hidden = 2, 28 | 29 | /// 30 | /// Rendered. 31 | /// 32 | Rendered = 3 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /ACadSharp/Objects/ShadePlotResolutionMode.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Objects 2 | { 3 | /// 4 | /// Defines the shade plot resolution mode. 5 | /// 6 | public enum ShadePlotResolutionMode : ushort 7 | { 8 | /// 9 | /// Draft. 10 | /// 11 | Draft = 0, 12 | 13 | /// 14 | /// Preview. 15 | /// 16 | Preview = 1, 17 | 18 | /// 19 | /// Normal. 20 | /// 21 | Normal = 2, 22 | 23 | /// 24 | /// Presentation. 25 | /// 26 | Presentation = 3, 27 | 28 | /// 29 | /// Maximum 30 | /// 31 | Maximum = 4, 32 | 33 | /// 34 | /// Custom as specified by the shade plot DPI. 35 | /// 36 | Custom = 5 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ACadSharp/Objects/SortEntitiesTable.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using ACadSharp.Entities; 3 | using ACadSharp.Tables; 4 | using System.Collections.Generic; 5 | 6 | namespace ACadSharp.Objects 7 | { 8 | /// 9 | /// Represents a object 10 | /// 11 | /// 12 | /// Object name
13 | /// Dxf class name 14 | ///
15 | [DxfName(DxfFileToken.ObjectSortEntsTable)] 16 | [DxfSubClass(DxfSubclassMarker.SortentsTable)] 17 | public class SortEntitiesTable : CadObject 18 | { 19 | /// 20 | public override ObjectType ObjectType => ObjectType.UNLISTED; 21 | 22 | /// 23 | public override string ObjectName => DxfFileToken.ObjectSortEntsTable; 24 | 25 | /// 26 | /// Block owner where the table is applied 27 | /// 28 | [DxfCodeValue(330)] 29 | public BlockRecord BlockOwner { get; internal set; } 30 | 31 | public List Sorters { get; } = new List(); 32 | 33 | public class Sorter 34 | { 35 | /// 36 | /// Sort handle 37 | /// 38 | [DxfCodeValue(5)] 39 | public ulong SortHandle { get; set; } 40 | 41 | /// 42 | /// Soft-pointer ID/handle to an entity 43 | /// 44 | [DxfCodeValue(331)] 45 | public Entity Entity { get; set; } 46 | 47 | public Sorter() { } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /ACadSharp/Objects/VisualStyle.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Objects 2 | { 3 | public class VisualStyle : CadObject 4 | { 5 | public override ObjectType ObjectType => ObjectType.UNLISTED; 6 | 7 | public override string ObjectName => DxfFileToken.ObjectVisualStyle; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ACadSharp/Objects/XRecrod.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using System.Collections.Generic; 3 | 4 | namespace ACadSharp.Objects 5 | { 6 | /// 7 | /// Represents a object 8 | /// 9 | /// 10 | /// Object name
11 | /// Dxf class name 12 | ///
13 | [DxfName(DxfFileToken.ObjectXRecord)] 14 | [DxfSubClass(DxfSubclassMarker.XRecord)] 15 | public class XRecrod : CadObject 16 | { 17 | public override ObjectType ObjectType => ObjectType.XRECORD; 18 | 19 | public override string ObjectName => DxfFileToken.ObjectXRecord; 20 | 21 | /// 22 | /// Duplicate record cloning flag (determines how to merge duplicate entries) 23 | /// 24 | [DxfCodeValue(280)] 25 | public DictionaryCloningFlags ClonningFlags { get; set; } 26 | 27 | //1-369 (except 5 and 105) These values can be used by an application in any way 28 | public List Entries { get; set; } = new List(); 29 | 30 | public class Entry 31 | { 32 | public int Code { get; } 33 | 34 | public object Value { get; } 35 | 36 | public Entry(int code, object value) 37 | { 38 | this.Code = code; 39 | this.Value = value; 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ACadSharp/ReferenceChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp 4 | { 5 | public class ReferenceChangedEventArgs : EventArgs 6 | { 7 | /// 8 | /// Current value 9 | /// 10 | public CadObject Current { get; } 11 | 12 | /// 13 | /// Old value for the object 14 | /// 15 | public CadObject Old { get; } 16 | 17 | public ReferenceChangedEventArgs(CadObject curr, CadObject old) 18 | { 19 | this.Current = curr; 20 | this.Old = old; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ACadSharp/SeqendCollection.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Entities; 2 | 3 | namespace ACadSharp 4 | { 5 | /// 6 | /// Represents a collection of ended by a entity 7 | /// 8 | /// 9 | public class SeqendCollection : CadObjectCollection, ISeqendColleciton 10 | where T : CadObject 11 | { 12 | public Seqend Seqend 13 | { 14 | get { return _seqend; } 15 | internal set 16 | { 17 | this._seqend = value; 18 | this._seqend.Owner = this.Owner; 19 | } 20 | } 21 | 22 | private Seqend _seqend; 23 | 24 | public SeqendCollection(CadObject owner) : base(owner) 25 | { 26 | this.Seqend = new Seqend(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ACadSharp/Tables/AppId.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using ACadSharp.IO.Templates; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace ACadSharp.Tables 8 | { 9 | /// 10 | /// Represents a entry 11 | /// 12 | /// 13 | /// Object name
14 | /// Dxf class name 15 | ///
16 | [DxfName(DxfFileToken.TableAppId)] 17 | [DxfSubClass(DxfSubclassMarker.ApplicationId)] 18 | public class AppId : TableEntry 19 | { 20 | /// 21 | /// Default application registry name. 22 | /// 23 | public const string DefaultName = "ACAD"; 24 | 25 | public static AppId Default { get { return new AppId(DefaultName); } } 26 | 27 | /// 28 | public override ObjectType ObjectType => ObjectType.APPID; 29 | 30 | /// 31 | public override string ObjectName => DxfFileToken.TableAppId; 32 | 33 | internal AppId() : base() { } 34 | 35 | public AppId(string name) : base(name) 36 | { 37 | if (string.IsNullOrEmpty(name)) 38 | throw new ArgumentNullException(nameof(name), "App id must have a name."); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ACadSharp/Tables/ArcLengthSymbolPosition.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Tables 2 | { 3 | /// 4 | /// Controls the arc length symbol position in an arc length dimension. 5 | /// 6 | public enum ArcLengthSymbolPosition : short 7 | { 8 | /// 9 | /// Before the dimension text (default). 10 | /// 11 | BeforeDimensionText, 12 | /// 13 | /// Above the dimension text. 14 | /// 15 | AboveDimensionText, 16 | /// 17 | /// Don't display the arc length symbol. 18 | /// 19 | None, 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ACadSharp/Tables/Collections/AppIdsTable.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Tables.Collections 2 | { 3 | public class AppIdsTable : Table 4 | { 5 | /// 6 | public override ObjectType ObjectType => ObjectType.APPID_CONTROL_OBJ; 7 | 8 | /// 9 | public override string ObjectName => DxfFileToken.TableAppId; 10 | 11 | protected override string[] _defaultEntries { get { return new string[] { AppId.DefaultName }; } } 12 | 13 | internal AppIdsTable() : base() { } 14 | 15 | internal AppIdsTable(CadDocument document) : base(document) { } 16 | } 17 | } -------------------------------------------------------------------------------- /ACadSharp/Tables/Collections/BlockRecordsTable.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Blocks; 2 | 3 | namespace ACadSharp.Tables.Collections 4 | { 5 | public class BlockRecordsTable : Table 6 | { 7 | /// 8 | public override ObjectType ObjectType => ObjectType.BLOCK_CONTROL_OBJ; 9 | 10 | /// 11 | public override string ObjectName => DxfFileToken.TableBlockRecord; 12 | 13 | protected override string[] _defaultEntries { get { return new string[] { BlockRecord.ModelSpaceName, BlockRecord.PaperSpaceName }; } } 14 | 15 | internal BlockRecordsTable() { } 16 | 17 | internal BlockRecordsTable(CadDocument document) : base(document) { } 18 | } 19 | } -------------------------------------------------------------------------------- /ACadSharp/Tables/Collections/DimensionStylesTable.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.IO.Templates; 2 | 3 | namespace ACadSharp.Tables.Collections 4 | { 5 | public class DimensionStylesTable : Table 6 | { 7 | /// 8 | public override ObjectType ObjectType => ObjectType.DIMSTYLE_CONTROL_OBJ; 9 | 10 | /// 11 | public override string ObjectName => DxfFileToken.TableDimstyle; 12 | 13 | protected override string[] _defaultEntries { get { return new string[] { DimensionStyle.DefaultName }; } } 14 | 15 | internal DimensionStylesTable() : base() { } 16 | 17 | internal DimensionStylesTable(CadDocument document) : base(document) { } 18 | } 19 | } -------------------------------------------------------------------------------- /ACadSharp/Tables/Collections/LayersTable.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Tables.Collections 2 | { 3 | public class LayersTable : Table 4 | { 5 | /// 6 | public override ObjectType ObjectType => ObjectType.LAYER_CONTROL_OBJ; 7 | 8 | /// 9 | public override string ObjectName => DxfFileToken.TableLayer; 10 | 11 | protected override string[] _defaultEntries { get { return new string[] { Layer.DefaultName }; } } 12 | 13 | internal LayersTable() { } 14 | 15 | internal LayersTable(CadDocument document) : base(document) { } 16 | } 17 | } -------------------------------------------------------------------------------- /ACadSharp/Tables/Collections/LineTypesTable.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.IO.Templates; 2 | 3 | namespace ACadSharp.Tables.Collections 4 | { 5 | public class LineTypesTable : Table 6 | { 7 | /// 8 | public override ObjectType ObjectType => ObjectType.LTYPE_CONTROL_OBJ; 9 | 10 | /// 11 | public override string ObjectName => DxfFileToken.TableLinetype; 12 | 13 | protected override string[] _defaultEntries 14 | { 15 | get 16 | { 17 | return new string[] 18 | { 19 | LineType.ByLayerName, 20 | LineType.ByBlockName, 21 | LineType.ContinuousName 22 | }; 23 | } 24 | } 25 | 26 | internal LineTypesTable() : base() { } 27 | 28 | internal LineTypesTable(CadDocument document) : base(document) { } 29 | } 30 | } -------------------------------------------------------------------------------- /ACadSharp/Tables/Collections/TextStylesTable.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Tables.Collections 2 | { 3 | public class TextStylesTable : Table 4 | { 5 | /// 6 | public override ObjectType ObjectType => ObjectType.STYLE_CONTROL_OBJ; 7 | 8 | /// 9 | public override string ObjectName => DxfFileToken.TableStyle; 10 | 11 | protected override string[] _defaultEntries { get { return new string[] { TextStyle.DefaultName }; } } 12 | 13 | internal TextStylesTable() : base() { } 14 | 15 | internal TextStylesTable(CadDocument document) : base(document) { } 16 | 17 | public override void Add(TextStyle item) 18 | { 19 | if (string.IsNullOrEmpty(item.Name) && !string.IsNullOrEmpty(item.Filename)) 20 | { 21 | this.add(item.Filename, item); 22 | return; 23 | } 24 | 25 | base.Add(item); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /ACadSharp/Tables/Collections/UCSTable.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Tables.Collections 2 | { 3 | public class UCSTable : Table 4 | { 5 | /// 6 | public override ObjectType ObjectType => ObjectType.UCS_CONTROL_OBJ; 7 | 8 | /// 9 | public override string ObjectName => DxfFileToken.TableUcs; 10 | 11 | protected override string[] _defaultEntries { get { return new string[] { }; } } 12 | 13 | internal UCSTable() : base() { } 14 | 15 | internal UCSTable(CadDocument document) : base(document) { } 16 | } 17 | } -------------------------------------------------------------------------------- /ACadSharp/Tables/Collections/VPortsTable.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.IO.Templates; 2 | 3 | namespace ACadSharp.Tables.Collections 4 | { 5 | public class VPortsTable : Table 6 | { 7 | /// 8 | public override ObjectType ObjectType => ObjectType.VPORT_CONTROL_OBJ; 9 | 10 | /// 11 | public override string ObjectName => DxfFileToken.TableVport; 12 | 13 | protected override string[] _defaultEntries { get { return new string[] { VPort.DefaultName }; } } 14 | 15 | internal VPortsTable() : base() { } 16 | 17 | internal VPortsTable(CadDocument document) : base(document) { } 18 | } 19 | } -------------------------------------------------------------------------------- /ACadSharp/Tables/Collections/ViewsTable.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.IO.Templates; 2 | 3 | namespace ACadSharp.Tables.Collections 4 | { 5 | public class ViewsTable : Table 6 | { 7 | /// 8 | public override ObjectType ObjectType => ObjectType.VIEW_CONTROL_OBJ; 9 | 10 | /// 11 | public override string ObjectName => DxfFileToken.TableView; 12 | 13 | protected override string[] _defaultEntries { get { return new string[] { }; } } 14 | 15 | internal ViewsTable() : base() { } 16 | 17 | internal ViewsTable(CadDocument document) : base(document) { } 18 | } 19 | } -------------------------------------------------------------------------------- /ACadSharp/Tables/DefaultLightingType.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Tables 2 | { 3 | /// 4 | /// Default lighting type 5 | /// 6 | public enum DefaultLightingType : short 7 | { 8 | /// 9 | /// One distant light 10 | /// 11 | OneDistantLight, 12 | /// 13 | /// Two distant lights 14 | /// 15 | TwoDistantLights, 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ACadSharp/Tables/DimensionTextBackgroundFillMode.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Tables 2 | { 3 | /// 4 | /// Represents the dimension text background color. 5 | /// 6 | public enum DimensionTextBackgroundFillMode : short 7 | { 8 | /// 9 | /// No background color is used. 10 | /// 11 | NoBackground, 12 | /// 13 | /// In this mode the drawing background color is used. 14 | /// 15 | DrawingBackgroundColor, 16 | /// 17 | /// This mode is used as the dimension text background. 18 | /// 19 | DimensionTextBackgroundColor, 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ACadSharp/Tables/DimensionTextHorizontalAlignment.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Tables 2 | { 3 | /// 4 | /// Controls the vertical placement of dimension text in relation to the dimension line. 5 | /// 6 | public enum DimensionTextHorizontalAlignment : byte 7 | { 8 | /// 9 | /// Centers the dimension text along the dimension line between the extension lines. 10 | /// 11 | Centered = 0, 12 | 13 | /// 14 | /// Left-justifies the text with the first extension line along the dimension line. 15 | /// 16 | Left = 1, 17 | 18 | /// 19 | /// Right-justifies the text with the second extension line along the dimension line. 20 | /// 21 | Right = 2, 22 | 23 | /// 24 | /// Positions the text over or along the first extension line. 25 | /// 26 | OverFirstExtLine = 3, 27 | 28 | /// 29 | /// Positions the text over or along the second extension line. 30 | /// 31 | OverSecondExtLine = 4 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ACadSharp/Tables/DimensionTextVerticalAlignment.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Tables 2 | { 3 | /// 4 | /// Controls the placement of dimension text. 5 | /// 6 | public enum DimensionTextVerticalAlignment 7 | { 8 | /// 9 | /// Centers the dimension text between the two parts of the dimension line. 10 | /// 11 | Centered = 0, 12 | 13 | /// 14 | /// Places the dimension text above the dimension line. 15 | /// 16 | Above = 1, 17 | 18 | /// 19 | /// Places the dimension text on the side of the dimension line farthest away from the first defining point. 20 | /// 21 | Outside = 2, 22 | 23 | /// 24 | /// Places the dimension text to conform to a Japanese Industrial Standards (JIS) representation. 25 | /// 26 | JIS = 3, 27 | 28 | /// 29 | /// Places the dimension text under the dimension line. 30 | /// 31 | Below = 4 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ACadSharp/Tables/EntryFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.Tables 4 | { 5 | /// 6 | /// Standard entry flags (bit-coded values). 7 | /// 8 | [Flags] 9 | public enum EntryFlags 10 | { 11 | /// 12 | /// Default 13 | /// 14 | None = 0, 15 | /// 16 | /// If set, table entry is externally dependent on an xRef. 17 | /// 18 | XrefDependent = 16, 19 | /// 20 | /// If both this bit and bit 16 are set, the externally dependent xRef has been successfully resolved. 21 | /// 22 | XrefResolved = 32, 23 | /// 24 | /// If set, the table entry was referenced by at least one entity in the drawing the last time the 25 | /// drawing was edited. (This flag is for the benefit of AutoCAD commands. It can be ignored by 26 | /// most programs that read DXF files and need not be set by programs that write DXF files) 27 | /// 28 | Referenced = 64 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ACadSharp/Tables/FontFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.Tables 4 | { 5 | /// 6 | /// Represent the font character formatting, such as italic, bold, or regular. 7 | /// 8 | [Flags] 9 | public enum FontFlags 10 | { 11 | /// 12 | /// Regular. 13 | /// 14 | Regular = 0, 15 | /// 16 | /// Italic or oblique. 17 | /// 18 | Italic = 1, 19 | /// 20 | /// Bold. 21 | /// 22 | Bold = 2 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /ACadSharp/Tables/FractionFormat.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Tables 2 | { 3 | /// 4 | /// Represents the fraction format when the linear unit format is set to architectural or fractional. 5 | /// 6 | public enum FractionFormat : short 7 | { 8 | /// 9 | /// Horizontal stacking. 10 | /// 11 | Horizontal, 12 | /// 13 | /// Diagonal stacking. 14 | /// 15 | Diagonal, 16 | /// 17 | /// Not stacked. 18 | /// 19 | None, 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ACadSharp/Tables/GridFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.Tables 4 | { 5 | [Flags] 6 | public enum GridFlags : short 7 | { 8 | _0 = 0, 9 | _1 = 1, 10 | _2 = 2, 11 | _3 = 4, 12 | _4 = 8, 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ACadSharp/Tables/LayerFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace ACadSharp.Tables 6 | { 7 | /// 8 | /// Standard layer flags (bit-coded values). 9 | /// 10 | [Flags] 11 | public enum LayerFlags : short 12 | { 13 | /// 14 | /// None 15 | /// 16 | None = 0, 17 | 18 | /// 19 | /// Layer is frozen; otherwise layer is thawed 20 | /// 21 | Frozen = 1, 22 | 23 | /// 24 | /// Layer is frozen by default in new viewports 25 | /// 26 | FrozenNewViewports = 2, 27 | 28 | /// 29 | /// Layer is locked 30 | /// 31 | Locked = 4, 32 | 33 | /// 34 | /// If set, table entry is externally dependent on an xRef 35 | /// 36 | XrefDependent = 16, 37 | 38 | /// 39 | /// If both this bit and bit 16 are set, the externally dependent xRef has been successfully resolved 40 | /// 41 | XrefResolved = 32, 42 | 43 | /// 44 | /// If set, the table entry was referenced by at least one entity in the drawing the last time the 45 | /// drawing was edited. (This flag is for the benefit of AutoCAD commands. It can be ignored by 46 | /// most programs that read DXF files and need not be set by programs that write DXF files) 47 | /// 48 | Referenced = 64 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /ACadSharp/Tables/LinetypeShapeFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.Tables 4 | { 5 | /// 6 | /// Represents a line type complex element type. 7 | /// 8 | [Flags] 9 | public enum LinetypeShapeFlags : short 10 | { 11 | /// 12 | /// None. 13 | /// 14 | None = 0, 15 | 16 | /// 17 | /// Text is rotated 0 degrees, otherwise it follows the segment. 18 | /// 19 | RotationIsAbsolute = 1, 20 | 21 | /// 22 | /// Complex shape code holds the index of the shape to be drawn. 23 | /// 24 | Text = 2, 25 | 26 | /// 27 | /// Complex shape code holds the index into the text area of the string to be drawn. 28 | /// 29 | Shape = 4, 30 | } 31 | } -------------------------------------------------------------------------------- /ACadSharp/Tables/StandardFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ACadSharp.Tables 8 | { 9 | /// 10 | /// Standard flags for tables 11 | /// 12 | [Flags] 13 | public enum StandardFlags : short 14 | { 15 | /// 16 | /// None 17 | /// 18 | None = 0, 19 | 20 | /// 21 | /// If set, table entry is externally dependent on an xRef 22 | /// 23 | XrefDependent = 16, 24 | 25 | /// 26 | /// If both this bit and bit 16 are set, the externally dependent xRef has been successfully resolved 27 | /// 28 | XrefResolved = 32, 29 | 30 | /// 31 | /// If set, the table entry was referenced by at least one entity in the drawing the last time the 32 | /// drawing was edited. (This flag is for the benefit of AutoCAD commands. It can be ignored by 33 | /// most programs that read DXF files and need not be set by programs that write DXF files) 34 | /// 35 | Referenced = 64, 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ACadSharp/Tables/StyleFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.Tables 4 | { 5 | /// 6 | /// Standard layer flags (bit-coded values). 7 | /// 8 | [Flags] 9 | public enum StyleFlags 10 | { 11 | /// 12 | /// Default 13 | /// 14 | None = 0, 15 | 16 | /// 17 | /// If set, this entry describes a shape 18 | /// 19 | IsShape = 1, 20 | 21 | /// 22 | /// Vertical text 23 | /// 24 | VerticalText = 4, 25 | 26 | /// 27 | /// If set, table entry is externally dependent on an xRef. 28 | /// 29 | XrefDependent = 16, 30 | 31 | /// 32 | /// If both this bit and bit 16 are set, the externally dependent xRef has been successfully resolved. 33 | /// 34 | XrefResolved = 32, 35 | 36 | /// 37 | /// If set, the table entry was referenced by at least one entity in the drawing the last time the 38 | /// drawing was edited. (This flag is for the benefit of AutoCAD commands. It can be ignored by 39 | /// most programs that read DXF files and need not be set by programs that write DXF files) 40 | /// 41 | Referenced = 64 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ACadSharp/Tables/TableEntry.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp.Attributes; 2 | using System; 3 | 4 | namespace ACadSharp.Tables 5 | { 6 | [DxfSubClass(DxfSubclassMarker.TableRecord, true)] 7 | public abstract class TableEntry : CadObject, INamedCadObject 8 | { 9 | /// 10 | /// Specifies the name of the object 11 | /// 12 | [DxfCodeValue(2)] 13 | public string Name { get; set; } 14 | 15 | /// 16 | /// Standard flags 17 | /// 18 | [DxfCodeValue(70)] 19 | public StandardFlags Flags { get; set; } 20 | 21 | internal TableEntry() { } 22 | 23 | public TableEntry(string name) 24 | { 25 | this.Name = name; 26 | } 27 | 28 | /// 29 | public override string ToString() 30 | { 31 | return $"{this.ObjectName}:{this.Name}"; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /ACadSharp/Tables/TextDirection.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Tables 2 | { 3 | /// 4 | /// Represents the text direction (left-to-right or right-to-left). 5 | /// 6 | public enum TextDirection : byte 7 | { 8 | /// Display text left-to-right. 9 | LeftToRight, 10 | /// Display text right-to-left. 11 | RightToLeft, 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ACadSharp/Tables/TextMovement.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Tables 2 | { 3 | /// 4 | /// Text movement rules. 5 | /// 6 | public enum TextMovement : short 7 | { 8 | /// 9 | /// Moves the dimension line with dimension text. 10 | /// 11 | MoveLineWithText, 12 | /// 13 | /// Adds a leader when dimension text is moved. 14 | /// 15 | AddLeaderWhenTextMoved, 16 | /// 17 | /// Allows text to be moved freely without a leader. 18 | /// 19 | FreeTextPosition, 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ACadSharp/Tables/ToleranceAlignment.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Tables 2 | { 3 | /// 4 | /// Tolerance alignment. 5 | /// 6 | public enum ToleranceAlignment : byte 7 | { 8 | /// 9 | /// Aligns the tolerance text with the bottom of the main dimension text. 10 | /// 11 | Bottom = 0, 12 | 13 | /// 14 | /// Aligns the tolerance text with the middle of the main dimension text. 15 | /// 16 | Middle = 1, 17 | 18 | /// 19 | /// Aligns the tolerance text with the top of the main dimension text. 20 | /// 21 | Top = 2 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ACadSharp/Tables/UscIconType.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Tables 2 | { 3 | /// 4 | /// Display Ucs icon 5 | /// 6 | public enum UscIconType : short 7 | { 8 | /// 9 | /// Off; No icon is displayed 10 | /// 11 | Off, 12 | 13 | /// 14 | /// On; the icon is displayed only in the lower-left corner of the current viewport or layout 15 | /// 16 | OnLower, 17 | 18 | /// 19 | /// Off; if the icon is turned on, it is displayed at the UCS origin, if possible 20 | /// 21 | OffOrigin, 22 | 23 | /// 24 | /// On; Displays the UCS icon at the origin, if possible. 25 | /// 26 | OnOrigin 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ACadSharp/Tables/ViewModeType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp.Tables 4 | { 5 | [Flags] 6 | public enum ViewModeType 7 | { 8 | /// 9 | /// Off 10 | /// 11 | Off = 0, 12 | /// 13 | /// Perspective view 14 | /// 15 | PerspectiveView = 1, 16 | /// 17 | /// Front clipping 18 | /// 19 | FrontClipping = 2, 20 | /// 21 | /// Back clipping 22 | /// 23 | BackClipping = 4, 24 | /// 25 | /// 26 | /// 27 | Follow = 8, 28 | /// 29 | /// Front clipping not at the camera (not available in AutoCAD LT) 30 | /// 31 | /// 32 | /// If turned on, FRONTZ determines the front clipping plane. 33 | /// If turned off, FRONTZ is ignored, and the front clipping plane passes through the camera point. 34 | /// This setting is ignored if the front-clipping bit 2 is turned off. 35 | /// 36 | FrontClippingZ = 16, 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ACadSharp/Tables/ZeroHandling.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Tables 2 | { 3 | /// 4 | /// Represents supression of zeros in displaying decimal numbers. 5 | /// 6 | public enum ZeroHandling : byte 7 | { 8 | /// 9 | /// Suppress zero feet and exactly zero inches. 10 | /// 11 | SuppressZeroFeetAndInches = 0, 12 | /// 13 | /// Show zero feet and exactly zero inches. 14 | /// 15 | ShowZeroFeetAndInches = 1, 16 | /// 17 | /// Show zero feet and suppress zero inches. 18 | /// 19 | ShowZeroFeetSuppressZeroInches = 2, 20 | /// 21 | /// Suppress zero feet and show zero inches. 22 | /// 23 | SuppressZeroFeetShowZeroInches = 3, 24 | /// 25 | /// Suppress leading zeroes in decimal numbers. 26 | /// 27 | SuppressDecimalLeadingZeroes = 4, 28 | /// 29 | /// Suppress trailing zeroes in decimal numbers. 30 | /// 31 | SuppressDecimalTrailingZeroes = 8, 32 | /// 33 | /// Suppress both leading and trailing zeroes in decimal numbers 34 | /// 35 | SuppressDecimalLeadingAndTrailingZeroes = 12, 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ACadSharp/Types/DwgReferenceType.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp 2 | { 3 | public enum DwgReferenceType 4 | { 5 | Undefined = 0, 6 | 7 | /// 8 | /// Soft ownership reference: the owner does not need the owned object. The owned object cannot exist by itself. 9 | /// 10 | SoftOwnership = 2, 11 | 12 | /// 13 | /// Hard ownership reference: the owner needs the owned object. The owned object cannot exist by itself. 14 | /// 15 | HardOwnership = 3, 16 | 17 | /// 18 | /// Soft pointer reference: the referencing object does not need the referenced object and vice versa. 19 | /// 20 | SoftPointer = 4, 21 | 22 | /// 23 | /// Hard pointer reference: the referencing object needs the referenced object, but both are owned by another object. 24 | /// 25 | HardPointer = 5, 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ACadSharp/Types/DxfReferenceType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ACadSharp 4 | { 5 | /// 6 | /// Type of dxf reference 7 | /// 8 | [Flags] 9 | public enum DxfReferenceType : byte 10 | { 11 | /// 12 | /// No reference, the value is a primitive 13 | /// 14 | None = 0, 15 | 16 | /// 17 | /// Handle reference, the value is a handle pointing to an object 18 | /// 19 | Handle = 1, 20 | 21 | /// 22 | /// Name reference, the value is a name pointing to an object 23 | /// 24 | Name = 2, 25 | 26 | /// 27 | /// Counter reference, the value is a list with multiple elements referenced to it 28 | /// 29 | Count = 4, 30 | 31 | /// 32 | /// Optional value 33 | /// 34 | /// 35 | /// This values are ignored, may be configurable in the future 36 | /// 37 | Optional = 8, 38 | 39 | /// 40 | /// Value will be ignored by the reader and writer 41 | /// 42 | Ignored = 16, 43 | 44 | /// 45 | /// Value is an angle and must be converted when convinient 46 | /// 47 | IsAngle = 32, 48 | 49 | Unprocess = 64 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /ACadSharp/Types/OrthographicType.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp 2 | { 3 | /// 4 | /// Orthographic type 5 | /// 6 | public enum OrthographicType 7 | { 8 | /// 9 | /// None 10 | /// 11 | None, 12 | /// 13 | /// Top 14 | /// 15 | Top, 16 | /// 17 | /// Bottom 18 | /// 19 | Bottom, 20 | /// 21 | /// Front 22 | /// 23 | Front, 24 | /// 25 | /// Back 26 | /// 27 | Back, 28 | /// 29 | /// Left 30 | /// 31 | Left, 32 | /// 33 | /// Right 34 | /// 35 | Right, 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ACadSharp/Types/PlotType.cs: -------------------------------------------------------------------------------- 1 | #region copyright 2 | //Copyright 2021, Albert Domenech. 3 | //All rights reserved. 4 | //This source code is licensed under the MIT license. 5 | //See LICENSE file in the project root for full license information. 6 | #endregion 7 | namespace ACadSharp.Objects 8 | { 9 | /// 10 | /// Defines the portion of paper space to output to the media 11 | /// 12 | public enum PlotType 13 | { 14 | /// 15 | /// Last screen display 16 | /// 17 | LastScreenDisplay = 0, 18 | 19 | /// 20 | /// Drawing extents 21 | /// 22 | DrawingExtents = 1, 23 | 24 | /// 25 | /// Drawing limits 26 | /// 27 | DrawingLimits = 2, 28 | 29 | /// 30 | /// View specified by the plot view name 31 | /// 32 | View = 3, 33 | 34 | /// 35 | /// Window specified by the upper-right and bottom-left window corners 36 | /// 37 | Window = 4, 38 | 39 | /// 40 | /// Layout information 41 | /// 42 | LayoutInformation = 5 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /ACadSharp/Types/RenderMode.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp 2 | { 3 | /// 4 | /// Viewport render mode 5 | /// 6 | public enum RenderMode 7 | { 8 | /// 9 | /// Classic 2D 10 | /// 11 | Optimized2D, 12 | /// 13 | /// Wire frame 14 | /// 15 | Wireframe, 16 | /// 17 | /// Hidden line 18 | /// 19 | HiddenLine, 20 | /// 21 | /// Flat shaded 22 | /// 23 | FlatShaded, 24 | /// 25 | /// Gouraud shaded 26 | /// 27 | GouraudShaded, 28 | /// 29 | /// Flat shaded with wire frame 30 | /// 31 | FlatShadedWithWireframe, 32 | /// 33 | /// Gouraud shaded with wireframe 34 | /// 35 | GouraudShadedWithWireframe, 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ACadSharp/Types/ScaledType.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Objects 2 | { 3 | public enum ScaledType 4 | { 5 | ScaledToFit = 0,// Scaled to Fit 6 | _1 = 1,//1/128"=1'; 7 | _2 = 2,//1/64"=1'; 8 | _3 = 3,//1/32"=1' 9 | _4 = 4,//1/16"=1'; 10 | _5 = 5,//3/32"=1'; 11 | _6 = 6,//1/8"=1' 12 | _7 = 7,//3/16"=1'; 13 | _8 = 8,//1/4"=1'; 14 | _9 = 9,//3/8"=1' 15 | _10 = 10,// 1/2"=1'; 16 | _11 = 11,// 3/4"=1'; 17 | _12 = 12,// 1"=1' 18 | _13 = 13,// 3"=1'; 19 | _14 = 14,// 6"=1'; 20 | _15 = 15,// 1'=1' 21 | _16 = 16,// 1:1 ; 22 | _17 = 17,// 1:2; 23 | _18 = 18,// 1:4; 24 | _19 = 19,// 1:8; 25 | _20 = 20,// 1:10; 26 | _21 = 21,// 1:16 27 | _22 = 22,// 1:20; 28 | _23 = 23,// 1:30; 29 | _24 = 24,// 1:40; 30 | _25 = 25,// 1:50; 31 | _26 = 26,// 1:100 32 | _27 = 27,// 2:1; 33 | _28 = 28,// 4:1; 34 | _29 = 29,// 8:1; 35 | _30 = 30,// 10:1; 36 | _31 = 31,// 100:1; 37 | _32 = 32,// 1000:1 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ACadSharp/Types/Units/AngularDirection.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Types.Units 2 | { 3 | /// 4 | /// Represents angular direction. 5 | /// 6 | public enum AngularDirection : short 7 | { 8 | /// 9 | /// Counterclockwise angles 10 | /// 11 | CounterClockWise = 0, 12 | /// 13 | /// Clockwise angles 14 | /// 15 | ClockWise = 1, 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ACadSharp/Types/Units/AngularUnitFormat.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Types.Units 2 | { 3 | /// 4 | /// Angular unit format 5 | /// 6 | public enum AngularUnitFormat : short 7 | { 8 | /// 9 | /// Decimal degrees 10 | /// 11 | DecimalDegrees, 12 | 13 | /// 14 | /// Degrees/minutes/seconds 15 | /// 16 | DegreesMinutesSeconds, 17 | 18 | /// 19 | /// Gradians 20 | /// 21 | Gradians, 22 | 23 | /// 24 | /// Radians 25 | /// 26 | Radians, 27 | 28 | /// 29 | /// Surveyors units 30 | /// 31 | SurveyorsUnits, 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ACadSharp/Types/Units/LinearUnitFormat.cs: -------------------------------------------------------------------------------- 1 | namespace ACadSharp.Types.Units 2 | { 3 | /// 4 | /// Units format for decimal numbers 5 | /// 6 | public enum LinearUnitFormat : short 7 | { 8 | /// 9 | /// None 10 | /// 11 | None = 0, 12 | /// 13 | /// Scientific 14 | /// 15 | Scientific = 1, 16 | /// 17 | /// Decimal 18 | /// 19 | Decimal = 2, 20 | /// 21 | /// Engineering 22 | /// 23 | Engineering = 3, 24 | /// 25 | /// Architectural 26 | /// 27 | Architectural = 4, 28 | /// 29 | /// Fractional 30 | /// 31 | Fractional = 5, 32 | /// 33 | /// Windows desktop 34 | /// 35 | WindowsDesktop = 6, 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ACadSharpInternal.Tests/DwgHeaderWriterTests.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp; 2 | using ACadSharp.IO.DWG; 3 | using System.IO; 4 | using Xunit; 5 | using Xunit.Abstractions; 6 | 7 | namespace ACadSharpInternal.Tests 8 | { 9 | public class DwgHeaderWriterTests : DwgSectionWriterTestBase 10 | { 11 | public DwgHeaderWriterTests(ITestOutputHelper output) : base(output) 12 | { 13 | } 14 | 15 | [Theory] 16 | [MemberData(nameof(DwgVersions))] 17 | public void WriteTest(ACadVersion version) 18 | { 19 | Stream stream = new MemoryStream(); 20 | CadDocument document = new CadDocument(); 21 | document.Header.Version = version; 22 | 23 | DwgHeaderWriter writer = new DwgHeaderWriter(stream, document); 24 | writer.Write(); 25 | 26 | IDwgStreamReader sreader = DwgStreamReaderBase.GetStreamHandler(version, stream, true); 27 | DwgHeaderReader reader = new DwgHeaderReader(version, sreader); 28 | var header = reader.Read(0, out _); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ACadSharpInternal.Tests/DwgSectionWriterTestBase.cs: -------------------------------------------------------------------------------- 1 | using ACadSharp; 2 | using ACadSharp.IO; 3 | using Xunit; 4 | using Xunit.Abstractions; 5 | 6 | namespace ACadSharpInternal.Tests 7 | { 8 | public abstract class DwgSectionWriterTestBase 9 | { 10 | public static TheoryData DwgVersions { get; } 11 | 12 | protected readonly ITestOutputHelper _output; 13 | 14 | static DwgSectionWriterTestBase() 15 | { 16 | DwgVersions = new TheoryData 17 | { 18 | ACadVersion.AC1012, 19 | ACadVersion.AC1014, 20 | ACadVersion.AC1015, 21 | ACadVersion.AC1018, 22 | ACadVersion.AC1021, 23 | ACadVersion.AC1024, 24 | ACadVersion.AC1027, 25 | ACadVersion.AC1032, 26 | }; 27 | } 28 | 29 | public DwgSectionWriterTestBase(ITestOutputHelper output) 30 | { 31 | this._output = output; 32 | } 33 | 34 | protected virtual void onNotification(object sender, NotificationEventArgs e) 35 | { 36 | _output.WriteLine(e.Message); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ACadSharpInternal.Tests/TestSetup.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | 3 | [assembly: CollectionBehavior(DisableTestParallelization = true)] 4 | -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | latest 4 | Debug;Release;Test 5 | 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Jan Kozik 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /reference/ACadFileExploration.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankozik/AutoCAD_CSharpLib/89d7977bd46a0880a456256611d48ee2b628ae98/reference/ACadFileExploration.xlsx -------------------------------------------------------------------------------- /reference/OpenDesign_Specification_for_.dwg_files.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankozik/AutoCAD_CSharpLib/89d7977bd46a0880a456256611d48ee2b628ae98/reference/OpenDesign_Specification_for_.dwg_files.pdf -------------------------------------------------------------------------------- /reference/autocad_2012_pdf_dxf-reference_enu.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankozik/AutoCAD_CSharpLib/89d7977bd46a0880a456256611d48ee2b628ae98/reference/autocad_2012_pdf_dxf-reference_enu.pdf -------------------------------------------------------------------------------- /samples/sample_AC1014.dwg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankozik/AutoCAD_CSharpLib/89d7977bd46a0880a456256611d48ee2b628ae98/samples/sample_AC1014.dwg -------------------------------------------------------------------------------- /samples/sample_AC1015.dwg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankozik/AutoCAD_CSharpLib/89d7977bd46a0880a456256611d48ee2b628ae98/samples/sample_AC1015.dwg -------------------------------------------------------------------------------- /samples/sample_AC1015_binary.dxf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankozik/AutoCAD_CSharpLib/89d7977bd46a0880a456256611d48ee2b628ae98/samples/sample_AC1015_binary.dxf -------------------------------------------------------------------------------- /samples/sample_AC1018.dwg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankozik/AutoCAD_CSharpLib/89d7977bd46a0880a456256611d48ee2b628ae98/samples/sample_AC1018.dwg -------------------------------------------------------------------------------- /samples/sample_AC1018_binary.dxf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankozik/AutoCAD_CSharpLib/89d7977bd46a0880a456256611d48ee2b628ae98/samples/sample_AC1018_binary.dxf -------------------------------------------------------------------------------- /samples/sample_AC1021.dwg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankozik/AutoCAD_CSharpLib/89d7977bd46a0880a456256611d48ee2b628ae98/samples/sample_AC1021.dwg -------------------------------------------------------------------------------- /samples/sample_AC1021_binary.dxf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankozik/AutoCAD_CSharpLib/89d7977bd46a0880a456256611d48ee2b628ae98/samples/sample_AC1021_binary.dxf -------------------------------------------------------------------------------- /samples/sample_AC1024.dwg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankozik/AutoCAD_CSharpLib/89d7977bd46a0880a456256611d48ee2b628ae98/samples/sample_AC1024.dwg -------------------------------------------------------------------------------- /samples/sample_AC1024_binary.dxf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankozik/AutoCAD_CSharpLib/89d7977bd46a0880a456256611d48ee2b628ae98/samples/sample_AC1024_binary.dxf -------------------------------------------------------------------------------- /samples/sample_AC1027.dwg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankozik/AutoCAD_CSharpLib/89d7977bd46a0880a456256611d48ee2b628ae98/samples/sample_AC1027.dwg -------------------------------------------------------------------------------- /samples/sample_AC1027_binary.dxf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankozik/AutoCAD_CSharpLib/89d7977bd46a0880a456256611d48ee2b628ae98/samples/sample_AC1027_binary.dxf -------------------------------------------------------------------------------- /samples/sample_AC1032.dwg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankozik/AutoCAD_CSharpLib/89d7977bd46a0880a456256611d48ee2b628ae98/samples/sample_AC1032.dwg -------------------------------------------------------------------------------- /samples/sample_AC1032_binary.dxf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankozik/AutoCAD_CSharpLib/89d7977bd46a0880a456256611d48ee2b628ae98/samples/sample_AC1032_binary.dxf -------------------------------------------------------------------------------- /samples/sample_base/empty.dwg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankozik/AutoCAD_CSharpLib/89d7977bd46a0880a456256611d48ee2b628ae98/samples/sample_base/empty.dwg -------------------------------------------------------------------------------- /samples/sample_base/sample_base.dwg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankozik/AutoCAD_CSharpLib/89d7977bd46a0880a456256611d48ee2b628ae98/samples/sample_base/sample_base.dwg -------------------------------------------------------------------------------- /samples/sample_base/sample_base_backup.dwg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankozik/AutoCAD_CSharpLib/89d7977bd46a0880a456256611d48ee2b628ae98/samples/sample_base/sample_base_backup.dwg -------------------------------------------------------------------------------- /update_submodules.bat: -------------------------------------------------------------------------------- 1 | git pull --recurse-submodules 2 | git submodule update --remote --recursive 3 | @echo off 4 | pause --------------------------------------------------------------------------------