vb.net - delete all entities ?

vb.net - delete all entities ?

jan_tappenbeck
Collaborator Collaborator
767 Views
1 Reply
Message 1 of 2

vb.net - delete all entities ?

jan_tappenbeck
Collaborator
Collaborator

HI !

 

could someone tell me how to delete all entities in the modellspace ?

 

reagards Jan

0 Likes
768 Views
1 Reply
Reply (1)
Message 2 of 2

norman.yuan
Mentor
Mentor

Only saying VB.NET does not provide enough details/information for others to help. Which API do you want to use (COM or .NET), what context the actual deleting code you are going to put into (i.e. do you know how to make the code work if a few line of COM or .NET code is provided)? Anyway, here is afew line of code using .NET API

 

Public Sub DleteleEntitiesInModel(Document dwg)

  

  Using tran As Transaction=dwg.StartTransaction() 

    ObjectId spaceId=SymbolUtilityServices.GetBlockModelSpaceId(dwg.Database)

    Dim space As BlockTableRecord = DirectCast( _

      tran.GetObject(spaceId, OpenMode.ForRead), BlockTableRecord)

    For Each id As ObjectId in space

      Dim ent As Entity=DirectCast(tran.GetObject(id, OpenMode.ForWrite), Entity)

      ent.Erase()

    Next

    tran.Commit();

  End Using

 

End Sub

 

Assume you know how to incorporate into your application project

Norman Yuan

Drive CAD With Code

EESignature