[Aspose.CAD 26.9] Unable to Add New Entities to Existing DWG Files – ObjectHandle and SoftOwner Not Preserved

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

  1. Does Aspose.CAD for .NET 26.9 support adding new entities to existing DWG files and saving them as valid DWG files?
  2. What is the officially recommended method for adding LINE, CIRCLE, TEXT, and other entities to an existing DWG?
  3. Is there an additional step required to register new entities, assign handles, or update the DWG object tables?
  4. Why does the DwgImage(CadAcadVersion) constructor throw NotImplementedException ?
  5. 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 file
  • test_line.dwg – Result after adding a LINE
  • test_circle.dwg – Result after adding a CIRCLE
  • result_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)

@ysoh,
Hello,

Thank you for the detailed description of the scenario you are facing with adding new entities to DWG files on Linux using Aspose.CAD for .NET 26.9.0.0. From what you have shared, the loading, modification, and deletion of existing entities work as expected, while the newly added LINE and CIRCLE objects lose their handle/owner information after the file is saved and re‑opened.

At the moment, adding entities to an existing DWG does require a few additional steps beyond simply inserting the object into BlockEntities or CadImage.Entities. The library expects the new objects to be registered in the internal object tables and to have valid handles and owner references. Typically this involves:

  1. Generating a unique handle for each new entity (using the image’s NextHandle or a similar helper).
  2. Setting the OwnerHandle (or SoftOwner) to the handle of the Model Space block (*Model_Space).
  3. Adding the entity to the image’s ObjectTable so that the handle is recorded.

If any of these steps are omitted, the entity may appear in memory but will be omitted from the saved DWG, which matches the behavior you observed.

Regarding the DwgImage(CadAcadVersion) constructor, this overload is not implemented in the current release; the library currently supports creating new DWG files only through the CadImage API after loading a template or by using the Create methods that are available for other formats. That is why the NotImplementedException is thrown.

To help us pinpoint the exact cause in your case, could you please provide a small sample DWG (the original file you load) together with the minimal code you use to add the LINE or CIRCLE? With the file and the exact sequence of API calls we can verify whether the handles are being assigned correctly and whether the object tables are being updated.

Once we have the sample, we’ll be able to confirm the supported workflow for adding entities, advise on any required registration steps, and provide a concise example that demonstrates a successful add‑and‑save cycle.

Hello,

Thank you for your response.

I have already attached test_files.zip (100.3 KB) to my original post. The ZIP file contains the sample DWG files and C# source code used to reproduce the issue.

Could you please review the attached files and reproduce the issue using Aspose.CAD for .NET 26.9.0.0?

Regarding your explanation about NextHandle and ObjectTable , could you provide the exact public API names and a working C# example demonstrating how to properly register and save a new LINE entity in an existing DWG file?

We have already tested assigning ObjectHandle and SoftOwner manually, but the issue remains unresolved.

If these operations are not supported through the public API, please confirm whether adding new entities to existing DWG files is officially supported.

I would appreciate it if the Aspose.CAD development team could review the attached sample and provide a verified solution.

Thank you.

@ysoh,
Hi,
thank you for all details provided, let us check this case and come back with feedback.

@ysoh,
Hello,
could you please test if the attached examples are helpful. We have support of creation only DWG 2018 version (CadAcadVersion.AC1032), that’s why exception occurred.
examples.zip (1.4 KB)

@oleksii.gorokhovatskyi

Hello,

Thank you for your response and for providing the sample code. Please excuse our delayed reply due to the holidays in Korea.

We tested your examples using Aspose.CAD for .NET 26.9.0.0 on Linux with .NET 8 and a commercial license.

Creating a new DWG and adding LINE/CIRCLE entities to a simple existing DWG both worked successfully. The resulting files opened in AutoCAD 2026 without recovery warnings.

However, we are still experiencing issues with an actual project drawing.

1. Block base points change after loading and saving without modifications

We confirmed that both the original and output files use the DWG 2018 format (AC1032).

We simply loaded and saved the host drawing, without adding or deleting entities, binding external references, or adjusting coordinates:

using var image = Aspose.CAD.Image.Load(inputPath);
image.Save(outputPath);

The drawing retains its existing external-reference links.

After comparing the original and saved drawings, we found that 31 block definitions had their BasePoint changed to (0, 0, 0). The insertion points of their INSERT entities remained unchanged, causing some symbols to appear at incorrect positions.

AutoCAD also displayed a message reporting three errors while opening the saved file.

2. Objects are discarded after incorporating an external reference

In a separate test using our own implementation, we attempted to incorporate an external-reference drawing into the host DWG as internal blocks.

During recovery, AutoCAD reported:

Error 34 (eWrongObjectType)
Object discarded

The recovery summary reported 410 deleted objects.

