Community
I make a loop To choose layer. Each time I select a layer, fade it out.
At first I changed the Transparency. It takes too much time running program.
Next I set layer's IsLocked, but I can't see the effect.
Is there any other way to do that?
the code below is my attempt of lock.
private void PickLayer(Dictionary<string, ObjectId> data)
{
Document doc = Common.GetActiveWindowDoc();
Editor ed = doc.Editor;
Database db = doc.Database;
this.Hide();
while (true)
{
PromptEntityOptions peo = new PromptEntityOptions("select layer");
PromptEntityResult per = ed.GetEntity(peo);
if (per.Status != PromptStatus.OK)
{
Common.Alert("quit");
break;
}
using (var lck = doc.LockDocument())
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
Entity ent = (Entity)per.ObjectId.GetObject(OpenMode.ForRead);
LayerTableRecord layerTR = (LayerTableRecord)ent.LayerId.GetObject(OpenMode.ForWrite);
TypedValue[] typedValues = { new TypedValue((int)DxfCode.LayerName, layerTR.Name) };
SelectionFilter filter = new SelectionFilter(typedValues);
if (!data.ContainsKey(layerTR.Name))
{
layerTR.IsLocked = true;
//layerTR.EntityColor =
layerTR.DowngradeOpen();
ed.Regen();
Common.Alert("add data:" + layerTR.Name);
data.Add(layerTR.Name, layerTR.Id);
}
tr.Commit();
}
}
}
//
this.Show();
//unlock
if (data.Any())
{
try
{
foreach (var item in data)
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
using (var lck = doc.LockDocument())
{
LayerTableRecord layerTR = (LayerTableRecord)item.Value.GetObject(OpenMode.ForRead);
layerTR.UpgradeOpen();
layerTR.IsLocked = false;
layerTR.DowngradeOpen();
ed.Regen();
Common.Alert(layerTR.Name + "unlock");
}
tr.Commit();
}
}
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
This may be a stupid proposal, but... What about changing the layer color (or it's entities) to a darker color?
amanero, I am not an expert by any means, but I think your idea is brilliant. If you take a layer color and multiply its RGB values by about 1/2, you will get a similar result. This will help me, thanks.
Can't find what you're looking for? Ask the community or share your knowledge.