.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problems to delete layer entities

3 REPLIES 3
Reply
Message 1 of 4
everts
670 Views, 3 Replies

Problems to delete layer entities

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) { ;}
}
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: everts

For future reference, many here that use newsreaders
cannot easily look at code posted via the web, with or
without the code tags.

My advice is if you want the most possible responses,
that you attach your code in a .txt file.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm


wrote in message news:6146620@discussion.autodesk.com...
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) { ;} }
Message 3 of 4
everts
in reply to: everts

ok mr.Tanzillo , my appologies. It just i did not know how to format the code here. Here is the text file containing the code. Thanks. By the way, I am using a hyperlink because I dont know how to attach files 😞
[Code for deleting entities|http://everts.comuv.com/public/code.zip]
Message 4 of 4
everts
in reply to: everts

I was able to solve the problem by adapting the code from Kean Walmsley at the following link [http://through-the-interface.typepad.com/through_the_interface/2007/08/moving-entities.html|http://through-the-interface.typepad.com/through_the_interface/2007/08/moving-entities.html]

Thanks everybody

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost