.NET

Reply
Contributor
FRFR1586
Posts: 11
Registered: ‎01-20-2014
Message 1 of 11 (361 Views)
Accepted Solution

annotative mleader problem

361 Views, 10 Replies
02-04-2014 09:50 AM

Hi everybody,

 

I have a problem about mtext textheight inside annotative mleader.

 

my software create a mleader object in the model space , this mleader use a mtext object

 

the mtext use the default textstyle

 

if , then creating the leader, the annotative scale of the model space is not 1:1 ,

the mtext textheight is autatcly divided by the annotative scale

(for example : original textheight=2.5, annotative scale=20 , after insertion the textheight is 0.125, exactly 2.5/20)

 

How can I create my mleader the the desired textheight ?

 

joined , you can find a sample of my project

 

regards

 

Luc

 

The mleader just uses the contents of the mtext or just just copies the contents.

To set the hieght use MLeader.TextHeight Property

 

Normally set it from its MleaderStyle.TextHeight

 Leader.TextHeight = 30

 instead of

mText.Height or TextHeight

 <CommandMethod("TST_L", CommandFlags.Modal)> _
Public Sub TST_L()
Dim Doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = Doc.Editor
Dim db As Database = ed.Document.Database
Dim Dl As Autodesk.AutoCAD.ApplicationServices.DocumentLock = Doc.LockDocument(Autodesk.AutoCAD.ApplicationServices.DocumentLockMode.ProtectedAutoWrite, "", "", False)
Using Dl
Dim tr As Transaction = db.TransactionManager.StartTransaction()
Dim btr As BlockTableRecord = DirectCast(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
Dim PtFleche As New Point3d(0, 0, 0)
Dim PtFleche2 As New Point3d(PtFleche.X + 4, PtFleche.Y + 4, PtFleche.Z)
Dim PtTexte As New Point3d(PtFleche.X + 8, PtFleche.Y + 6, PtFleche.Z)
Dim Leader As New MLeader
Leader.SetDatabaseDefaults()
Leader.ContentType = ContentType.MTextContent
'Leader.LayerId = CalqId
Leader.ArrowSize = 2.0
Leader.EnableDogleg = False
Dim idx As Integer = Leader.AddLeaderLine(PtFleche2)
Leader.AddFirstVertex(idx, PtFleche)
Leader.Annotative = AnnotativeStates.True
btr.AppendEntity(Leader)
tr.AddNewlyCreatedDBObject(Leader, True)
Using mText As New MText()
mText.Contents = "MyTexte"
Leader.MText = mText
End Using
Leader.TextHeight = 30
'Dim mlstyle As MLeaderStyle = Leader.MLeaderStyle.GetObject(OpenMode.ForRead)
'Leader.TextHeight = mlstyle.TextHeight
tr.Commit()
End Using
MsgBox("now change the annotation scale to 20 (for exemple)" & vbCrLf & _
"then restart the tst_l command" & vbCrLf & vbCrLf & _
"then look at the text height of the new leader" & vbCrLf & _
"it is le 20th of the previous one")
End Sub

 

 

 

 

 

 

Distinguished Contributor
CommCorp
Posts: 104
Registered: ‎03-19-2007
Message 2 of 11 (352 Views)

Re: annotative mleader problem

02-04-2014 10:51 AM in reply to: FRFR1586

I just went through adding mleaders myself and i think i can offer some suggestions.

 

Instead of "mText.Height = 30" try "mText.TextHeight = 30". I fell for that same trick and i think this will fix your problem.

 

Also, I had to attach the mtext to the mleader AFTER the mleader had been added to the modelspace, but this may have nothing to do with your issue. 

*Expert Elite*
JoAnn_Hogan
Posts: 529
Registered: ‎06-25-2012
Message 3 of 11 (344 Views)

Re: annotative mleader problem

02-04-2014 11:37 AM in reply to: CommCorp

HI There,

 

The idea of using annotative text is for viewports. Now if your text height in Model Space is for example 3mm, and you have 4 viewports with different scales, your text height in paper space will remain 3mm even if you have different scales.

 

 

If this post solved your issue please mark as solved and Kudos are always welcome =)

Jo - Ann
Twitter: @JoAnn_Hogan
AutoCAD Certified Professional 2015 / Inventor Certified Professional 2015
Contributor
FRFR1586
Posts: 11
Registered: ‎01-20-2014
Message 4 of 11 (323 Views)

Re: annotative mleader problem

02-04-2014 11:46 PM in reply to: CommCorp

Hi,

 

this don't solve the problem

 

the result is the same then adding then mtext.textheight=2.5 line

 

