/// <summary> /// Set Text /// </summary> /// <param name="value"></param> /// <param name="type"></param> /// <param name="location"></param> /// <param name="alignment"></param> /// <param name="angle"></param> private void InternalSetType(string value, RVT.TextNoteType type, XYZ location, HorizontalTextAlignment alignment, double angle) { int bold = type.get_Parameter(BuiltInParameter.TEXT_STYLE_BOLD).AsInteger(); int italic = type.get_Parameter(BuiltInParameter.TEXT_STYLE_ITALIC).AsInteger(); string font = type.get_Parameter(BuiltInParameter.TEXT_FONT).AsString(); double size = type.get_Parameter(BuiltInParameter.TEXT_SIZE).AsDouble(); bool isBold = (bold == 1) ? true : false; bool isItalic = (italic == 1) ? true : false; InternalSetTextSettings(value, isBold, isItalic, size, font, location.ToPoint(true), alignment, angle); }
/// <summary> /// Set Text /// </summary> /// <param name="value"></param> /// <param name="type"></param> /// <param name="location"></param> /// <param name="alignment"></param> /// <param name="angle"></param> private void InternalSetType(string value, RVT.TextNoteType type, XYZ location, HorizontalTextAlignment alignment, double angle) { int bold = type.LookupParameter("Bold").AsInteger(); int italic = type.LookupParameter("Italic").AsInteger(); string font = type.LookupParameter("Text Font").AsString(); double size = type.LookupParameter("Text Size").AsDouble(); bool isBold = (bold == 1) ? true : false; bool isItalic = (italic == 1) ? true : false; InternalSetTextSettings(value, isBold, isItalic, size, font, location.ToPoint(true), alignment, angle); }
public static TextNoteType Wrap(Autodesk.Revit.DB.TextNoteType ele, bool isRevitOwned) { return(TextNoteType.FromExisting(ele, isRevitOwned)); }
/// <summary> /// Init element by location /// </summary> /// <param name="view"></param> /// <param name="origin"></param> /// <param name="alignment"></param> /// <param name="text"></param> /// <param name="keepRotatedTextreadable"></param> /// <param name="rotation">in degrees</param> /// <param name="typeId"></param> private void Init(RVT.View view, RVT.XYZ origin, RVT.HorizontalTextAlignment alignment, string text, bool keepRotatedTextreadable, double rotation, ElementId typeId) { Autodesk.Revit.DB.Document document = DocumentManager.Instance.CurrentDBDocument; TransactionManager.Instance.EnsureInTransaction(document); var element = ElementBinder.GetElementFromTrace <RVT.TextNote>(document); RVT.TextNoteOptions options = new TextNoteOptions() { HorizontalAlignment = alignment, KeepRotatedTextReadable = keepRotatedTextreadable, Rotation = rotation.ToRadians(), TypeId = typeId }; if (element == null) { element = RVT.TextNote.Create(document, view.Id, origin, text, options); } else { if (element.HorizontalAlignment != alignment) { element.HorizontalAlignment = alignment; } if (element.KeepRotatedTextReadable != keepRotatedTextreadable) { element.KeepRotatedTextReadable = keepRotatedTextreadable; } if (element.Text != text) { element.Text = text; } // if the element location is null, try to use the Coord property // Coord holds a point only without rotation. if (element.Location == null) { if (!element.Coord.IsAlmostEqualTo(origin)) { element.Coord = origin; } } else { // If a location point is set we can use this and extract // its location and rotation if (element.Location is LocationPoint) { LocationPoint point = (LocationPoint)element.Location; if (!point.Point.IsAlmostEqualTo(origin)) { point.Point = origin; } if (Math.Abs(point.Rotation - rotation.ToRadians()) <= System.Double.Epsilon) { point.Rotate(Line.CreateUnbound(XYZ.Zero, XYZ.BasisZ), rotation.ToRadians()); } } } } RVT.TextNoteType type = (RVT.TextNoteType)document.GetElement(typeId); InternalSetType(text, type, origin, alignment, rotation); InternalSetElement(element); TransactionManager.Instance.TransactionTaskDone(); ElementBinder.SetElementForTrace(this.InternalElement); }