Hi Nathan & Tony,
Thank U very much for U'r reply, Actually i'm creating a tool palette with .Net 2005 for AutoCAD 2007, which will be loaded with various images when i drag drop the with doesn't have any text in it there's no problem at all, but when i drag drop a image which has some text i'm getting this error, here's my code where i'm creating MText with style, please review this and give a solution, please.
Autodesk.AutoCAD.DatabaseServices.MText mText = new Autodesk.AutoCAD.DatabaseServices.MText()
{
mText.Contents = text.emrtext.Text;
mText.TextHeight = Math.Abs(font.elfw.elfLogFont.lfHeight);
mText.Color = textColor;
using (AcadDb.TextStyleTableRecord tstR = new Autodesk.AutoCAD.DatabaseServices.TextStyleTableRecord())
{
tstR.Name = "Style" + fileName + instanceIndex + textStyleCount++;
/// -------- Here is where i have inserted U'r code --------- ///
Autodesk.AutoCAD.DatabaseServices.RegAppTable objRAT;
objRAT = ((Autodesk.AutoCAD.DatabaseServices.RegAppTable)trans.GetObject(db.RegAppTableId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite, false));
Autodesk.AutoCAD.DatabaseServices.RegAppTableRecord objRATR;
Autodesk.AutoCAD.DatabaseServices.ObjectId objRATRID = new Autodesk.AutoCAD.DatabaseServices.ObjectId();
objRATRID = GetTableRecord(db.RegAppTableId, db, trans, tstR.Name);
if (objRATRID == Autodesk.AutoCAD.DatabaseServices.ObjectId.Null)
{
objRATR = new Autodesk.AutoCAD.DatabaseServices.RegAppTableRecord();
objRATR.Name = tstR.Name;
objRAT.Add(objRATR);
trans.AddNewlyCreatedDBObject(objRATR, true);
}
///---------------------------------------------------///
tstR.Font = new Autodesk.AutoCAD.GraphicsInterface.FontDescriptor((font.FaceName.Equals("System")) ? "Arial" : font.FaceName, font.IsBold, font.IsItalic, font.CharSet, font.PitchAndFamily);
tstR.TextSize = Math.Abs(font.elfw.elfLogFont.lfHeight);
AcadDb.TextStyleTable tst = (AcadDb.TextStyleTable)trans.GetObject(db.TextStyleTableId, AcadDb.OpenMode.ForWrite);
mText.TextStyle = tst.Add(tstR);
trans.AddNewlyCreatedDBObject(tstR, true);
}
mText.TextHeight *= 0.65;
// btr is BlockTableRecord
btr.AppendEntity(mText);
trans.AddNewlyCreatedDBObject(mText, true);
}
thank U & bye - Prakash.C