Of the 154 object handles explicitly listed in the reading errors, 127 belonged to entities within the original symbol blocks and 27 belonged to newly imported blocks. These entities were present when reloaded with Aspose.CAD, but AutoCAD discarded them during recovery.

3. Questions

Could you please clarify the following?

  1. Does “creation only DWG 2018 version (CadAcadVersion.AC1032)” refer specifically to the supported format for creating a new DwgImage? Are there any additional limitations for existing AC1032 files saved by AutoCAD 2026?

  2. If compatibility with files saved by AutoCAD 2026 is currently limited, are there plans to improve this compatibility? If available, could you share an estimated release timeline?

  3. Is the loss of block BasePoint values during a simple load-and-save operation a known issue? Is there an additional setting or recommended procedure required to preserve block base points and symbol positions?

  4. Is binding an external DWG reference into a host drawing supported? If so, could you provide an official working example or recommended procedure that preserves native entities and produces a file that opens without recovery warnings?

Thank you for your assistance.

@ysoh,
Hi.
Both problems you describe look like possible bugs. Plase share some test files and code samples, so we can reproduce the issues and plan work on the fixes for them. There are no known limitations or issues regarding your questions, probably, something works incorrectly during saving.

@oleksii.gorokhovatskyi

Hello,

Thank you for your response and for offering to investigate these issues.

We have prepared a test drawing, ValveXrefTest2.dwg, together with its external-reference file, Title_block.dwg, and a minimal C# program. The visible test area contains a valve symbol, an inside/outside boundary symbol, and reference lines that make displacement easy to compare.

  1. Loading and saving without any modifications

In the earlier version of this test drawing, which also contained only 8 Model Space entities, including one external-reference INSERT, merely loading and saving caused AutoCAD 2026 to report 3 errors while opening the output and recommend RECOVER. When that output was opened, the valve and the inside/outside boundary symbols were displaced relative to the reference lines and text. In particular, the boundary symbol appeared far away from its original position.

We have further reduced the test file to the attached ValveXrefTest2.dwg by purging unused definitions and giving the two symbol blocks generic names. We have confirmed in AutoCAD that this latest output produces the same opening-error warning and visible symbol displacement. Its output also exhibits the block-base-point changes described below in the SDK comparison.

The before/after screenshots show the opening warning and the visible displacement. We have not yet identified the detailed causes of the three opening errors, and we do not assume that they are the same as the block-base-point issue described below.

The supplied program only calls Image.Load() and Save(). It does not add, modify, or delete entities, bind external references, call UpdateSize(), or adjust coordinates.

Using Aspose.CAD for .NET 26.9.0.0, our before/after SDK comparison of the newly prepared ValveXrefTest2.dwg shows:

  • The two remaining symbol block-definition BasePoint values change from non-zero values to (0, 0, 0).
  • The compared INSERT insertion-point values do not change.
  • GATE VALVE changes from approximately (-16, 7.5, 0) to (0, 0, 0).
  • BUILDING PENETRATION changes from (-130, 70, 0) to (0, 0, 0).

The input and output each have 8 Model Space entities. In the output, the block definitions consist of the two symbol blocks, the external-reference block, and the standard Model/Paper Space blocks. The base-point comparison is performed on the Aspose output before any AutoCAD recovery or resaving.

Separately, newly created simple drawings containing a triangle block, including a rotated and mirrored instance, survive the same load/save test and open correctly in AutoCAD. Those block definitions have BasePoint=(0, 0, 0) before saving.

Could you investigate whether the loss of non-zero block-definition base points during saving explains the symbol displacement? Please also check whether the supplied drawing reveals a separate DWG structural problem responsible for the recovery warning.

  1. Binding an external reference into the host DWG

In earlier tests, our custom code that imported the external-reference contents into the host DWG produced recovery errors and missing or displaced objects. This binding operation is not performed by the attached minimal load/save program, so please treat it as a separate question rather than an independently reproduced case in this example.

Does Aspose.CAD 26.9 provide a supported API or a complete recommended example for binding an external-reference DWG into the host and saving a self-contained DWG while preserving existing block definitions, base points, and symbol placement?

Environment:

  • Aspose.CAD for .NET 26.9.0.0
  • .NET 8 on Linux
  • Commercial license
  • AutoCAD 2026 for verification; DWG 2018 / AC1032 format

The reproduction code uses our license through an environment variable. No license file is included.

To run the example, extract the archive and use that folder as the working directory. Set ASPOSE_CAD_LICENSE_PATH to your own license file and run:
dotnet run --project ValveSaveRepro.csproj -c Release

The archive contains the generated output for comparison. Before running the code, rename that supplied ValveXrefTest2_resave.dwg to a different filename, or change outputPath in Program.cs. The example uses FileMode.CreateNew to avoid overwriting an existing result.

Thank you for your assistance.

ValveXrefTest2.zip (816.8 KB)

@ysoh,
thank you for all details, we have created task CADNET-10507 to investigate and fix these issues.