an other idea ?

 

regards

 

luc

Distinguished Contributor
CommCorp
Posts: 104
Registered: ‎03-19-2007
Message 5 of 11 (308 Views)

Re: annotative mleader problem

02-05-2014 04:21 AM in reply to: FRFR1586

Is the code you attached working?

I ask because I see that you did not AppendEntity or AddNewlyCreatedDBObject your mtext object.

I tried that in my code and it would not run.

 

I attached what I did, hopefully it will help.

 

 

Contributor
FRFR1586
Posts: 11
Registered: ‎01-20-2014
Message 6 of 11 (294 Views)

Re: annotative mleader problem

02-05-2014 11:57 PM in reply to: CommCorp
hi,

my code is working (expect the text height problem)

I'm working with the 2014 autocad version

while testing your code , I have then same size problem

Have you tested your solution in my sample case ?

regards

Luc
Distinguished Contributor
CommCorp
Posts: 104
Registered: ‎03-19-2007
Message 7 of 11 (286 Views)

Re: annotative mleader problem

02-06-2014 03:35 AM in reply to: FRFR1586

The only other thing I can think of is your "Annotation Plot Size" setting, is that correct?

 

After that, I'm out of ideas.

Contributor
FRFR1586
Posts: 11
Registered: ‎01-20-2014
Message 8 of 11 (254 Views)

Re: annotative mleader problem

02-11-2014 04:49 AM in reply to: CommCorp

hi,

 

I don't know how to verify Annotation Plot Size in vanilla autocad

 

luc

Distinguished Contributor
CommCorp
Posts: 104
Registered: ‎03-19-2007
Message 9 of 11 (238 Views)

Re: annotative mleader problem

02-11-2014 07:45 AM in reply to: FRFR1586

On command line type “units”

A dialog box should open, go to the “Scale” tab and “Annotation Plot Size:” is at the top right.

Ours is set to 3/32”

Valued Mentor
jeff
Posts: 338
Registered: ‎05-12-2009
Message 10 of 11 (232 Views)

Re: annotative mleader problem

02-11-2014 08:08 AM in reply to: CommCorp

The mleader just uses the contents of the mtext or just just copies the contents.

To set the hieght use MLeader.TextHeight Property

 

Normally set it from its MleaderStyle.TextHeight

 Leader.TextHeight = 30

 instead of

mText.Height or TextHeight

        <CommandMethod("TST_L", CommandFlags.Modal)> _
        Public Sub TST_L()
            Dim Doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            Dim ed As Editor = Doc.Editor
            Dim db As Database = ed.Document.Database
            Dim Dl As Autodesk.AutoCAD.ApplicationServices.DocumentLock = Doc.LockDocument(Autodesk.AutoCAD.ApplicationServices.DocumentLockMode.ProtectedAutoWrite, "", "", False)
            Using Dl
                Dim tr As Transaction = db.TransactionManager.StartTransaction()
                Dim btr As BlockTableRecord = DirectCast(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)

                Dim PtFleche As New Point3d(0, 0, 0)
                Dim PtFleche2 As New Point3d(PtFleche.X + 4, PtFleche.Y + 4, PtFleche.Z)
                Dim PtTexte As New Point3d(PtFleche.X + 8, PtFleche.Y + 6, PtFleche.Z)


              

                Dim Leader As New MLeader
                Leader.SetDatabaseDefaults()
                Leader.ContentType = ContentType.MTextContent
                'Leader.LayerId = CalqId


                Leader.ArrowSize = 2.0
                Leader.EnableDogleg = False
                Dim idx As Integer = Leader.AddLeaderLine(PtFleche2)
                Leader.AddFirstVertex(idx, PtFleche)
                Leader.Annotative = AnnotativeStates.True

                btr.AppendEntity(Leader)
                tr.AddNewlyCreatedDBObject(Leader, True)


                Using mText As New MText()
                    mText.Contents = "MyTexte"
                    Leader.MText = mText
                End Using
                Leader.TextHeight = 30
                'Dim mlstyle As MLeaderStyle = Leader.MLeaderStyle.GetObject(OpenMode.ForRead)
                'Leader.TextHeight = mlstyle.TextHeight
            

                tr.Commit()
            End Using

            MsgBox("now change the annotation scale to 20 (for exemple)" & vbCrLf & _
                    "then restart the tst_l command" & vbCrLf & vbCrLf & _
                    "then look at the text height of the new leader" & vbCrLf & _
                    "it is le 20th of the previous one")
        End Sub

 

 

 

 

 

 

You can also find your answers @ TheSwamp
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.