.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
How to new a TextStyle? And then set it current?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hello.I want to set a TestStyle,so I can control the fontsize,fontname,etc.Is there anyone who have done that before,Can your code be shared with us? Thank you.
Re: How to new a TextStyle? And then set it current?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Here is one way you can go about it:
Document curDoc = Autodesk.AutoCAD.ApplicationServices.Application.D
Database db = curDoc.Database;
Editor ed = curDoc.Editor;
TextStyleTableRecord txtStyle = new TextStyleTableRecord();
txtStyle.Name = "My Style";
txtStyle.Font = new Autodesk.AutoCAD.GraphicsInterface.FontDescriptor(
txtStyle.Annotative = AnnotativeStates.True;
txtStyle.TextSize = 0.125;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
TextStyleTable tab = (TextStyleTable)db.TextStyleTableId.GetObject(Open
tab.Add(txtStyle);
trans.AddNewlyCreatedDBObject(txtStyle, true);
db.Textstyle = txtStyle.Id;
trans.Commit();
}
Re: How to new a TextStyle? And then set it current?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
how can I show what is the current TextStyle ??
this show me my style, but I know what is this name:
textStyleId = textStyleTable["MyTextStyle"];
TextStyleTableRecord style = tr.GetObject(textStyleId, OpenMode.ForRead) as TextStyleTableRecord;
string sTx = style.Name;
ed.WrittenMessage("\nCurrent Text Style: {0}", sTx);
but If I don't??
textStyleId = textStyleTable[??]; // - I want to know name current TextStyle
TextStyleTableRecord style = tr.GetObject(textStyleId, OpenMode.ForRead) as TextStyleTableRecord;
string sTx = style.Name;
ed.WrittenMessage("\nCurrent Text Style: {0}", sTx);
regards
Re: How to new a TextStyle? And then set it current?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
if you have access to your database you also have access to the property .Textstyle (e.g. AcadDocDB.Textstyle) which gives you the ObjectID for the TextStyleTableRecord.
- alfred -
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Re: How to new a TextStyle? And then set it current?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi Alfred,
thank you it's work ![]()
TextStyleTableRecord style = tr.GetObject(db.Textstyle, OpenMode.ForRead) as TextStyleTableRecord;
string sTx = style.Name;
regards
