Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

"Description" value of layer #331

Open
pmorshed opened this issue Nov 11, 2021 · 4 comments
Open

"Description" value of layer #331

pmorshed opened this issue Nov 11, 2021 · 4 comments

Comments

@pmorshed
Copy link

pmorshed commented Nov 11, 2021

Hi. How can i get "description" property for a layer?!
netDxf.Tables.Layer class doesn't contain the "Description"..
layer desc

The "Description" field is very useful because special characters ( <>/?":;*|,=` ) are allowed in it.

@haplokuon
Copy link
Owner

In the official DXF documentation there is no code for the layer description, but after checking if that value was really stored in the DXF, I found that it really does but in the extended data information. Another example of Autodesk at its best, they had to choose the worst way of saving a simple string. Why not do the same as the line type or the block which descriptions are saved under a code 3 and 4 respectively?

At the moment if you need the description you will have to read it manually from the XData.

@pmorshed
Copy link
Author

Thanks
How can i read it from XData? Do you have an example?

@haplokuon
Copy link
Owner

haplokuon commented Nov 16, 2021

DxfDocument doc = DxfDocument.Load("Drawing1.dxf");
Layer layer = doc.Layers["Layer1"];
// Get the extended data information,
// how and where the layer description is stored is undocumented, proceed with care
// the layer description is saved as extended data information associated to an ApplicationRegistry called "AcAecLayerStandard"
string layerDescription;
XData xData = layer.XData["AcAecLayerStandard"];
foreach (XDataRecord data in xData.XDataRecord)
{
	// looks like it just stores two string values under a code 1000
	// the first one seems to be always empty, I do not know if it is there just to waste space
	// or it is actually used for something else from who knows where
	if (data.Code == XDataCode.String)
	{
		layerDescription = data.Value as string;
	}
}

If you need more detailed information about the extended data go to the AutoCad manual, you can start here.

@pmorshed
Copy link
Author

Many thanks. You’re awesome

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants