.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Qleader Settings

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
e.g.
724 Views, 5 Replies

Qleader Settings

Hi,

 

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,

 

e.g.

5 REPLIES 5
Message 2 of 6
khoa.ho
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.

 

-Khoa

Message 3 of 6
Hallex
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)
                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

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 4 of 6
e.g.
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"?

 

Thanks,

 

e.g.

Message 5 of 6
e.g.
in reply to: e.g.

Hi Hallex,

 

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

 

Thanks,

 

e.g.

Message 6 of 6
Hallex
in reply to: e.g.

Glad you solved it by yourself

Happy coding

Cheers Smiley Happy

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost