Revit二次開發--文字註釋
阿新 • • 發佈:2018-12-04
記錄一下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(); }