Community
Can a hatch pattern be exploded. The hatch pattern does not have an option to explode
Public Sub explode(doc As Document, db As Database, ed As Editor)
Try
Dim explodecount As Integer = 0
Dim objs As DBObjectCollection = New DBObjectCollection()
Using lk As DocumentLock = doc.LockDocument()
Using tr As Transaction = db.TransactionManager.StartTransaction()
Dim bt As BlockTable = TryCast(tr.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
Dim modelBtr As BlockTableRecord = tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForRead)
For Each id As ObjectId In modelBtr
If id.ObjectClass.Name = "AcDbBlockReference" Or id.ObjectClass.Name = "AcDbHatch" Then
Dim br
If id.ObjectClass.Name = "AcDbBlockReference" Then
br = CType(tr.GetObject(id, OpenMode.ForRead), BlockReference)
br.ExplodeToOwnerSpace()
Else
br = CType(tr.GetObject(id, OpenMode.ForRead), Hatch)
End If
Dim ent As Entity = DirectCast(tr.GetObject(id, OpenMode.ForRead, False), Entity)
br.UpgradeOpen()
br.Erase()
br.DowngradeOpen()
explodecount += 1
End If
Next
tr.Commit()
End Using
End Using
Catch ex As Exception
End Try
End Sub
Hi,
The Entity class provides an Explode method which can be used by any instance of a class deriving from Entity.
You can define your own ExplodetoOwnerSpace for Hatch (or other types of Entity).
private static void ExplodeToOwnerSpace(Hatch hatch, Transaction tr)
{
var ownerSpace = (BlockTableRecord)tr.GetObject(hatch.OwnerId, OpenMode.ForWrite);
var entitySet = new DBObjectCollection();
hatch.Explode(entitySet);
foreach (Entity entity in entitySet)
{
ownerSpace.AppendEntity(entity);
tr.AddNewlyCreatedDBObject(entity, true);
}
}
Can't find what you're looking for? Ask the community or share your knowledge.