.NET

Reply
Valued Mentor
AubelecBE
Posts: 394
Registered: ‎01-27-2010
Message 1 of 3 (531 Views)
Accepted Solution

How to remove entity from BlockTableRecord ?

531 Views, 2 Replies
02-23-2012 05:23 AM
....
'Gestion Bloc en mémoire
            Dim BlocSpace As BlockTable         'Coll des BlockDef en ModelSpace
            Dim BlocDef As BlockTableRecord     'Def du bloc
            Try
                tr = db.TransactionManager.StartTransaction()

                BlocSpace = tr.GetObject(db.BlockTableId, OpenMode.ForRead)
                If BlocSpace.Has(Tableau.NomBlocDessin) = False Then
                    'création d'un nouveau Def
                    BlocDef = New BlockTableRecord
                    BlocDef.Name = Tableau.NomBlocDessin
                    'Open.ForWrite
                    BlocSpace.UpgradeOpen()
                    'Ajout à la base et mémorisation de l'ID pour l'add sur le dessin
                    ' blocref = new blockreference(point3d,id)
                    Dim BlocDefId As ObjectId = BlocSpace.Add(BlocDef)
                    'Ajout au dessin
                    tr.AddNewlyCreatedDBObject(BlocDef, True)
                Else
                    'récupération de la def.
                    BlocDef = tr.GetObject(BlocSpace.Item(Tableau.NomBlocDessin), OpenMode.ForWrite)
                    'suppression de tous les élements dans la def.
                End If
            Catch ex As Exception
                MsgBox(ex.ToString, vbOKOnly, "Erreur système dans ClassFichier.CréationTableau")

            Finally
                tr.Commit()
                tr.Dispose()
            End Try
....

 

now i have a BlockTableRecord in car BlocDef.

How i can delete all entity in this ?

I want to create a new order in the blocdef but i dont want delete the Blockreference. so i dont 'purge'

 

Thx.

Hi,

You can iterate the BlockTableRecord, open each entity and erase it.

 

Salut,

Tu peux parcourir le BloctTableRecord ouvrir chaque entité et l'effacer.

 

foreach (ObjectId id in BlocDef)

{

    Entity ent = (Entity)tr.GetObject(id, OpenMode.ForWrite);

    ent.erase();

}

*Expert Elite*
_gile
Posts: 2,114
Registered: ‎04-29-2006
Message 2 of 3 (525 Views)

Re : How to remove entity from BlockTableRecord ?

02-23-2012 05:45 AM in reply to: AubelecBE

Hi,

You can iterate the BlockTableRecord, open each entity and erase it.

 

Salut,

Tu peux parcourir le BloctTableRecord ouvrir chaque entité et l'effacer.

 

foreach (ObjectId id in BlocDef)

{

    Entity ent = (Entity)tr.GetObject(id, OpenMode.ForWrite);

    ent.erase();

}

Gilles Chanteau
Valued Mentor
AubelecBE
Posts: 394
Registered: ‎01-27-2010
Message 3 of 3 (511 Views)

Re : How to remove entity from BlockTableRecord ?

02-23-2012 07:31 AM in reply to: _gile

ah ok Thanks i have to try it tomorrow.

 

If i delete all BlockReference and purge the DefBloc: it is much fast no ?

 

 

 

 

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!