- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am new to developing with this API but not to VB.NET. I am trying to associate mtext to a leader using the instructions in the AutoCAD .NET Developer's Guide (115) for AutoCAD 2012 but keep getting the eInvalidInput exception. One suggestion is that an exception is thrown if the mtext does not exist but I checked the mtext objectid for null and valid which returns good. I am certain that I am missing something but not sure what. I have included my source; the exception occurs at: acLdr.EvaluateLeader()
Thanks in Advance -Ken
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
Dim acBlkTbl As BlockTable
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)
Dim acBlkTblRec As BlockTableRecord
acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
'Create the MText annotation
Dim acMText As MText = New MText()
acMText.SetDatabaseDefaults()
acMText.Layer ="TEXT"
acMText.Contents = contents
'pt is a function that returns a Point3d(x, y, z) where z = 0
acMText.Location = pt(endPt.X + 2, endPt.Y + acMText.ActualHeight / 2)
acMText.Width = 70
'Add the new object to Model space and the transaction
acBlkTblRec.AppendEntity(acMText)
acTrans.AddNewlyCreatedDBObject(acMText, True)
'Create the leader
Dim acLdr As Leader = New Leader()
acLdr.SetDatabaseDefaults()
acLdr.Layer = "DIM"
acLdr.AppendVertex(startPt)
acLdr.AppendVertex(breakPt)
acLdr.AppendVertex(endPt)
acLdr.HasArrowHead = True
'Add the new object to Model space and the transaction
acBlkTblRec.AppendEntity(acLdr)
acTrans.AddNewlyCreatedDBObject(acLdr,True)
'Attach the annotation after the leader object is added
acLdr.Annotation = acMText.Object
acLdr.EvaluateLeader()
acTrans.Commit()
Solved! Go to Solution.