<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Mleader Text Height Is NOT What Is Set in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/mleader-text-height-is-not-what-is-set/m-p/10307956#M16457</link>
    <description>&lt;P&gt;I couldn't find it in the "AddMLeader" routine where the text height is set to MText. Where You set the text height equal to 2.2?&amp;nbsp;In my opinion&amp;nbsp;in .NET the text height of MText is completely independent of the height defined in Mleader.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;MText mText = new MText();
mText.SetDatabaseDefaults();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;creates a new MText based on the definition of the current text style in the current drawing.&lt;/P&gt;&lt;P&gt;SetDatabaseDefaults defines the layer, color, visibility, etc. I think it also defines the height of the text based on the value of the TXTSIZE variable.&lt;/P&gt;&lt;P&gt;So, I think it is necessary to adjust the height of the text after MText is created.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;MText mText = new MText();
mText.SetDatabaseDefaults();
// set the height of the text
mText.Height = 2.2;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Mtext textHeight after SetDatabaseDefaults:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Default MText Height.jpg" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/917975i35074A011067C6F2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Default MText Height.jpg" alt="Default MText Height.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 12 May 2021 12:06:59 GMT</pubDate>
    <dc:creator>Gepaha</dc:creator>
    <dc:date>2021-05-12T12:06:59Z</dc:date>
    <item>
      <title>Mleader Text Height Is NOT What Is Set</title>
      <link>https://forums.autodesk.com/t5/net-forum/mleader-text-height-is-not-what-is-set/m-p/10306824#M16455</link>
      <description>&lt;P&gt;Ok this is weird.&amp;nbsp; I have a drawing that has my dimension styles, text styles, and MLeader styles all set.&amp;nbsp; This base drawing gets inserted and the program just changes the dimension and Mleader styles scale value.&lt;/P&gt;&lt;P&gt;The mleader style that is used has a set mtext height of 2.2.&amp;nbsp; The scale factor will make it aesthetic in the drawings.&lt;/P&gt;&lt;P&gt;Here is the code to update the mleader style scale factor:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Public Sub UpdateMleaderStyle(ByVal dwg_scale As Double)
        Dim podDWG As Document = Application.DocumentManager.MdiActiveDocument
        Dim podDB As Database = podDWG.Database

        Using mldrTrans As Transaction = podDB.TransactionManager.StartTransaction()
            Const styleName As String = "MyStyle"
            Dim mlstyles As DBDictionary = CType(mldrTrans.GetObject(podDB.MLeaderStyleDictionaryId, OpenMode.ForRead), DBDictionary)
            If Not mlstyles.Contains(styleName) Then Return
            Dim id As ObjectId = mlstyles.GetAt(styleName)
            Dim mlStyle As MLeaderStyle = TryCast(mldrTrans.GetObject(id, OpenMode.ForWrite), MLeaderStyle)
            mlStyle.Scale = dwg_scale
            mldrTrans.Commit()
        End Using
    End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code that inserts an mleader:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Public Sub AddMLeader(ByVal ldrPnt1 As Point3d, ByVal ldrPnt2 As Point3d, ByVal ldrTextVal As String, ByVal ldrTextWidth As Double,
                          ldrJustify As String, ByVal dwg_scale As Double, ByVal mlLayer As String)
        Dim podDWG As Document = Application.DocumentManager.MdiActiveDocument
        Dim podDB As Database = podDWG.Database

        Using mlTran As Transaction = podDB.TransactionManager.StartTransaction()
            Dim blkTbl As BlockTable = TryCast(mlTran.GetObject(podDB.BlockTableId, OpenMode.ForRead), BlockTable)
            Dim blkTblRec As BlockTableRecord = TryCast(mlTran.GetObject(blkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
            Dim mleader As MLeader = New MLeader()
            mleader.SetDatabaseDefaults()
            mleader.ContentType = ContentType.MTextContent
            mleader.SetFromStyle()
            mleader.Layer = mlLayer
            Dim mText As MText = New MText()
            mText.SetDatabaseDefaults()
            mText.Width = ldrTextWidth
            mText.Layer = mlLayer
            mText.SetContentsRtf(ldrTextVal)
            mText.Location = ldrPnt2
            If ldrJustify = "Left" Then mText.Attachment = AttachmentPoint.MiddleLeft
            If ldrJustify = "Right" Then mText.Attachment = AttachmentPoint.MiddleRight
            mleader.MText = mText
            Dim idx As Integer = mleader.AddLeaderLine(ldrPnt1)
            Dim dict As DBDictionary = CType(mlTran.GetObject(podDB.MLeaderStyleDictionaryId, OpenMode.ForRead), DBDictionary)
            Dim mlStyleId As ObjectId = dict.GetAt("MyStyle")
            mleader.MLeaderStyle = mlStyleId
            blkTblRec.AppendEntity(mleader)
            mlTran.AddNewlyCreatedDBObject(mleader, True)
            mlTran.Commit()
        End Using
    End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When the program is done running, the mleader style is correct when I look at the mleader format.&amp;nbsp; The text height is set to 2.2.&amp;nbsp; So nothing in the code will change the mtext text height, but when the mleader in created in the drawing, the text height is 0.367.&amp;nbsp; Where the heck did it get such a weird number and why did it change the text height anyway.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 23:57:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/mleader-text-height-is-not-what-is-set/m-p/10306824#M16455</guid>
      <dc:creator>mgorecki</dc:creator>
      <dc:date>2021-05-11T23:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: Mleader Text Height Is NOT What Is Set</title>
      <link>https://forums.autodesk.com/t5/net-forum/mleader-text-height-is-not-what-is-set/m-p/10306856#M16456</link>
      <description>&lt;P&gt;Also, the dwg_scale that I'm using is 0.50, so the text height should appear to be 1.1, not 0.367.&lt;/P&gt;</description>
      <pubDate>Wed, 12 May 2021 00:18:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/mleader-text-height-is-not-what-is-set/m-p/10306856#M16456</guid>
      <dc:creator>mgorecki</dc:creator>
      <dc:date>2021-05-12T00:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: Mleader Text Height Is NOT What Is Set</title>
      <link>https://forums.autodesk.com/t5/net-forum/mleader-text-height-is-not-what-is-set/m-p/10307956#M16457</link>
      <description>&lt;P&gt;I couldn't find it in the "AddMLeader" routine where the text height is set to MText. Where You set the text height equal to 2.2?&amp;nbsp;In my opinion&amp;nbsp;in .NET the text height of MText is completely independent of the height defined in Mleader.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;MText mText = new MText();
mText.SetDatabaseDefaults();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;creates a new MText based on the definition of the current text style in the current drawing.&lt;/P&gt;&lt;P&gt;SetDatabaseDefaults defines the layer, color, visibility, etc. I think it also defines the height of the text based on the value of the TXTSIZE variable.&lt;/P&gt;&lt;P&gt;So, I think it is necessary to adjust the height of the text after MText is created.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;MText mText = new MText();
mText.SetDatabaseDefaults();
// set the height of the text
mText.Height = 2.2;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Mtext textHeight after SetDatabaseDefaults:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Default MText Height.jpg" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/917975i35074A011067C6F2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Default MText Height.jpg" alt="Default MText Height.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 May 2021 12:06:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/mleader-text-height-is-not-what-is-set/m-p/10307956#M16457</guid>
      <dc:creator>Gepaha</dc:creator>
      <dc:date>2021-05-12T12:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: Mleader Text Height Is NOT What Is Set</title>
      <link>https://forums.autodesk.com/t5/net-forum/mleader-text-height-is-not-what-is-set/m-p/10308599#M16458</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Thank you for your post.&amp;nbsp; Originally I had used mtext.TextHeight (not mtext.height) set to 2.2, but that did nothing.&amp;nbsp; So I commented out the line:&amp;nbsp; mText.SetDatabaseDefaults() and that seems to have done the trick.&amp;nbsp; Thank you for bringing that line to my attention.&lt;/P&gt;&lt;P&gt;By the way, I set the text height to 2.20 in the actual mleader dialog box in the base drawing that gets inserted.&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;</description>
      <pubDate>Wed, 12 May 2021 15:50:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/mleader-text-height-is-not-what-is-set/m-p/10308599#M16458</guid>
      <dc:creator>mgorecki</dc:creator>
      <dc:date>2021-05-12T15:50:02Z</dc:date>
    </item>
  </channel>
</rss>

