Skip to content

Conversation

@thaiguer
Copy link
Contributor

Description

This PR changes the Header Value for 3 values that were beeing incorrectly interpreted by BricsCad.

The image shows the error list from BricsCad prompt before and after the code changes.
image

Related Issues / Pull Requests

@DomCR DomCR linked an issue Oct 24, 2025 that may be closed by this pull request
@DomCR DomCR added bug Something isn't working code refactoring Improvements in the existing code labels Oct 24, 2025
@DomCR
Copy link
Owner

DomCR commented Oct 24, 2025

Commit 8ddb6e5 should resolve the following errors:

Name: Database header
Value: System Variable "CMLSTYLE"
Validation: Invalid
Replaced by: Standard

Name: AcDbMlineStyle(15)
Value: Segments amount 0
Validation: Not 1..16
Replaced by: Set to 1

TODO: Consider renaming the class MLineStyle.Element to MLineStyle.Segment

@DomCR
Copy link
Owner

DomCR commented Oct 24, 2025

Commit ca483a4 should resolve the following errors:

(Not sure about this one)
Name: Database header
Value: System Variable "TEXTSIZE"
Validation: Not >0
Replaced by: Set to 2.5

Name: AcDbTextStyleTableRecord(12)
Value: Is not externally dependent on an Xref, but XRefBlockId ((4)) is not Null
Validation: Invalid
Replaced by: Set to Null

Name: AcDbTextStyleTableRecord(12)
Value: Last height 0
Validation: Not >0
Replaced by: Set to 2.5

@DomCR
Copy link
Owner

DomCR commented Oct 24, 2025

Commit 4ab1fd4 should resolve the following errors:

Name: AcDbDictionary(2D)
Value: AcDbDictionary (ACAD_FIELDLIST)
Validation: AcDbFieldList
Replaced by: Removed

Name: AcDbDictionary(A)
Value: Entry object (2D)
Validation: Invalid
Replaced by: Removed

@DomCR
Copy link
Owner

DomCR commented Oct 24, 2025

To simplify the location of the errors, I would recommend to create an empty dwg and open it with bricsCad, let me know the results.

@DomCR
Copy link
Owner

DomCR commented Oct 24, 2025

@thaiguer
Copy link
Contributor Author

The remaing erros are just these 5:

: _RECOVER
Recover .dwg file.
Name: .dwg file
Value: Object improperly read: <AcDbRasterImage> (3D)
 Previous error: .dwg file needs recovery
Replaced by: Removed

Total errors found during recover: 1.
Audit recovered Database.
Name: Database header
Value: System Variable "CMLSTYLE"
Validation: Invalid
Replaced by: Standard

Name: Database header
Value: System Variable "TILEMODELIGHTSYNCH"
Validation: Not 0..1
Replaced by: Set to 1

Name: AcDbTextStyleTableRecord(12)
Value: Is not externally dependent on an Xref, but XRefBlockId ((4)) is not Null
Validation: Invalid
Replaced by: Set to Null

Name: AcDbLayout(35)
Value: Layout has invalid ModelType flag
Validation: Invalid
Replaced by: Set to True

67 objects audited
Total errors found during audit 5, fixed 5

@DomCR
Copy link
Owner

DomCR commented Oct 28, 2025

Last 3 commits should resolve the following errors:

Name: Database header
Value: System Variable "CMLSTYLE"
Validation: Invalid
Replaced by: Standard

Name: AcDbLayout(35)
Value: Layout has invalid ModelType flag
Validation: Invalid
Replaced by: Set to True

@thaiguer
Copy link
Contributor Author

Hello.
Almost there.
Here is the new list, with only 3 errors:

: _RECOVER
Recover .dwg file.
Name: .dwg file
Value: Object improperly read: <AcDbRasterImage> (3D)
 Previous error: .dwg file needs recovery
Replaced by: Removed

Total errors found during recover: 1.
Audit recovered Database.
Name: Database header
Value: System Variable "TILEMODELIGHTSYNCH"
Validation: Not 0..1
Replaced by: Set to 1

Name: AcDbTextStyleTableRecord(12)
Value: Is not externally dependent on an Xref, but XRefBlockId ((4)) is not Null
Validation: Invalid
Replaced by: Set to Null

67 objects audited
Total errors found during audit 3, fixed 3

@DomCR
Copy link
Owner

DomCR commented Nov 1, 2025

