Класс для работы со слоем в Autocad .NET API
if (this.description != null)
{
layerTableRecord.Description = this.description;
}
if (this.transparency != null)
{
layerTableRecord.Transparency = this.transparency;
}
if (this.linetype != null)
{
layerTableRecord.LinetypeObjectId = this.linetype;
}
transaction.AddNewlyCreatedDBObject(layerTableRecord, true);
}
transaction.Commit();
return true;
}
}
return false;
}
/// <summary>
/// Установить цвет слоя из палитры ARGB (графический интерфейс GDI+).
/// </summary>
/// <param name=»color»></param>
/// <returns></returns>
public Layer SetColor(System.Drawing.Color color)
{
this.color = Color.FromColor(color);
return this;
}
/// <summary>
/// Установить цвет слоя из палитры ARGB (приложения WPF).
/// </summary>
/// <param name=»color»></param>
/// <returns></returns>
public Layer SetColor(System.Windows.Media.Color color)
{
this.color = Color.FromColor(color);
return this;
}
/// <summary>
/// Установить цвет слоя из числового индекса.
/// </summary>
/// <param name=»colorIndex»></param>
/// <returns></returns>
public Layer SetColorFromIndex(short colorIndex)
{
this.color = Color.FromColorIndex(ColorMethod.ByLayer, colorIndex);
return this;
}
/// <summary>
/// Установить цвет слоя из цветовой палитры RGB.
/// </summary>
/// <param name=»red»></param>
/// <param name=»green»></param>
/// <param name=»blue»></param>
/// <returns></returns>
public Layer SetColorFromRgb(byte red, byte green, byte blue)
{
this.color = Color.FromRgb(red, green, blue);
return this;
}
/// <summary>
/// Установить описание слоя.
/// </summary>
/// <param name=»description»></param>
/// <returns></returns>
public Layer SetDescription(string description)
{
this.description = description;
return this;
}
/// <summary>
/// Установить вес линии.
/// </summary>
/// <param name=»lineWeight»></param>
/// <returns></returns>
public Layer SetLineWeight(LineWeight lineWeight = LineWeight.ByLineWeightDefault)
{
this.lineWeight = lineWeight;
return this;
}
/// <summary>
/// Установить прозрачность слоя от 0 до 90.
/// </summary>
/// <param name=»transparency»></param>
/// <returns></returns>
public Layer SetTransparency(byte transparency)
{
Byte alpha = (Byte)(255 * (100 — transparency) / 100);
this.transparency = new Transparency(alpha);
return this;
}
/// <summary>
/// Установить тип линии.
/// </summary>
/// <param name=»nameLinetype»></param>
/// <returns></returns>
public Layer SetLinetype(string nameLinetype)
{
LinetypeTable linetypeTable;
using (linetypeTable = Database.LinetypeTableId.GetObject(OpenMode.ForRead) as LinetypeTable)
{
if (linetypeTable.Has(nameLinetype) == true)
{
this.linetype = linetypeTable[nameLinetype];
}
}
return this;
}