Message 1 of 2
Create a annotative mleader in vb.net
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to create a multileader vb.net. I am mostly successful except for two issues.
One, the text for the multileader is white instead of by layer. the color does change if I double click on the mtext to edit it.
Two the text does not add annotation scales. The arrow itself scales but not the text.
This is the code I am using:
Public Sub DrawLeader(ldrText As String, ldrRoatateRaw As Double, invLayer As String)
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim edt As Editor = doc.Editor
Dim mlIns As Point3d = edt.GetPoint(vbCrLf + "Select the Mleader insertion point: ").Value
Dim mlTIns As Point3d = edt.GetPoint(vbCrLf + "Select text insertion location: ").Value
Using trans As Transaction = db.TransactionManager.StartTransaction()
doc.LockDocument()
Try
Dim bt As BlockTable = trans.GetObject(db.BlockTableId, OpenMode.ForRead)
Dim btr As BlockTableRecord = trans.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
Dim dict As DBDictionary = db.MLeaderStyleDictionaryId.GetObject(OpenMode.ForRead)
Dim mlstyle As ObjectId = dict.GetAt("BA_EX_L90_Arrow")
Application.SetSystemVariable("TEXTSTYLE", "BA_EX_L90")
Dim mlText As New MText With
{.Contents = ldrText,
.Rotation = ldrRoatateRaw,
.TextStyleId = db.Textstyle
}
Using mldr As New MLeader
mldr.MLeaderStyle = mlstyle
Dim index As Integer = mldr.AddLeaderLine(New Point3d(0, 0, 0))
mldr.AddFirstVertex(index, mlIns)
mldr.Layer = invLayer
mldr.ContentType = ContentType.MTextContent
mldr.MText = mlText
mldr.TextLocation = mlTIns
mldr.Annotative = AnnotativeStates.True
btr.AppendEntity(mldr)
trans.AddNewlyCreatedDBObject(mldr, True)
End Using
trans.Commit()
doc.SendStringToExecute("regen", True, False, False)
Catch ex As Exception
edt.WriteMessage(vbCrLf + "Error encountered: " + ex.Message)
trans.Abort()
End Try
End Using
End Sub
The leader style is
And my Text Style is: