create a MTEXT-object, set whatever you want to individually re-format, then open your property-windows, click the MTEXT-object to get selected and then look to the content of the text within the property-window ==> there you see the special-codes for formatting. That is what you have to set.
- alfred -
I understood your question in the way you want to change parts of a text within MTEXT to another font, .... or globally change any formating for parts of your text.
The way AutoCAD does modifying e.g. that the 3rd char within the text to be Arial-Black is to put control-characters within the text. And that is what you have to do: take the text-context in your vb-app, place the control characters into the text and save it back.
So you can learn the special chars AutoCAD uses within a MTEXT you can create a MTEXT-object by just drawing it, modify it in the way you like and look into the property-window how the special-formatting is saved.
Hope that was more clear now (and I understood your question correctly).
- alfred -
that is the minimum-code to set one textstyle to the whole MTEXT-object.
Dim tMTextObj As DatabaseServices.MText = New DatabaseServices.MText() tMTextObj.TextStyleId = myTextStyleObjectID
And what you need for that to come to:
>> change the Style to Romans
You first have either to define a textstyle that is called "Romans" or at least have the font "Romans" assigned to it ... or you have to seek through the list of textstyles within you current drawing, it a style is defined in the way you want and take this ObjectID to assign this to the MTEXT.TextStyleID-property
- alfred -
Can't speak VB anymore, but maybe this C# sample may help you
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
using (Transaction tr = db.TransactionManager.StartTransaction())
BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord ms = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord
TextStyleTable ts = (TextStyleTable)tr.GetObject(db.TextStyleTableId, OpenMode.ForRead);
ObjectId mtStyleid = db.Textstyle;
mtStyleid = ts["Romans"];
MText mt = new MText();
mt.Location = new Point3d(100, 150, 0);
mt.TextStyleId = mtStyleid;
mt.TextHeight = 2.5;
mt.Rotation = 30 * Math.PI / 180.0;
mt.Contents = "Hello World!";
mt.Width = 0;
out of reasons I don't know between 2007- and 2010-API the propertyname for modifying the TextStyle-ObjectID changed.
Said that you have to check what AutoCAD-version call's your code, either by doing this with flags like #IF (conditional compiling, see also >>>here<<<) or you have different projects for 2007 and 2010.
I prefere different projects and codeparts (most code is in same source-files, the version-specific code is placed in small source files that handles issues like this where signatures changed dependign on version) ... the additional advantage is that you have different Windows Frameworks for 2007 (version 2) and 2010 (Framework 3.5 if I'm right now), imho it's more stable to have the DLL compiled with the correct Framework.
Good luck, - alfred -
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.