/// <summary>
/// The active
/// </summary>
private bool active = false;
/// <summary>
/// Inserts the block.
/// </summary>
/// <param name="name">The name.</param>
/// <returns></returns>
private async Task<bool> InsertBlock(string name)
{
//string layerName = Settings.Variables.CLAYER;
using (TemporarySystemVariables tsv
= new TemporarySystemVariables
() { }) {
//double scale = 1;
tsv.TEXTEVAL = true;
//scale = 1.0 / Db.Cannoscale.Scale;
using (Transaction trx = Doc.TransactionManager.StartTransaction())
{
if (DocData.LayerMap.ContainsKey(name))
{
string tempLayerName = DocData.LayerMap[name];
LayerTable lt = Db.LayerTable();
if (lt.Has(tempLayerName))
{
LayerTableRecord ltr = lt[tempLayerName].GetDBObject<LayerTableRecord>();
if (ltr.IsFrozen)
{
Application.ShowAlertDialog(String.Format("Unfreeze {0}", tempLayerName));
return false;
}
tsv.CLAYER = tempLayerName;
}
else if (DocData.StandardDwg.Layers.Has(tempLayerName))
{
DocData.StandardDwg.Layers.WblockCloneObject(tempLayerName);
tsv.CLAYER = tempLayerName;
}
}
trx.Commit();
}
try
{
Ed.InitCommandVersion(2);
active = true;
Application.PreTranslateMessage += Application_PreTranslateMessage;
await Ed.CommandAsync("_.-INSERT", name, Editor.PauseToken);
Application.PreTranslateMessage -= Application_PreTranslateMessage;
//if (active)
//{
// active = false;
//}
await Ed.CommandAsync(1);
while (Ed.IsDragging || Settings.Variables.CMDNAMES.ToUpper().IndexOf("INSERT", System.StringComparison.Ordinal) >= 0)
{
await Ed.CommandAsync(Editor.PauseToken);
}
}
catch (Autodesk.AutoCAD.Runtime.Exception ex)
{
if (ex.ErrorStatus != ErrorStatus.UserBreak)
{
throw;
}
Application.PreTranslateMessage -= Application_PreTranslateMessage;
return false;
}
}
return true;
}