Hello Aspose Support Team,
We are using Aspose.CAD for .NET 26.9.0.0 on Linux with .NET 8 and a commercial license.
We are developing a DWG processing application that needs to read existing DWG files, modify or delete existing entities, and add new entities before saving the modified DWG.
We have encountered an issue when adding new entities to existing DWG files.
1. Environment
- Aspose.CAD for .NET: 26.9.0.0
- .NET Runtime: .NET 8
- Operating System: Linux
- License: Commercial
- CAD Application for Verification: AutoCAD 2026
2. Problem Description
The following operations work correctly:
- Loading existing DWG files
- Modifying properties of existing entities
- Deleting existing entities
- Saving modified DWG files
However, adding new entities such as LINE or CIRCLE does not work correctly .
We tested adding entities to both BlockEntities["*Model_Space"] and CadImage.Entities .
The entities are successfully added in memory, but after saving and reloading the DWG file, the newly added entities are either missing or have invalid object information.
Additionally, when opening the modified DWG file in AutoCAD 2026, a drawing recovery warning appears, indicating that the file may contain errors or inconsistencies.
3. Test Results
Test 1: Adding a LINE without explicitly assigning ObjectHandle
Before saving:
Block Entities: 3
Image Entities: 3
LINE Handle: []
LINE SoftOwner: [1F]
After saving and reloading:
Reload Block Entities: 2
Reload Image Entities: 3
LINE Handle: [0]
LINE SoftOwner: []
The LINE geometry is preserved, but the entity is not associated with Model Space.
Test 2: Adding a CIRCLE
We performed the same test with a new CIRCLE entity.
After saving and reloading:
Reload Block Entities: 2
Reload Image Entities: 3
CIRCLE Handle: [0]
CIRCLE SoftOwner: []
The same issue occurs with CIRCLE entities.
Test 3: Explicitly assigning ObjectHandle and SoftOwner
We assigned a new handle (2DB ) and the Model Space owner handle (1F ) before saving.
Before saving:
LINE Handle: [2DB]
LINE SoftOwner: [1F]
After reloading:
Reload Block Entities: 2
Reload Image Entities: 2
Total LINE Count: 0
In this case, the newly added LINE disappears completely after saving.
Test 4: Creating a new DWG using DwgImage
We also tested the following code:
using var drawing = new DwgImage(CadAcadVersion.AC1027);
However, it throws:
System.NotImplementedException:
The method or operation is not implemented.
at Aspose.CAD.FileFormats.Cad.DwgImage..ctor(CadAcadVersion cadVersion)
We also confirmed that Image.Load() returns a CadImage instance rather than a DwgImage instance.
AutoCAD 2026 Verification: The original sample.dwg opens normally in AutoCAD 2026. However, when opening the modified DWG file generated by Aspose.CAD, AutoCAD 2026 displays a drawing recovery warning. This issue occurs after adding new entities and saving the drawing.
4. Expected Behavior
We expect newly added entities to:
- Be saved with valid ObjectHandle values
- Preserve their Model Space ownership information
- Be correctly associated with the Model Space block
- Be visible in AutoCAD 2026
- Open without DWG recovery warnings
5. Questions
- Does Aspose.CAD for .NET 26.9 support adding new entities to existing DWG files and saving them as valid DWG files?
- What is the officially recommended method for adding LINE, CIRCLE, TEXT, and other entities to an existing DWG?
- Is there an additional step required to register new entities, assign handles, or update the DWG object tables?
- Why does the
DwgImage(CadAcadVersion)constructor throwNotImplementedException? - Could you provide a complete working C# example demonstrating how to add a new LINE to an existing DWG file and save it successfully?
6. Attachments
We have attached the following files for reproduction:
sample.dwg– Original DWG filetest_line.dwg– Result after adding a LINEtest_circle.dwg– Result after adding a CIRCLEresult_handle_test.dwg– Result after explicitly assigning ObjectHandle- C# source code and project file
We would appreciate your guidance on whether this functionality is currently supported and, if so, the correct implementation.
Thank you for your assistance.
test_files.zip (100.3 KB)