Removal of 'processing sequences'?

1
Aluro
4/13/2022 11:12 AM

Hi,

When processing text data from a table I noticed additional characters, which are documented here: https://www.woutware.com/doc/cadlib4.0/html/cacc57fe-a291-d8e2-c22f-002620683c8a.htm (https://www.woutware.com/Forum/Topic/1083)

Does CadLib provide a utility to strip string's of these "processing sequences"?
Some examples of the raw string values and what I'm actually expecting:

"{\\C256;8000}" -> "8000"
"{\\C256;\\c16777215;50}" -> "50"
"False{\\C240;\\c2367469; }" -> "False"

Thank you.

Wout
4/13/2022 11:18 AM

Hi,

You can use the DxfMText.SimplifiedText property.

- Wout

Aluro
4/13/2022 11:24 AM

Hi Wout,

What is the equivalent for the DxfTableCellContent type?

Wout
4/13/2022 11:47 AM

Hi,

There is currently now convenient way of getting the SimplifiedText from the table cell content text. But you can create a temporary DxfMText object and get it from there.

- Wout

Aluro
4/13/2022 12:09 PM

Hi Wout,

If I try to go through a new DxfMText instance I get an object null reference exception when accessing the simplified text property.

C# Code:
        private static (string key, string value) GetKeyValueFromRow(DxfTableRow row)
        {
            var keyCellContent = row.Cells.ElementAtOrDefault(0)?.Contents?.ElementAtOrDefault(0);
            var valueCellContent = row.Cells.ElementAtOrDefault(1)?.Contents?.ElementAtOrDefault(0);

            var key = keyCellContent?.Value?.GetValueString(DxfValueFormat.GeneralInstance)?.ToLowerInvariant().Trim();
            if (string.IsNullOrWhiteSpace(key)) return (null, null);

            var value = valueCellContent?.Value?.GetValueString(DxfValueFormat.GeneralInstance) ?? string.Empty;

            // Get rid of procesing sequences
            var mText = new DxfMText { Text = value };
            value = mText.SimplifiedText; // Object null reference exception

            return (key, value);
        }

Wout
4/13/2022 12:20 PM

Hi,

You'll have to temporarily make it part of the model unfortunately. You can make some temporary DxfBlock, add it to model.Blocks, and add the mtext to the DxfBlock.Entities.

- Wout

Wout
4/13/2022 12:35 PM

Which version of CadLib are you using? 4/5/6? Evaluation version? I've added a new method to simplify this, but I need to know which CadLib version to compile.

- Wout

Aluro
4/14/2022 10:25 AM

Hi Wout,

I'm currently running the CadLib 5 evaluation but will migrate to a CadLib 6 evaluation as the final project will be based on the .NET 6 platform.

Wout
4/14/2022 10:52 AM

Hi,

I've added a static method DxfMText.GetSimplifiedText(DxfModel model, string s), to get the simplified text in an easier way to CadLib 5.0.

Note that the windows version of CadLib 6.0 is not yet ready, but will be soon. The current 6.0 version is multi-platform, and is priced higher than the windows version.

- Wout

Aluro
4/14/2022 12:03 PM

Hi Wout,

The static method works great, thanks.

1