Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hi,
how to find standard text style font from one file, i found some error in the red color code line.
[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 if (openTextStyleTbl.Name.ToString() == "STANDARD") { 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()); }
Solved! Go to Solution.