Skip to content

Conversation

@bwright85428
Copy link
Contributor

Description

Implemented overrides for DimensionStyle in Dimension.cs

Related Issues / Pull Requests

Notes for reviewer

  • I created a new TestVariable that dumps all of the Dwg/Dxf files to a sub directory in single_cases. Will work on making these tests more specific, for instance angular precision on an angular dimension etc.

@DomCR DomCR added the enhancement New feature or request label Nov 28, 2025
case XDataValueKind.ZeroHandling:
return ZeroHandling.SuppressZeroFeetAndInches;
case XDataValueKind.LineType:
return ensureLineType(doc, "LT_TEST");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have to think about the best way to implement this, by now I leave some notes that I think it will help you to avoid code repetition.

The ensure methods could be replaced for Table.TryAdd it works in the same way and is directly implemented in all the tables.

private static string getDumpFolder()
{
var folder = Path.Combine(TestVariables.OutputSingleCasesFolder, "dim_style_overrides");
Directory.CreateDirectory(folder);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The folder creation should be initialized in TestSetup is it giving trouble in ryder?

}
}

public enum XDataValueKind
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This enum is repeated, DxfCode enum contains all this fields, look for ExtendedData at the end, starts with the value 1000.

You can also check the classes in XData folder for the dedicated classes for each type fo data.


namespace ACadSharp.Tables;

public sealed class DimensionStyleOverride
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the class DxfMap it creates this exact same structure and there is already methods to get and set the values for CadObjects.

/// </summary>
/// <param name="app">The AppId object.</param>
/// <param name="value">ExtendedData object.</param>
public bool TryGet(AppId app, out ExtendedData value)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point with this method, I would use directly the name such as:

return this.TryGet(app.Name, out value);

I see some other errors in this class like public void Add(AppId app, IEnumerable<ExtendedDataRecord> records) is not checking that the AppId is in the document.

@DomCR DomCR self-requested a review November 28, 2025 09:11
@DomCR
Copy link
Owner

DomCR commented Nov 28, 2025

Proposal for this implementation:

Dimension Methods:
Dimension.SetStyleOverride(DimensionStyle)
Method setps:

if style == null
//Remove Extended data entry DSTYLE
else
//1 Create DxfMap for dimstyle
DxfMap.Create<T>

//2 Compare Dimension.Style vs override style using DxfMap
foreach p in DxfMap.DxfProperties

if p.value(style) != p.value(override)
//Add to extended data
else
//continue

//End: have the edata updated using the dim override as a parameter

Dimension.GetStyleOverride(DimensionStyle)

Method setps:

if override == null => return null;
//Clone current style
//Map the properties from edata into a dxfmap
//override de edata values into the clone
return the clone

Let me know what you think about this approach.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants