I recently worked on a project, where I need to get access to layer's description and based on the formatted description value to do something.
In AutoCAD's Layer Manager's view, the last column displays layer description. Of course the description is stored as LayerTableRecord.Description property. So, pretty simple, eh? Wrong. it is not as simple as it looks.
Whenever a new layer is created, a default description, which is the same as the layer name, is set, the Layer Manager shows. Also, if one tries to clear the description, the Layer Manager simply restores it back with the layer's name.
However, when trying to use code to access LayerTableRecord.Description property, it returns empty (String.Empty).
That means, the default layer description appearing in Layer Manager looks just displayed by Layer Manager if the description is not set explicitly. If we edit the layer description in the Layer Manager, then, yes, the description will be assigned to the layer (LayerTableRecord) with one exception: you cannot edit the description as the same as the layer name (i.e. you clear the appeared "fake" layer description, and then enter the layer name as the description), the description in LayerTableRecord remains empty.
However, you can use code to set LayerTableRecord.Description with the same text value as layer name (i.e. LayerTableRecord.Description property can be set via code to whatever value you want); or, in Layer Manager, you can first set the description to nay value other than empty text or layer name, then again you can set it back to the layer name. This time, the displayed description (the same as layer name) is really assigned to the LayerTableRecord.Descriotion property, not a "fake" value made up by Layer Manager.
So, I'd consider this is a bug of Layer Manager: if AutoCAD wants to give a layer a default description when a new layer is created, it should do so, not left it empty; and if the Description property is empty, the Layer Manager should leave it alone, not display a fake, misleading value.
However, by Layer Manager, I mean the "newer" paletteset style, floating window version (since AutoCAD 2009, I think). If open the old "Layer Properties Manager" modal dialog box (with "LayerDlgMode" system variable set to 0), the description in the dialog box is displayed correctly (emtpy) when a new layer is created. This convinces me that the issue I described here is a bug of Layer Manager (since AutoCAD 2009!).
No comments:
Post a Comment