<?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: Help Changing Text Styles in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/help-changing-text-styles/m-p/9640729#M19072</link>
    <description>&lt;P&gt;Thank you @ddetnnis, that is a solution i also thought about but the problem is that, as i change the text style based on the model space scale, i do not know before hand the characteristics that my Text need, so it is kind of dificult to solve it that way. Maybe with a pre-established collection of object containing the data based on the scale could work.&lt;/P&gt;&lt;P&gt;Thanks anyways.&lt;/P&gt;</description>
    <pubDate>Fri, 17 Jul 2020 09:49:33 GMT</pubDate>
    <dc:creator>carlosrdrzalns</dc:creator>
    <dc:date>2020-07-17T09:49:33Z</dc:date>
    <item>
      <title>Help Changing Text Styles</title>
      <link>https://forums.autodesk.com/t5/net-forum/help-changing-text-styles/m-p/9632157#M19070</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm working on a Simple program to change all text in a dwg file to a diferent text style based on the current scale of model Space. The text style comes with the prefix "TfL_m1-" and then the scale number. The program does work but it only change the style name, and I need to change also its properties.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code is as following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt; &amp;lt;CommandMethod("ChangeTextStyle")&amp;gt;
    Public Sub SetTextStyle()
        Dim TextDic As New Dictionary(Of String, TextStyleTableRecord)
        Using tr As Transaction = m_Database.TransactionManager.StartTransaction()

            '' Get the current Annotation Scale on the drawing

            Dim scale As String = m_Database.Cannoscale.Name
            Dim subscale As String = scale.Substring(scale.IndexOf(":") + 1, scale.IndexOf("(") - scale.IndexOf(":") - 1)



            '' Create a dictionary with the text styles and names
            Dim acTextStyleTable As TextStyleTable = tr.GetObject(m_Database.TextStyleTableId, OpenMode.ForRead)
            ed.WriteMessage("la escala actual del modelSpace es:" + scale + vbCrLf)
            ed.WriteMessage("el valor que nos atañe es: " + subscale + vbCrLf)
            For Each id As ObjectId In acTextStyleTable
                Dim Symbol As TextStyleTableRecord = tr.GetObject(id, OpenMode.ForRead)
                TextDic.Add(Symbol.Name, Symbol)
                'ed.WriteMessage("estilo de texto: " + Symbol.Name + vbCrLf)
            Next

            Dim keys As Dictionary(Of String, TextStyleTableRecord).KeyCollection = TextDic.Keys


            Dim stri As String = "TfL_m1-" + subscale

            ed.WriteMessage("el valor clave del diccionario sería: " + stri + " cuya longitud es: " + Str(stri.Length) + vbCrLf)

            ed.WriteMessage("La escala a aplicar en este dibujo seria: {0} con un valor de id : {1}", stri, TextDic(stri).ToString + vbCrLf)







            'Search for all text object in the current model space

            Dim model = DirectCast(tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(m_Database), OpenMode.ForWrite), BlockTableRecord)



            For Each obj As ObjectId In model
                Select Case obj.ObjectClass.DxfName
                    Case "TEXT"
                        ed.WriteMessage("Hola")
                        Dim tx As DBText = tr.GetObject(obj, OpenMode.ForWrite)
                        tx.TextStyleId = TextDic(stri).ObjectId


                    Case "MTEXT"
                        ed.WriteMessage("Hola")
                        Dim tx As MText = tr.GetObject(obj, OpenMode.ForWrite)
                        tx.TextStyleId = TextDic(stri).ObjectId

                    Case Else
                        ed.WriteMessage("Not he encontrado ninguna entidad Decimal este tipo")
                        Exit Select
                End Select

            Next

            tr.Commit()

            ed.Regen()
        End Using
    End Sub&lt;/LI-CODE&gt;&lt;P&gt;I would be very gratefull if someone could explain me where i am wrong.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Carlos.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 12:47:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/help-changing-text-styles/m-p/9632157#M19070</guid>
      <dc:creator>carlosrdrzalns</dc:creator>
      <dc:date>2020-07-13T12:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: Help Changing Text Styles</title>
      <link>https://forums.autodesk.com/t5/net-forum/help-changing-text-styles/m-p/9637767#M19071</link>
      <description>&lt;P&gt;I found the same results as you, so instead I change the properties individually while also changing the text style. I've also opted to use a single annotative text style where possible, and then I apply a new annotative scale to the text with this method:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private static void SetAnnotationScale(Database db, Entity obj, string scale)
{
    obj.Annotative = AnnotativeStates.True;
    var occ = db.ObjectContextManager.GetContextCollection("ACDB_ANNOTATIONSCALES");
    ObjectContexts.AddContext(obj, occ.GetContext(scale));
    ObjectContexts.RemoveContext(obj, occ.GetContext("1:1"));
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Sorry, this is C# instead of VB, but it hopefully it's fairly simple to convert.)&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 20:57:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/help-changing-text-styles/m-p/9637767#M19071</guid>
      <dc:creator>ddetennis</dc:creator>
      <dc:date>2020-07-15T20:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Help Changing Text Styles</title>
      <link>https://forums.autodesk.com/t5/net-forum/help-changing-text-styles/m-p/9640729#M19072</link>
      <description>&lt;P&gt;Thank you @ddetnnis, that is a solution i also thought about but the problem is that, as i change the text style based on the model space scale, i do not know before hand the characteristics that my Text need, so it is kind of dificult to solve it that way. Maybe with a pre-established collection of object containing the data based on the scale could work.&lt;/P&gt;&lt;P&gt;Thanks anyways.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 09:49:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/help-changing-text-styles/m-p/9640729#M19072</guid>
      <dc:creator>carlosrdrzalns</dc:creator>
      <dc:date>2020-07-17T09:49:33Z</dc:date>
    </item>
  </channel>
</rss>

