Too big constant width of LWPOLYLINE?

1
athenasoft
10/8/2021 7:05 AM

Hello. I'm using CadLib with version 4.0.38.241.
In attached DWG file while importing I'm encountering about a dozen LWPOLYLINE objects with enormous 'ConstantWidth'. It is about 100 times greater than size of ExtMin<->ExtMax of a project. Sample code below:

C# Code:
var dxfModel = CadReader.Read(nazwaPliku);
for (int i = 0; i < dxfModel.Entities.Count; ++i)
{
    if (dxfModel.Entities[i] is DxfLwPolyline lwp && lwp.ConstantWidth > 100)
    {
        [DEBUG BREAKPOINT]
    }
}

First entity that I catch in [DEBUG BREAKPOINT] section is with i=27.
Data of this entity (and project's ExtMin and ExtMax) below. It has ConstantWidth = 4404332.81522387 so much greater than size of whole project:

DxfModel.Header.ExtMin {-41472.8469696056, -6839.74222980124, -1333.79399999999}
DxfModel.Header.ExtMax {-13554.5156657688, 5999.60969772279, 666.896999999993}
lwp {Handle = 0x5D9F, Type = DxfLwPolyline}
lwp.ConstantWidth 4404332.81522387
lwp.InteractionControlPoints Count = 2{WW.Cad.Model.Entities.DxfLwPolyline.VertexCollection}
+ [0] {-16239.8595670281, -2023.74497757216, bulge = 1} WW.Cad.Model.Entities.DxfLwPolyline.Vertex
+ [1] {-16241.2358852444, -2017.28686901589, bulge = 1} WW.Cad.Model.Entities.DxfLwPolyline.Vertex

Is this a bug in CadLib or am I interpreting this property in a wrong way? Should it be ignored? Or whole object should be ignored? I can't see it in DWGTrueView viewer.

rammi
10/8/2021 8:57 AM

As you say first catch: are there more entities like that? If yes I'd consider it a bug in whatever tool created that DWG when writing that constant width. CadLib just follows what it reads.

What you can do to handle that file (eg display it): directly after loading the DxfModel go over all entities (there are also entities in the DxfModel.Blocks) and do a similar check like you did above (probably using the extension size instead of 100), and for each LWPOLYLINE which has too large width just set it to 0.0. Only then do further steps.

I don't think that CadLib could automate that for you as EXTMIN/EXTMAX or similar values are not always accurate, so depending on them could lead to false results.

- Rammi

Wout
10/8/2021 3:21 PM

Values seem correct to me, the actual extents of the drawing are much larger than what's written in the EXTMIN/EXTMAX values. They are not always accurate or useful.

- Wout

athenasoft
10/20/2021 12:23 PM

Those values are much bigger than real size of project. We decided to ignore those lines.

Wout
10/20/2021 12:44 PM

I had another look, I found another polyline with width 436937.7793, AutoCAD shows it having this width in the properties, so the value is definitely in the file. It looks like they're intended to be displayed as filled circles, which is commonly done using an LWPOLYLINE using 2 vertices with a bulge value of 1. Looks like someone just entered some random value or it was converted somehow from something else incorrectly. But whatever it is, CadLib reads the value correctly.

- Wout

athenasoft
10/20/2021 1:38 PM

You are right. I've found those filled circles on project. Currently we show them as empty circles with thin edge (I decided to make their edge thin instead of ignoring whole object). Now that I understand how this should work I can find better solution to show those object in our app. Thank you for having another look.

Tom

1