Message 1 of 4
Problems to delete layer entities
Not applicable
03-22-2009
10:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hello everyone, I made an app in C# to draw boring (soil exploration) graphics, well, it was made to Land 06, but now, we want to use it in Civil 3d 09, but I encountered several compatibility problems in the code. That is, the code used for deleting entities on determinated layer does not work now, but thats not the only code that is not working, also the code for delete layer, code for hiding the layer, code for showing the layer and so on. So, I was wondering if you guys can help me with this problem.
Here is the code used for deleting entities (works fine in Land06):
public void DeleteLayerEntities(string layer)
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
Transaction tr = db.TransactionManager.StartTransaction();
TypedValue[] tV = new TypedValue[1];
tV[0] = new TypedValue((int)DxfCode.LayerName, layer);
SelectionFilter selectionFilter = new SelectionFilter(tV);
PromptSelectionResult promptSelectionResult
= ed.SelectAll(selectionFilter);
try
{
DocumentLock mLock = Application.DocumentManager.MdiActiveDocument.LockDocument();
foreach (ObjectId id in promptSelectionResult.Value.GetObjectIds())
{
Entity entity = (Entity)tr.GetObject(id, OpenMode.ForWrite);
entity.UpgradeOpen();
entity.Erase();
entity.Dispose();
}
UpdateScreen();
mLock.Dispose();
tr.Commit();
}
catch (System.NullReferenceException) { ;}
}
Here is the code used for deleting entities (works fine in Land06):
public void DeleteLayerEntities(string layer)
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
Transaction tr = db.TransactionManager.StartTransaction();
TypedValue[] tV = new TypedValue[1];
tV[0] = new TypedValue((int)DxfCode.LayerName, layer);
SelectionFilter selectionFilter = new SelectionFilter(tV);
PromptSelectionResult promptSelectionResult
= ed.SelectAll(selectionFilter);
try
{
DocumentLock mLock = Application.DocumentManager.MdiActiveDocument.LockDocument();
foreach (ObjectId id in promptSelectionResult.Value.GetObjectIds())
{
Entity entity = (Entity)tr.GetObject(id, OpenMode.ForWrite);
entity.UpgradeOpen();
entity.Erase();
entity.Dispose();
}
UpdateScreen();
mLock.Dispose();
tr.Commit();
}
catch (System.NullReferenceException) { ;}
}