i want to get the mtext font, height and width
Dim acDoc As Document = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
Dim bt As BlockTable
bt = acTrans.GetObject(acCurDb.BlockTableId, _
OpenMode.ForRead)
Dim btRec As BlockTableRecord
btRec = acTrans.GetObject(bt(BlockTableRecord.ModelSpace), _
OpenMode.ForRead)
Dim ts As TextStyleTable = acTrans.GetObject(acCurDb.TextStyleTableId, _
OpenMode.ForRead)
For Each mtstyleid As ObjectId In ts
..........
Next
This will get you started, you have just to translate the code on vb.net by yourself^
[CommandMethod("mxx")] public void mxprops() { Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; PromptEntityOptions peo = new PromptEntityOptions("\nSelect the mtext to get properties: "); peo.SetRejectMessage("Only a mtext !"); peo.AddAllowedClass(typeof(MText), false); PromptEntityResult per = ed.GetEntity(peo); if (per.Status != PromptStatus.OK) return; ObjectId id = per.ObjectId; using (Transaction tr = db.TransactionManager.StartTransaction()) { Entity ent = tr.GetObject(id, OpenMode.ForWrite) as Entity; MText mtx = ent as MText; if (mtx != null) { List<object> lst = GetMtextProperties(mtx); foreach (object item in lst) ed.WriteMessage("\n\t{0}\n", item); } } } public static List<object> GetMtextProperties(MText mtx) { Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; List<object> data = new List<object>(); int nCol = -1; ObjectId tstyleID = ObjectId.Null; if (mtx != null) { nCol = mtx.ColorIndex; tstyleID = mtx.TextStyleId; TextStyleTable tsTbl = db.TextStyleTableId.GetObject(OpenMode.ForRead) as TextStyleTable; if (tsTbl == null) return null; TextStyleTableRecord tsTblRec = mtx.TextStyleId.GetObject(OpenMode.ForRead) as TextStyleTableRecord; data.Add(tsTblRec.Name); // style name data.Add(tsTblRec.FileName);// font name data.Add(mtx.TextHeight);// textsize data.Add(mtx.ActualHeight);// mtext frame height data.Add(mtx.ActualWidth); // mtext frame width // <---add other properties you need... } return data; }
Can't find what you're looking for? Ask the community or share your knowledge.