I need some help, I am struggling to find how to adjust the Qleader Settings(ex. to set the points number to unlimited, etc). Can someone point me in the right direction?
Thank you very much,
Solved! Go to Solution.
Like you, I still don't know how to adjust fully the QLeader Settings, some properties are still missing and do not expose on the .NET API. In fact QLeader is a composite object containing a Solid (for arrow head), a Polyline (for leader line) and an MText (for leader text). When we declare a new Leader() object with some initialized properties, there is no property said NumberOfPoints. However, this number of points is the property NumberOfVertices of Polyline class. So the API does not expose this property on Leader and MLeader classes.
There are also some other missing properties of QLeader Settings on Leader and MLeader classes. I think the API might not consider all properties of a composite entity like Leader/MLeader.
You could be able to specify points dynamically
Try this quick code example
(tested on A2010 only)
<CommandMethod("drl")> _ Public Sub DrawLeaderTest() Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.D
ocumentManager.MdiActiveDocument Dim ed As Editor = doc.Editor Dim db As Database = doc.Database 'start a transaction Using tr As Transaction = db.TransactionManager.StartTransaction() Dim btr As BlockTableRecord = DirectCast(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite, False), BlockTableRecord) Try Dim pts As New Point3dCollection() Dim opts As New PromptPointOptions(vbLf & "Pick leader arrow point: ") opts.AllowArbitraryInput = True opts.AllowNone = True opts.UseBasePoint = False opts.UseDashedLine = True Dim dp As New Point3d(Double.NegativeInfinity, 0, 0) While True If Not Double.IsNegativeInfinity(dp.X) Then opts.UseBasePoint = True opts.BasePoint = dp End If Dim res As PromptPointResult = ed.GetPoint(opts) If res.Status = PromptStatus.OK Then pts.Add(res.Value) dp = res.Value Else Exit While End If opts.Message = vbLf & "Next leader point or (Enter to exit): " End While Dim mtx As New MText() mtx.SetDatabaseDefaults() mtx.Contents = "Put your annotation\Ptext here." mtx.Normal = Vector3d.ZAxis mtx.Location = pts(pts.Count - 1) Dim mtxId As ObjectId = btr.AppendEntity(mtx) tr.AddNewlyCreatedDBObject(mtx, True) Dim leader As New Leader() leader.SetDatabaseDefaults() For Each p As Point3d In pts leader.AppendVertex(p) Next Dim leaderId As ObjectId = btr.AppendEntity(leader) tr.AddNewlyCreatedDBObject(leader, True) leader.Annotation = mtxId tr.Commit() Catch ex As System.Exception ed.WriteMessage(Environment.NewLine & ex.ToString()) End Try End Using End Sub
thank you for you answer, yes it does the trick for me, instead of trying to modify the settings, I can have a custom command to create the leader.
Though, I have one more question: I am using the command through a viewport that sometimes has a different annotation scale: what will be the best aproach to use the current viewport annotation scale? Just read the variable "CANNOSCALE"?
Start with some of our most frequented solutions to get help installing your software.