/// <summary>
/// Makes the layer, makes sure it's thawed and on
/// </summary>
/// <param name="layerName">Name of the layer.</param>
/// <param name="color">The color.</param>
/// <param name="print">whether or not the layer prints</param>
/// <returns>True if the layername is valid, false if it's not</returns>
public static bool MakeLayer(string layerName, short color=7, bool print = true)
{
if (Utililty.IsValidSymbolName(layerName))
{
using (Active.Document.LockDocument())
{
using (Transaction tr = Active.Document.TransactionManager.StartTransaction())
{
LayerTable layerTable = (LayerTable)tr.GetObject(Active.Database.LayerTableId, OpenMode.ForWrite);
if (!layerTable.Has(layerName))
{
LayerTableRecord newLayer
= new LayerTableRecord
{
Name = layerName,
Color = Color.FromColorIndex(ColorMethod.ByAci, color),
IsPlottable = print
};
layerTable.Add(newLayer);
tr.AddNewlyCreatedDBObject(newLayer, true);
}
else
{
// make sure it's thawed and on. (maybe we should unlock it?)
LayerTableRecord ltr = tr.GetObject(layerTable[layerName], OpenMode.ForWrite) as LayerTableRecord;
if (ltr != null)
{
if (ltr.IsFrozen) ltr.IsFrozen = false;
ltr.IsOff = false;
}
}
tr.Commit();
}//<-eInValidContext throws here
}
}
else
{
Active.WriteMessage("\nInvalid Layername: " + layerName);
}
return Utililty.IsValidSymbolName(layerName);
}