Thank you gile .
I am sorry I am a new with VB.net and C# .
I added your codes into the program but I failed . Can you please just include your codes in my prorgam ?
Public Class rocks
<CommandMethod("AddLine")>
Public Sub AddLine()
'' Get the current document and database
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
'' Start a transaction
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
'' Open the Block table for read
Dim acBlkTbl As BlockTable
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)
'' Open the Block table record Model space for write
Dim acBlkTblRec As BlockTableRecord
acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace),
OpenMode.ForWrite)
Dim acLine As Line = New Line(New Point3d(0, 0, 0), New Point3d(12, 3, 0))
acLine.SetDatabaseDefaults()
acLine.ColorIndex = 1
'acLine.Linetype =
acLine.LineWeight = LineWeight.LineWeight040
'' Add the new object to the block table record and the transaction
acBlkTblRec.AppendEntity(acLine)
acTrans.AddNewlyCreatedDBObject(acLine, True)
'' Save the new object to the database
acTrans.Commit()
End Using
End Sub
End Class
thank you very much.