Community
Hi all,
I have problem. This is, when i create new layer for text, i have met one error. I hope everybody can help me. Thanks. And this is my code;
<CommandMethod("dd")> Public Sub DrawText() Dim doc As Document = Application.DocumentManager.MdiActiveDocument Dim db As Database = doc.Database Dim ed As Editor = doc.Editor ucs = ed.CurrentUserCoordinateSystem doc.LockDocument() ''Messenger select stone Dim pOption As New PromptPointOptions("") pOption.Message = vbLf & "Select Point:" Dim pResult As PromptPointResult = ed.GetPoint(pOption) doc.LockDocument() '' Start a transaction Using acTrants As Transaction = db.TransactionManager.StartTransaction() Dim acBlkTbl As BlockTable acBlkTbl = acTrants.GetObject(db.BlockTableId, _ OpenMode.ForRead) '' Open the Block table record Model space for write Dim acBlkTblRec As BlockTableRecord acBlkTblRec = acTrants.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _ OpenMode.ForWrite) ''Create a single-line text object Dim acText As DBText = New DBText() acText.SetDatabaseDefaults() acText.Position = New Point3d(0, 0, 0) acText.Height = 100 acText.TextString = "Cadviet" acText.Layer = "LTEXT" acText.WidthFactor = 0.8 acBlkTblRec.AppendEntity(acText) '' condition add floor acBlkTblRec.AppendEntity(acText) acTrants.AddNewlyCreatedDBObject(acText, True) acTrants.Commit() End Using
Error appear at this line->acText.Layer = "LTEXT"
Along with SENL1362 suggestions, remove the extra line from your code.
acBlkTblRec.AppendEntity(acText)'' condition add floor acBlkTblRec.AppendEntity(acText)