I'm trying to create ModelText in a Revit model via the APIs but I'm not sure how to accomplish this. Here's what I have so far but it crashes with a Protected Memory Error:
string templateFileName = uiapp.Application.FamilyTemplatePath + "\\Generic Model face based.rft"; //"\\Annotations\\Generic Annotation.rft"; //"\\Generic Model.rft"; Document fdoc = app.NewFamilyDocument(templateFileName); using (Transaction tx = new Transaction(fdoc)) { tx.Start("Create Model Text"); ModelTextType pMT = new FilteredElementCollector(doc).OfClass(typeof(ModelTextType)).First() as ModelTextType; MyCreation.FamilyItemFactory pFIF = fdoc.FamilyCreate; try { pFIF.NewModelText("Joe", pMT, uidoc.ActiveView.SketchPlane, new XYZ(0.0, 0.0, 0.0), HorizontalAlign.Left, 5.0); } catch (Exception ex ) { } tx.Commit(); }
If I use the "\\Annotations\\Generic Annotation.rft" Family Template it will throw an exception stating there was an error creating Model Text.
Any guidance would be appreciated.
Thanks,
Joe