Try this simple example
Btw, did you tryed to search for an answer on this forum?
{code}
Imports System
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
< commandclass="">
Namespace BlockTools
Public Class BlockCommands
Public Shared Sub AddBlock(ByVal bname As String)
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Using doclock As DocumentLock = doc.LockDocument()
Using tr As Transaction = db.TransactionManager.StartTransaction()
Dim bt As BlockTable = CType(tr.GetObject(db.BlockTableId, OpenMode.ForWrite, False), BlockTable)
Dim btr As New BlockTableRecord
btr.Name = bname
btr.Origin = New Point3d(0, 0, 0)
bt.Add(btr)
tr.AddNewlyCreatedDBObject(btr, True)
Dim circle As New Circle(New Point3d(0, 0, 0), New Vector3d(0, 0, 1), 1.0)
btr.AppendEntity(circle)
tr.AddNewlyCreatedDBObject(circle, True)
Dim text As New DBText
text.Position = New Point3d(0, 1.1, 0)
text.TextString = "text above circle"
text.HorizontalMode = TextHorizontalMode.TextMid
text.VerticalMode = TextVerticalMode.TextBottom
text.AlignmentPoint = New Point3d(0, 1.1, 0)
text.AdjustAlignment(db)
btr.AppendEntity(text)
tr.AddNewlyCreatedDBObject(text, True)
tr.Commit()
End Using
End Using
End Sub
_
Public Shared Sub CreateBlock()
AddBlock("MyCoolBlock")
End Sub
End Class
End Namespace
{code}
~'J'~>
_____________________________________
C6309D9E0751D165D0934D0621DFF27919