Message 1 of 3
Read xref layer color overrides in model space
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to get the model space layer colors for external references.
I have a model.dwg with an xref.dwg linked, where xref.dwg has a layer called "layer123" which is set to color 9.
If I open the model.dwg in AutoCAD I can see that xref|layer123 has a color override set to 255, 128, 128, but when I look at the layer from the API LayerTableRecord.Color returns the original xref color (ByAci / ACI 9 / RGB 192,192,192).
I've checked these system variables if that matters and the values are:
VISRETAIN = 1
VISRETAINMODE = 0
XREFOVERRIDE = 0
Here's a shortened version of my code:
I'm reading model.dwg as a side db
using (var sideDb = new Database(false, true))
{
sideDb.ReadDwgFile(sideDbPath, FileOpenMode.OpenForReadAndAllShare, false, null);
sideDb.ResolveXrefs(true, false);
message.FileContents.Layers = LayerHandler.GetLayers(sideDb);
}
internal static void GetLayers(Database db)
{
using (Transaction transaction = db.TransactionManager.StartTransaction())
{
var layerTable = transaction.GetObject(db.LayerTableId, OpenMode.ForRead) as LayerTable;
foreach (var layObj in layerTable)
{
var lay = layObj.GetObject(OpenMode.ForRead) as LayerTableRecord;
var color = lay.Color;
// do stuff...
}
transaction.Dispose();
}
}
Am I missing something?