.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

mtext.TextStyleId in Arial format

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
joantopo
819 Views, 3 Replies

mtext.TextStyleId in Arial format

Hi.

 

I would like to do this for mtext:

 

try
{
   MText mt = new MText();
mt.TextStyleName="ARIAL";
}
catch{}

 But "TextStyleName" is only for read.

 

 

I can use "TextStyleId", so...How can I get the ObjectIdCollection of TextStyle and check which of them is "ARIAL"?

 

 

 

Thanks.

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
3 REPLIES 3
Message 2 of 4
joantopo
in reply to: joantopo

This is to create a new textstyle and make it current:

 

http://adndevblog.typepad.com/autocad/2012/06/creating-a-text-style-using-vbnet.html

 

But I want to check if there is a textstyle called "ARIAL" and create mtext with this textsytle.

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
Message 3 of 4
SENL1362
in reply to: joantopo

       [CommandMethod("TestTextStyle")]
        static public void TestTextStyle()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            string textStyleName = "Standard";
            try
            {
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    ed.WriteMessage("\n Default Textsize=={0}", db.Textsize);
                    TextStyleTable textStyleTable = (TextStyleTable)tr.GetObject(db.TextStyleTableId, OpenMode.ForRead);
                    if (!textStyleTable.Has(textStyleName))
                        throw new System.Exception(string.Format("Error: TextStyle not found: {0}", textStyleName));

                    ObjectId textStyleId = textStyleTable[textStyleName];
                    TextStyleTableRecord textStyle = (TextStyleTableRecord)tr.GetObject(textStyleId, OpenMode.ForRead);
                    ed.WriteMessage("\n {0} Size=={1}", textStyleName, textStyle.TextSize);

                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage(ex.Message);
            }
        }

 

Message 4 of 4
joantopo
in reply to: SENL1362

Thanks a lot!

It´s just that.

 

   MText mt = new MText();

              TextStyleTable TextStyleTable = (TextStyleTable)tr.GetObject(db.TextStyleTableId, OpenMode.ForRead);
              try
              {
                  ObjectId textStyleId = TextStyleTable["ARIAL"];
                  mt.TextStyleId = textStyleId;
              }
              catch { }
    
              mt.Contents = Contenido;
              mt.Layer = NombreCapa;

 

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost