Exemple #1
0
        /// <summary>
        /// Construct a new Revit Revision by Name
        /// </summary>
        /// <param name="name">Revision Name</param>
        /// <param name="visibility">Visibility settings</param>
        /// <param name="revDate">Revision Date</param>
        /// <param name="description">Description</param>
        /// <param name="issued">Issuing status</param>
        /// <param name="issuedBy">Issued by</param>
        /// <param name="issuedTo">Issued to</param>
        /// <param name="numberType">Number type</param>
        /// <returns></returns>
        public static Revision ByName(string name, string revDate, string description, bool issued, string issuedBy, string issuedTo, string visibility = "", string numberType = "")
        {
            RevisionVisibility revVisibility = RevisionVisibility.CloudAndTagVisible;

            if (!Enum.TryParse <RevisionVisibility>(visibility, out revVisibility))
            {
                revVisibility = RevisionVisibility.CloudAndTagVisible;
            }

            RevisionNumberType revNumberType = RevisionNumberType.Alphanumeric;

            if (!Enum.TryParse <RevisionNumberType>(numberType, out revNumberType))
            {
                revNumberType = RevisionNumberType.Alphanumeric;
            }

            return(new Revision(name, revVisibility, revDate, description, issued, issuedBy, issuedTo, revNumberType));
        }
Exemple #2
0
        /// <summary>
        /// Private helper that converts a string to the equivilent RevisionNumberType.
        /// </summary>
        /// <param name="revisionNumberDescription">
        /// The string representing a RevisionNumberType.
        /// </param>
        /// <returns>
        /// Returns the default RevisionNumberType if the string is not a recognized RevisionNumberType.
        /// </returns>
        private static RevisionNumberType ToRevisionNumberType(string revisionNumberDescription)
        {
            RevisionNumberType result = RevisionNumberType.Automatic;
            string             lower  = revisionNumberDescription.ToLower();

            if (lower.StartsWith("i"))
            {
                result = RevisionNumberType.Increment;
            }
            else if (lower.StartsWith("f"))
            {
                result = RevisionNumberType.Fixed;
            }
            else
            {
                result = RevisionNumberType.Automatic;
            }

            return(result);
        }
Exemple #3
0
        /// <summary>
        /// Create new Revision
        /// </summary>
        /// <param name="name"></param>
        /// <param name="visibility"></param>
        /// <param name="revDate"></param>
        /// <param name="description"></param>
        /// <param name="issued"></param>
        /// <param name="issuedBy"></param>
        /// <param name="issuedTo"></param>
        /// <param name="numberType"></param>
        private void Init(string name, RevisionVisibility visibility, string revDate, string description, bool issued, string issuedBy, string issuedTo, RevisionNumberType numberType)
        {
            // Get document and open transaction
            Autodesk.Revit.DB.Document document = DocumentManager.Instance.CurrentDBDocument;
            TransactionManager.Instance.EnsureInTransaction(document);

            // Get existing element if any
            var RevisionElem = ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.Revision>(document);

            if (RevisionElem == null)
            {
                RevisionElem = Autodesk.Revit.DB.Revision.Create(document);
            }

            // Apply properties
            if (RevisionElem.Visibility != visibility)
            {
                RevisionElem.Visibility = visibility;
            }

            if (RevisionElem.Description != description)
            {
                RevisionElem.Description = description;
            }

            if (RevisionElem.RevisionDate != revDate)
            {
                RevisionElem.RevisionDate = revDate;
            }

            if (RevisionElem.Issued != issued)
            {
                RevisionElem.Issued = issued;
            }

            if (RevisionElem.IssuedBy != issuedBy)
            {
                RevisionElem.IssuedBy = issuedBy;
            }

            if (RevisionElem.IssuedTo != issuedTo)
            {
                RevisionElem.IssuedTo = issuedTo;
            }

            if (RevisionElem.NumberType != numberType)
            {
                RevisionElem.NumberType = numberType;
            }

            InternalSetElement(RevisionElem);

            // commit transaction and set element for trace
            TransactionManager.Instance.TransactionTaskDone();
            ElementBinder.SetElementForTrace(this.InternalElement);
        }
Exemple #4
0
 /// <summary>
 /// Create Revision
 /// </summary>
 /// <param name="name"></param>
 /// <param name="visibility"></param>
 /// <param name="revDate"></param>
 /// <param name="description"></param>
 /// <param name="issued"></param>
 /// <param name="issuedBy"></param>
 /// <param name="issuedTo"></param>
 /// <param name="numberType"></param>
 private Revision(string name, RevisionVisibility visibility, string revDate, string description, bool issued, string issuedBy, string issuedTo, RevisionNumberType numberType)
 {
     SafeInit(() => Init(name, visibility, revDate, description, issued, issuedBy, issuedTo, numberType));
 }