Exemplo n.º 1
0
        /// <summary>
        /// This node will return all of the leaders associated with the text note.
        /// </summary>
        /// <param name="textNote">The text note to get leaders from.</param>
        /// <returns name="leaders">The leaders..</returns>
        /// <search>
        /// textnote, getleaders, rhythm
        /// </search>
        public static List <Leader> GetLeaders(global::Revit.Elements.Element textNote)
        {
            Autodesk.Revit.DB.Document doc          = DocumentManager.Instance.CurrentDBDocument;
            Autodesk.Revit.DB.TextNote internalNote = (Autodesk.Revit.DB.TextNote)textNote.InternalElement;

            return(internalNote.GetLeaders().ToList());
        }
Exemplo n.º 2
0
 /// <summary>
 /// Create from existing
 /// </summary>
 /// <param name="instance"></param>
 /// <param name="isRevitOwned"></param>
 /// <returns></returns>
 internal static TextNote FromExisting(Autodesk.Revit.DB.TextNote instance, bool isRevitOwned)
 {
     return(new TextNote(instance)
     {
         IsRevitOwned = isRevitOwned
     });
 }
Exemplo n.º 3
0
        public Autodesk.Revit.UI.Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            try
            {
                // get the active document and view
                UIDocument             revitDoc = commandData.Application.ActiveUIDocument;
                Autodesk.Revit.DB.View view     = revitDoc.Document.ActiveView;
                foreach (Element elem in revitDoc.Selection.Elements)
                {
                    if (elem.GetType() == typeof(Autodesk.Revit.DB.Structure.Rebar))
                    {
                        // cast to Rebar and get its first curve
                        Autodesk.Revit.DB.Structure.Rebar rebar = (Autodesk.Revit.DB.Structure.Rebar)elem;
                        Autodesk.Revit.DB.Curve           curve = rebar.GetCenterlineCurves(false, false, false)[0];

                        // calculate necessary arguments
                        Autodesk.Revit.DB.XYZ origin = new XYZ(
                            curve.GetEndPoint(0).X + curve.Length,
                            curve.GetEndPoint(0).Y,
                            curve.GetEndPoint(0).Z);// draw the text at the right size
                        Autodesk.Revit.DB.XYZ baseVec = new Autodesk.Revit.DB.XYZ(1, 0, 0);
                        Autodesk.Revit.DB.XYZ upVec   = new Autodesk.Revit.DB.XYZ(0, 0, 1);
                        double lineWidth = curve.Length / 50;
                        string strText   = "This is " + rebar.Category.Name + " : " + rebar.Name;

                        // create the text
                        Transaction t = new Transaction(revitDoc.Document);
                        t.Start("Create new textnote");
                        Autodesk.Revit.DB.TextNote text = revitDoc.Document.Create.NewTextNote(view, origin, baseVec, upVec, lineWidth,
                                                                                               Autodesk.Revit.DB.TextAlignFlags.TEF_ALIGN_LEFT, strText);
                        text.Width = curve.Length; // set the text width
                        t.Commit();
                        return(Autodesk.Revit.UI.Result.Succeeded);
                    }
                }
                message = "No rebar selected!";
                return(Autodesk.Revit.UI.Result.Failed);
            }
            catch (Exception e)
            {
                message = e.Message;
                return(Autodesk.Revit.UI.Result.Failed);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// This node will convert the text note to lower with formatting.
        /// </summary>
        /// <param name="textNote">The text note to convert.</param>
        /// <returns name="textNote">The converted text note.</returns>
        /// <search>
        /// textnote, tolower, rhythm
        /// </search>
        public static global::Revit.Elements.Element ToLower(global::Revit.Elements.Element textNote)
        {
            Autodesk.Revit.DB.Document doc          = DocumentManager.Instance.CurrentDBDocument;
            Autodesk.Revit.DB.TextNote internalNote = (Autodesk.Revit.DB.TextNote)textNote.InternalElement;

            //Get the text from the text box
            //we obtain formated text and modify the caps instead of the string. Preserves formatting. - John
            FormattedText formattedText = internalNote.GetFormattedText();

            formattedText.SetAllCapsStatus(false);
            //Change all the text to upper case and reassign to the text box
            //using formatted text allows for the formatting to stay - John
            TransactionManager.Instance.EnsureInTransaction(doc);
            internalNote.SetFormattedText(formattedText);
            TransactionManager.Instance.TransactionTaskDone();

            return(textNote);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Init element from existing
        /// </summary>
        /// <param name="element"></param>
        private void InitElement(Autodesk.Revit.DB.TextNote element)
        {
            // use the default coordinates for an unrotated text
            XYZ    position = element.Coord;
            double rotation = 0;

            // If an element location is present, use this location instead because it
            // holds the elements rotation
            if (element.Location != null && element.Location is LocationPoint)
            {
                LocationPoint location = element.Location as LocationPoint;
                position = location.Point;
                rotation = location.Rotation.ToDegrees();
            }

            InternalSetType(element.Text, element.TextNoteType, position, element.HorizontalAlignment, rotation);
            InternalSetElement(element);
        }
Exemplo n.º 6
0
 public static TextNote Wrap(Autodesk.Revit.DB.TextNote ele, bool isRevitOwned)
 {
     return(TextNote.FromExisting(ele, isRevitOwned));
 }
Exemplo n.º 7
0
 /// <summary>
 /// TextNote from existing
 /// </summary>
 /// <param name="TextNote"></param>
 internal TextNote(Autodesk.Revit.DB.TextNote TextNote)
 {
     SafeInit(() => InitElement(TextNote));
 }