Public Sub RectangleAndSolid()
Dim Doc As Document = Application.DocumentManager.MdiActiveDocument
Dim CurDb As Database = Doc.Database
Using Trans As Transaction = CurDb.TransactionManager.StartTransaction()
Dim BlockObj As BlockTableRecord = New BlockTableRecord
BlockObj.Name = "Obrazec"
Dim blockTable As BlockTable = Trans.GetObject(CurDb.BlockTableId, OpenMode.ForRead)
If (blockTable.Has("Obrazec")) = False Then
With blockTable
.UpgradeOpen()
.Add(BlockObj)
End With
Trans.AddNewlyCreatedDBObject(BlockObj, True)
Dim SolidObj As Solid = New Solid(New Point3d(0, 2, 0), New Point3d(2, 2, 0), New Point3d(0, 0, 0), New Point3d(2, 0, 0))
BlockObj.AppendEntity(SolidObj)
Trans.AddNewlyCreatedDBObject(SolidObj, True)
End If
' ....................................................
Trans.Commit()
End Using
End Sub
Public Sub VstBk()
Dim Doc As Document = Application.DocumentManager.MdiActiveDocument
Dim CurDb As Database = Doc.Database
Dim PointP(0 To 2) As Double
Using Trans As Transaction = CurDb.TransactionManager.StartTransaction()
Dim KolBlock As BlockTableRecord = New BlockTableRecord
KolBlock.Name = "Scvajina"
Dim blockTable As BlockTable = Trans.GetObject(CurDb.BlockTableId, OpenMode.ForWrite)
blockTable.Add(KolBlock)
Trans.AddNewlyCreatedDBObject(KolBlock, True)
PointP(0) = PointP(0) + 2
PointP(1) = 0 - PointP(1) * 10
PointP(2) = 0
Dim BlockObj As BlockTableRecord = New BlockTableRecord
BlockObj.Name = "Obrazec"
Dim blockRef As BlockReference = New BlockReference(New Point3d(PointP), BlockObj.ObjectId)
BlockObj.AppendEntity(blockRef)
Trans.AddNewlyCreatedDBObject(blockRef, True)
Trans.Commit()
End Using
End Sub