Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
The code I'm using to insert my mleaders will add the mleader either pointing to the left or right. The problem is, when its pointing to the right, the text is still left justified within the bounding box.
Is there a way to set the mtext justification?
Public Sub AddMLeader2(ByVal ldrPnt1 As Point3d, ByVal ldrPnt2 As Point3d, ByVal ldrTextVal As String, _
ByVal ldrTextWidth As Double, ByVal dwgTextHeight As Double)
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Using mlTran As Transaction = db.TransactionManager.StartTransaction()
Dim blkTbl As BlockTable = TryCast(mlTran.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
Dim blkTblRec As BlockTableRecord = TryCast(mlTran.GetObject(blkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
Dim mldr As MLeader = New MLeader()
Dim mText As MText = New MText()
mldr.SetDatabaseDefaults()
' Creates a new leader cluster
Dim leaderNumber As Integer = mldr.AddLeader()
' Add a leader line to the cluster
Dim leaderLineNum As Integer = mldr.AddLeaderLine(leaderNumber)
mldr.AddFirstVertex(leaderLineNum, ldrPnt1)
mldr.AddLastVertex(leaderLineNum, ldrPnt2)
Dim direction As Double = 1.0
If (ldrPnt2 - ldrPnt1).DotProduct(Vector3d.XAxis) < 0.0 Then direction = -1.0
mldr.SetDogleg(leaderNumber, Vector3d.XAxis.MultiplyBy(direction))
mText.Width = ldrTextWidth
mText.Height = dwgTextHeight
mText.Contents = ldrTextVal
mldr.MText = mText
blkTblRec.UpgradeOpen()
blkTblRec.AppendEntity(mldr)
mlTran.AddNewlyCreatedDBObject(mldr, True)
mlTran.Commit()
End Using
End Sub
Thanks,
Mark
Solved! Go to Solution.