<?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: how to find standard text style font from one file in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-find-standard-text-style-font-from-one-file/m-p/8465101#M24264</link>
    <description>&lt;P&gt;Not all TextStyles have Names, for example Shape Files.&lt;/P&gt;
&lt;P&gt;Slightly modified code sample, iterating all&amp;nbsp;TextStyles&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;...
                var fontForStandard = default(Autodesk.AutoCAD.GraphicsInterface.FontDescriptor);
                using (var tr=db.TransactionManager.StartTransaction())
                {
                    var tsTbl = (TextStyleTable)tr.GetObject(db.TextStyleTableId, OpenMode.ForRead);
                    foreach (ObjectId tsId in tsTbl)
                    {
                        var textStyle = (TextStyleTableRecord)tr.GetObject(tsId, OpenMode.ForRead);
                        //Some TextStyles do NOT have names, for example ltshapes.shx
                        //  textStyle.IsShapeFile==TRUE
                        if (string.IsNullOrWhiteSpace(textStyle.Name))
                        {
                            //ShapeFile
                        }
                        else if (textStyle.Name.Equals("STANDARD", StringComparison.OrdinalIgnoreCase))
                        {
                            fontForStandard = textStyle.Font;
                        }

                        if (tsId== db.Textstyle)
                        {
                            //this is the Current TextStyle
                        }
                     }
                    tr.Commit();
                }
...&lt;/PRE&gt;</description>
    <pubDate>Thu, 13 Dec 2018 08:34:00 GMT</pubDate>
    <dc:creator>SENL1362</dc:creator>
    <dc:date>2018-12-13T08:34:00Z</dc:date>
    <item>
      <title>how to find standard text style font from one file</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-find-standard-text-style-font-from-one-file/m-p/8403878#M24263</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how to find standard text style font from one file, i found some error in the red color code line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        [CommandMethod("AttachFontCommand")]
        public static void AttachFont() // This method can have any name
        {

            Document acadDoc = Application.DocumentManager.MdiActiveDocument;

            ///get the current drawing database
            Database acadCurDb = acadDoc.Database;

            /// Get the current font settings
            FontDescriptor acFont;

            TextStyleTableRecord openTextStyleTbl;

            int errorIndex;

            /// prompt receive the Block file path
            PromptStringOptions pBlkFile = new PromptStringOptions("\nEnter Block file path: ");
            pBlkFile.AllowSpaces = true;
            PromptResult pBlkFileRes = acadDoc.Editor.GetString(pBlkFile);
            string sBlockfile = pBlkFileRes.StringResult;

                using (Database OpenDb = new Database(false, true))
                {

                    OpenDb.ReadDwgFile(sBlockfile, System.IO.FileShare.ReadWrite, true, "");

                    ObjectIdCollection ObjectIds = new ObjectIdCollection();
                
                    using (Transaction acadTrans = OpenDb.TransactionManager.StartTransaction())
                    {

                        /// Open the exiting text style for read
                        openTextStyleTbl = acadTrans.GetObject(OpenDb.Textstyle, OpenMode.ForRead) as TextStyleTableRecord;

                    //TODO : remodify the code
                   &lt;FONT color="#FF0000"&gt; if (openTextStyleTbl.Name.ToString() == "STANDARD")&lt;/FONT&gt;
                    {
                        acFont = openTextStyleTbl.Font;
                    }
                    else
                    {
                        acFont = openTextStyleTbl.Font;
                    }

                    acadTrans.Commit();

                    }
                }
                if (acFont.ToString() != null)
                {
                    /// Start a transaction for text style
                    using (Transaction acTrans = acadCurDb.TransactionManager.StartTransaction())
                    {
                        TextStyleTableRecord currentTextStyleTbl;

                        currentTextStyleTbl = acTrans.GetObject(acadCurDb.Textstyle, OpenMode.ForWrite) as TextStyleTableRecord;

                        currentTextStyleTbl.Font = acFont;

                      //  Application.SetSystemVariable("USERS3", acFont);

                        acadDoc.Editor.Regen();

                        acTrans.Commit();

                        errorIndex = 0;
                    }
                }
                else
                {
                    errorIndex = 0;
                }

            Application.SetSystemVariable("USERS2", errorIndex.ToString());
        }&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Nov 2018 12:06:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-find-standard-text-style-font-from-one-file/m-p/8403878#M24263</guid>
      <dc:creator>VallimanalanT</dc:creator>
      <dc:date>2018-11-15T12:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to find standard text style font from one file</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-find-standard-text-style-font-from-one-file/m-p/8465101#M24264</link>
      <description>&lt;P&gt;Not all TextStyles have Names, for example Shape Files.&lt;/P&gt;
&lt;P&gt;Slightly modified code sample, iterating all&amp;nbsp;TextStyles&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;...
                var fontForStandard = default(Autodesk.AutoCAD.GraphicsInterface.FontDescriptor);
                using (var tr=db.TransactionManager.StartTransaction())
                {
                    var tsTbl = (TextStyleTable)tr.GetObject(db.TextStyleTableId, OpenMode.ForRead);
                    foreach (ObjectId tsId in tsTbl)
                    {
                        var textStyle = (TextStyleTableRecord)tr.GetObject(tsId, OpenMode.ForRead);
                        //Some TextStyles do NOT have names, for example ltshapes.shx
                        //  textStyle.IsShapeFile==TRUE
                        if (string.IsNullOrWhiteSpace(textStyle.Name))
                        {
                            //ShapeFile
                        }
                        else if (textStyle.Name.Equals("STANDARD", StringComparison.OrdinalIgnoreCase))
                        {
                            fontForStandard = textStyle.Font;
                        }

                        if (tsId== db.Textstyle)
                        {
                            //this is the Current TextStyle
                        }
                     }
                    tr.Commit();
                }
...&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Dec 2018 08:34:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-find-standard-text-style-font-from-one-file/m-p/8465101#M24264</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2018-12-13T08:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: how to find standard text style font from one file</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-find-standard-text-style-font-from-one-file/m-p/8468391#M24265</link>
      <description>&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 14 Dec 2018 13:17:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-find-standard-text-style-font-from-one-file/m-p/8468391#M24265</guid>
      <dc:creator>VallimanalanT</dc:creator>
      <dc:date>2018-12-14T13:17:10Z</dc:date>
    </item>
  </channel>
</rss>

