Revit二次开发--文字注释

记录一下TextNote的简单使用方法:

	UIApplication uiApp = new UIApplication(commandData.Application.Application);
        UIDocument uiDoc = commandData.Application.ActiveUIDocument;
        Document doc = commandData.Application.ActiveUIDocument.Document;
        using (Transaction trans = new Transaction(doc,"Text Node creation"))
        {
            trans.Start();
            XYZ textLoc = uiDoc.Selection.PickPoint("Pick a point for sample text.");
            ElementId defaultTextTypeId = doc.GetDefaultElementTypeId(ElementTypeGroup.TextNoteType);
            TextNoteOptions opts = new TextNoteOptions(defaultTextTypeId);
            opts.HorizontalAlignment = HorizontalTextAlignment.Left;//设置文字的位置
            opts.Rotation = Math.PI / 4;//设置文字的倾斜角度
            TextNote textNote = TextNote.Create(doc, doc.ActiveView.Id, textLoc,DateTime.Now.ToString(), opts);
            trans.Commit();
        }

猜你喜欢

转载自blog.csdn.net/qq_43026206/article/details/84252911