I've been trying to locate the variable "TILEMODELIGHTSYNCH" but I couldn't find it, there are some sections in the dwg file that are not fully read because they are not rellevant for the file at all, al least for ACadSharp.

I'll try to focus on the main problem, the Value: Object improperly read: (3D), I'm guessing that is because the ImageRecord is not written but I'm not sure.

For the other issue "Value: Is not externally dependent on an Xref, but XRefBlockId ((4)) is not Null" not sure why is complaining about this one for a text style.

@DomCR
Copy link
Owner

DomCR commented Nov 5, 2025

I've noticed that ClipType is set to Rectangular, which takes only the 2 first vertices to draw a box, try to change the vertices to:

raster.ClipBoundaryVertices.Add(new XY(0, 0));
raster.ClipBoundaryVertices.Add(new XY(1, 1));

Or change the ClipType to polygonal, see if this does something.

@thaiguer
Copy link
Contributor Author

thaiguer commented Nov 5, 2025

I've noticed that ClipType is set to Rectangular, which takes only the 2 first vertices to draw a box, try to change the vertices to:

raster.ClipBoundaryVertices.Add(new XY(0, 0));
raster.ClipBoundaryVertices.Add(new XY(1, 1));

Or change the ClipType to polygonal, see if this does something.

using ACadSharp;
using ACadSharp.Entities;
using ACadSharp.IO;
using ACadSharp.Objects;
using CSMath;

string newFilePath = @"C:\devAux\newDocWithImage.dwg";
string imagePath = @"C:\devAux\image.jpg";

ImageDefinition definition = new ImageDefinition();
definition.Size = new XY(1, 1);
definition.Name = "image";
definition.IsLoaded = true;
definition.FileName = imagePath;

RasterImage raster = new RasterImage(definition);
raster.Flags = ImageDisplayFlags.ShowImage;

raster.ClipBoundaryVertices.Add(new XY(0, 0));
raster.ClipBoundaryVertices.Add(new XY(1, 1));
raster.ClipType = ClipType.Polygonal;

CadDocument newDoc = new CadDocument();
newDoc.Entities.Add(raster);

using (DwgWriter writer = new DwgWriter(newFilePath, newDoc))
{
    writer.Write();
}
: RECOVER
Recover .dwg file.
Name: .dwg file
Value: Object improperly read: <AcDbRasterImage> (3D)
 Previous error: .dwg file needs recovery
Replaced by: Removed

Total errors found during recover: 1.
Audit recovered Database.
Name: Database header
Value: System Variable "TILEMODELIGHTSYNCH"
Validation: Not 0..1
Replaced by: Set to 1

Name: AcDbTextStyleTableRecord(12)
Value: Is externally dependent on an Xref, but Xref BlockRecord ((4))
Validation: Invalid
Replaced by: Removed dependence

67 objects audited
Total errors found during audit 3, fixed 3

@thaiguer
Copy link
Contributor Author

thaiguer commented Nov 5, 2025

The same happens with different configurations:

RasterImage raster = new RasterImage(definition);
raster.Flags = ImageDisplayFlags.ShowImage;

raster.ClipType = ClipType.Polygonal;
raster.ClipBoundaryVertices.Add(new XY(0, 0));
raster.ClipBoundaryVertices.Add(new XY(0, 1));
raster.ClipBoundaryVertices.Add(new XY(1, 1));
raster.ClipBoundaryVertices.Add(new XY(1, 0));
RasterImage raster = new RasterImage(definition);
raster.Flags = ImageDisplayFlags.ShowImage;

raster.ClipType = ClipType.Rectangular;
raster.ClipBoundaryVertices.Add(new XY(0, 0));
raster.ClipBoundaryVertices.Add(new XY(1, 1));

@thaiguer
Copy link
Contributor Author

After 05515c9, this is the result:

: _RECOVER
Recover .dwg file.
Name: .dwg file
Value: Object improperly read: <AcDbRasterImage> (3D)
 Previous error: .dwg file needs recovery
Replaced by: Removed

Total errors found during recover: 1.
Audit recovered Database.
Name: Database header
Value: System Variable "TILEMODELIGHTSYNCH"
Validation: Not 0..1
Replaced by: Set to 1

Name: AcDbTextStyleTableRecord(12)
Value: Is externally dependent on an Xref, but Xref BlockRecord ((4))
Validation: Invalid
Replaced by: Removed dependence

67 objects audited
Total errors found during audit 3, fixed 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working code refactoring Improvements in the existing code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System variables defaults and ranges

2 participants