I have some interesting task. In one of drawings i've got a MText field. So, my plugin needs to know, how to get exactly that field from this drawing and others. Is there any attributes or smth, what i can use for determining Mtext field on different drawings?
Asked
Active
Viewed 2,627 times
1
-
Maybe the answers to this question http://stackoverflow.com/questions/3154613/ will help you along? – Toastgeraet Jun 27 '13 at 10:15
1 Answers
3
I think this may be what you are looking for...
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using AcApplication = Autodesk.AutoCAD.ApplicationServices.Application;
public static Document acDoc {
get {
return Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
}
}
public static MText getMTextObj(string TextYouNeed)
{
var ed = acDoc.Editor;
var selMText = new TypedValue[1];
selMText.SetValue(new TypedValue(0,"MTEXT"),0);
var MTextObjs = ed.SelectAll(new SelectionFilter(selMText));
using (var Transaction = acDoc.Database.TransactionManager.StartTransaction()) {
foreach (ObjectId MTextObjId in MTextObjs.Value.GetObjectIds()) {
var current_MTextObj = Transaction.GetObject(MTextObjId,OpenMode.ForWrite) as MText;
if(current_MTextObj.Text.Equals(TextYouNeed))
// return current_MTextObj;
// or
// do somehting else
}
}
Transaction.Commit(); // if you change something.
}

Trae Moore
- 1,759
- 3
- 17
- 32