Valued Contributor
Posts: 65
Registered: ‎07-23-2008
Message 1 of 6 (291 Views)
Accepted Solution

Qleader Settings

291 Views, 5 Replies
09-14-2012 07:49 AM



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,



Distinguished Contributor
Posts: 136
Registered: ‎09-15-2011
Message 2 of 6 (278 Views)

Re: Qleader Settings

09-14-2012 09:50 AM in reply to: e.g.

Hi e.g.


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.



*Expert Elite*
Posts: 1,558
Registered: ‎10-08-2008
Message 3 of 6 (264 Views)

Re: Qleader Settings

09-14-2012 12:30 PM in reply to: e.g.

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.DocumentManager.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)
                    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
                            dp = res.Value

                            Exit While
                        End If
                        opts.Message = vbLf & "Next leader point or (Enter to exit): "
                    End While
                    Dim mtx As New MText()


                    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()


                    For Each p As Point3d In pts
                    Dim leaderId As ObjectId = btr.AppendEntity(leader)

                    tr.AddNewlyCreatedDBObject(leader, True)

                    leader.Annotation = mtxId

                Catch ex As System.Exception
                    ed.WriteMessage(Environment.NewLine & ex.ToString())
                End Try
            End Using
        End Sub



Valued Contributor
Posts: 65
Registered: ‎07-23-2008
Message 4 of 6 (231 Views)

Re: Qleader Settings

09-17-2012 07:04 AM in reply to: Hallex

Hi Hallex,


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"?





Valued Contributor
Posts: 65
Registered: ‎07-23-2008
Message 5 of 6 (230 Views)

Re: Qleader Settings

09-17-2012 07:12 AM in reply to: e.g.

Hi Hallex,


yes, the leader.Annotative = AnnotativeStates.True does the trick.





*Expert Elite*
Posts: 1,558
Registered: ‎10-08-2008
Message 6 of 6 (206 Views)

Re: Qleader Settings

09-18-2012 01:23 AM in reply to: e.g.

Glad you solved it by yourself

Happy coding

Cheers :smileyhappy:




You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community