Imports ZwSoft.ZwCAD.Runtime
Imports ZwSoft.ZwCAD.ApplicationServices
Imports ZwSoft.ZwCAD.DatabaseServices
Imports ZwSoft.ZwCAD.EditorInput
Public Class ZwcadApp
<CommandMethod("test")> _
Public Sub test()
Dim ZcDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim ZcDB As Database = ZcDoc.Database
Dim ZcEd As Editor = ZcDoc.Editor
Using ZcTrans As Transaction = ZcDB.TransactionManager.StartTransaction()
Dim ZcBT As BlockTable = ZcTrans.GetObject(ZcDB.BlockTableId, OpenMode.ForWrite)
If ZcBT.Has("testA") And ZcBT.Has("testB") Then
Dim ZcBLTRa As BlockTableRecord = ZcTrans.GetObject(ZcBT("testA"), OpenMode.ForWrite)
Dim brf As BlockReference = New BlockReference(ZcBLTRa.Origin, ZcBLTRa.ObjectId)
Dim ZcBTR As BlockTableRecord = DirectCast(ZcTrans.GetObject(ZcBT(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
ZcBTR.AppendEntity(brf)
ZcTrans.AddNewlyCreatedDBObject(brf, True)
Dim ent As Entity = DirectCast(brf, Entity).Clone()
Dim ZcBLTRb As BlockTableRecord = ZcTrans.GetObject(ZcBT("testB"), OpenMode.ForWrite)
ZcBLTRb.AppendEntity(ent)
ZcTrans.AddNewlyCreatedDBObject(ent, True)
Dim newBrf As BlockReference = New BlockReference(ZcBLTRb.Origin, ZcBLTRb.ObjectId)
ZcBTR.AppendEntity(newBrf)
ZcTrans.AddNewlyCreatedDBObject(newBrf, True)
brf.Erase()
Else
ZcEd.WriteMessage(vbLf & "A block with this name doesn't exist.")
End If
ZcTrans.Commit()
End Using
End Sub
End Class
Imports ZwSoft.ZwCAD.ApplicationServices
Imports ZwSoft.ZwCAD.DatabaseServices
Imports ZwSoft.ZwCAD.EditorInput
Public Class ZwcadApp
<CommandMethod("test")> _
Public Sub test()
Dim ZcDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim ZcDB As Database = ZcDoc.Database
Dim ZcEd As Editor = ZcDoc.Editor
Using ZcTrans As Transaction = ZcDB.TransactionManager.StartTransaction()
Dim ZcBT As BlockTable = ZcTrans.GetObject(ZcDB.BlockTableId, OpenMode.ForWrite)
If ZcBT.Has("testA") And ZcBT.Has("testB") Then
Dim ZcBLTRa As BlockTableRecord = ZcTrans.GetObject(ZcBT("testA"), OpenMode.ForWrite)
Dim brf As BlockReference = New BlockReference(ZcBLTRa.Origin, ZcBLTRa.ObjectId)
Dim ZcBTR As BlockTableRecord = DirectCast(ZcTrans.GetObject(ZcBT(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
ZcBTR.AppendEntity(brf)
ZcTrans.AddNewlyCreatedDBObject(brf, True)
Dim ent As Entity = DirectCast(brf, Entity).Clone()
Dim ZcBLTRb As BlockTableRecord = ZcTrans.GetObject(ZcBT("testB"), OpenMode.ForWrite)
ZcBLTRb.AppendEntity(ent)
ZcTrans.AddNewlyCreatedDBObject(ent, True)
Dim newBrf As BlockReference = New BlockReference(ZcBLTRb.Origin, ZcBLTRb.ObjectId)
ZcBTR.AppendEntity(newBrf)
ZcTrans.AddNewlyCreatedDBObject(newBrf, True)
brf.Erase()
Else
ZcEd.WriteMessage(vbLf & "A block with this name doesn't exist.")
End If
ZcTrans.Commit()
End Using
End Sub
End Class