private bool RevisionIsOnSheet(ViewSheet viewSheet, int sequence)
        {
            IList <ElementId> revisionIds = viewSheet.GetAllRevisionIds();
            bool flag = false;

            foreach (ElementId i in revisionIds)
            {
                Element  elem = myRevitDoc.GetElement(i);
                Revision r    = elem as Revision;

                if (r.SequenceNumber == sequence)
                {
                    flag = true;
                }
                else
                {
                    flag = false;
                }
                if (flag)
                {
                    break;
                }
            }
            return(flag);
        }
Beispiel #2
0
        /// <summary>
        /// Возвращает массив из 4 строк, с количеством облаков на листе из последних 4 ревизий
        /// </summary>
        /// <param name="sheet"></param>
        /// <returns></returns>
        public static string[] GetCloudsCountOnSheet(ViewSheet sheet)
        {
            Document             doc    = sheet.Document;
            List <RevisionCloud> clouds = new FilteredElementCollector(doc)
                                          .OfClass(typeof(RevisionCloud))
                                          .Cast <RevisionCloud>()
                                          .Where(i => i.OwnerViewId.IntegerValue == sheet.Id.IntegerValue)
                                          .ToList();

            List <Revision> allRevisionsOnSheet = sheet.GetAllRevisionIds()
                                                  .Select(i => doc.GetElement(i))
                                                  .Cast <Revision>()
                                                  .OrderBy(i => Settings.revisionParam.GetValueFromRevision(i))
                                                  .ToList();

            var allRevisionsGrouped = allRevisionsOnSheet.GroupBy(i => Settings.revisionParam.GetValueFromRevision(i)).ToDictionary(j => j.Key, j => j.ToList());

            Dictionary <string, List <Revision> > revsBase = new Dictionary <string, List <Revision> >();

            foreach (Revision rev in allRevisionsOnSheet)
            {
                string utvDlya = Settings.revisionParam.GetValueFromRevision(rev);
            }

            int             revisionsCount       = allRevisionsOnSheet.Count;
            List <Revision> lastRevisionsOnSheet = new List <Revision>();

            if (revisionsCount > 4)
            {
                lastRevisionsOnSheet = allRevisionsOnSheet.GetRange(revisionsCount - 4, 4);
            }
            else
            {
                lastRevisionsOnSheet = allRevisionsOnSheet;
            }

            int revsCount = lastRevisionsOnSheet.Count;

            string[] cloudsCounts = new string[revsCount];

            for (int i = 0; i < revsCount; i++)
            {
                Revision rev = lastRevisionsOnSheet[i];
                int      curRevCloudsCount = clouds.Where(c => c.RevisionId.IntegerValue == rev.Id.IntegerValue).ToList().Count;
                string   val = "";
                if (curRevCloudsCount == 0)
                {
                    val = "-";
                }
                else
                {
                    val = curRevCloudsCount.ToString();
                }

                cloudsCounts[i] = val;
            }

            return(cloudsCounts);
        }
        private void AddRevisionOnSheet(ViewSheet viewSheet, Revision revisionToAdd)
        {
            IList <ElementId> revisionIds = null;

            revisionIds = viewSheet.GetAllRevisionIds();
            revisionIds.Add(revisionToAdd.Id);

            viewSheet.SetAdditionalRevisionIds(revisionIds);
        }
        private void RemoveRevisionOnSheet(ViewSheet viewSheet, Revision revisionToRemove)
        {
            IList <ElementId> revisionIds = null;

            revisionIds = viewSheet.GetAllRevisionIds();
            revisionIds.Remove(revisionToRemove.Id);

            viewSheet.SetAdditionalRevisionIds(revisionIds);
        }
        /// <summary>
        /// Check if Revision is on the ViewSheet
        /// </summary>
        /// <param name="sheet"></param>
        /// <param name="rev"></param>
        /// <returns></returns>
        private bool CheckForRevision(ViewSheet sheet, Revision rev)
        {
            bool result = false;

            if ((sheet == null) || (rev == null))
            {
                return(result);
            }
            if (sheet.GetAllRevisionIds().Count == 0)
            {
                return(result);
            }

            foreach (ElementId id in sheet.GetAllRevisionIds())
            {
                if (id.IntegerValue == rev.Id.IntegerValue)
                {
                    return(true);
                }
            }
            return(result);
        }
Beispiel #6
0
        void f(TextWriter tw, ViewSheet oViewSheet)
        {
            Document doc = oViewSheet.Document;

            IList <ElementId> oElemIDs = oViewSheet.GetAllRevisionIds();

            if (oElemIDs.Count == 0)
            {
                return;
            }

            foreach (ElementId elemID in oElemIDs)
            {
                Element oEl = doc.GetElement(elemID);

                Revision oRev = oEl as Revision;

                // Add text line to text file
                tw.WriteLine("Rev Category Name: " + oRev.Category.Name);

                // Add text line to text file
                tw.WriteLine("Rev Description: " + oRev.Description);

                // Add text line to text file
                tw.WriteLine("Rev Issued: " + oRev.Issued.ToString());

                // Add text line to text file
                tw.WriteLine("Rev Issued By: " + oRev.IssuedBy.ToString());

                // Add text line to text file
                tw.WriteLine("Rev Issued To: " + oRev.IssuedTo.ToString());

                // Add text line to text file
                tw.WriteLine("Rev Number Type: " + oRev.NumberType.ToString());

                // Add text line to text file
                tw.WriteLine("Rev Date: " + oRev.RevisionDate);

                // Add text line to text file
                tw.WriteLine("Rev Visibility: " + oRev.Visibility.ToString());

                // Add text line to text file
                tw.WriteLine("Rev Sequence Number: " + oRev.SequenceNumber.ToString());

                // Add text line to text file
                tw.WriteLine("Rev Number: " + oRev.RevisionNumber);
            }
        }
        void f( TextWriter tw, ViewSheet oViewSheet )
        {
            Document doc = oViewSheet.Document;

              IList<ElementId> oElemIDs = oViewSheet.GetAllRevisionIds();

              if( oElemIDs.Count == 0 )
            return;

              foreach( ElementId elemID in oElemIDs )
              {
            Element oEl = doc.GetElement( elemID );

            Revision oRev = oEl as Revision;

            // Add text line to text file
            tw.WriteLine( "Rev Category Name: " + oRev.Category.Name );

            // Add text line to text file
            tw.WriteLine( "Rev Description: " + oRev.Description );

            // Add text line to text file
            tw.WriteLine( "Rev Issued: " + oRev.Issued.ToString() );

            // Add text line to text file
            tw.WriteLine( "Rev Issued By: " + oRev.IssuedBy.ToString() );

            // Add text line to text file
            tw.WriteLine( "Rev Issued To: " + oRev.IssuedTo.ToString() );

            // Add text line to text file
            tw.WriteLine( "Rev Number Type: " + oRev.NumberType.ToString() );

            // Add text line to text file
            tw.WriteLine( "Rev Date: " + oRev.RevisionDate );

            // Add text line to text file
            tw.WriteLine( "Rev Visibility: " + oRev.Visibility.ToString() );

            // Add text line to text file
            tw.WriteLine( "Rev Sequence Number: " + oRev.SequenceNumber.ToString() );

            // Add text line to text file
            tw.WriteLine( "Rev Number: " + oRev.RevisionNumber );
              }
        }
        private static void CheckSheetLinks(Document doc, Guid projectId, ref RevitSheetData sheetData)
        {
            try
            {
                Dictionary <Guid /*revisionId*/, int /*elementId*/> revDictionary = new Dictionary <Guid, int>();
                var linkedRevisions = from revision in sheetData.Revisions where revision.LinkStatus.IsLinked select revision;
                if (linkedRevisions.Count() > 0)
                {
                    revDictionary = linkedRevisions.ToDictionary(o => o.Id, o => o.LinkStatus.LinkedElementId);
                }

                for (int i = 0; i < sheetData.Sheets.Count; i++)
                {
                    RevitSheet rvtSheet = sheetData.Sheets[i];

                    var linkedSheetFound = from lsheet in sheetData.Sheets[i].LinkedSheets where lsheet.LinkProject.Id == projectId select lsheet;
                    if (linkedSheetFound.Count() > 0)
                    {
                        LinkedSheet linkedSheet = linkedSheetFound.First();
                        ViewSheet   viewSheet   = doc.GetElement(linkedSheet.LinkedElementId) as ViewSheet;
                        if (null != viewSheet)
                        {
                            sheetData.Sheets[i].LinkStatus.IsLinked        = true;
                            sheetData.Sheets[i].LinkStatus.CurrentLinkedId = linkedSheet.LinkedElementId;
                            sheetData.Sheets[i].LinkStatus.LinkedElementId = viewSheet.Id.IntegerValue;
                            sheetData.Sheets[i].LinkStatus.ToolTip         = "Linked Sheet ElementId: " + viewSheet.Id.IntegerValue;

                            //parameter check
                            string toolTip = "";
                            if (CompareSheetParameters(viewSheet, sheetData.Sheets[i], sheetData, out toolTip))
                            {
                                sheetData.Sheets[i].LinkStatus.Modified = true;
                                sheetData.Sheets[i].LinkStatus.ToolTip  = toolTip;
                            }
                            var viewRevisionIds = from elementId in viewSheet.GetAllRevisionIds() select elementId.IntegerValue;
                            //revision check
                            foreach (Guid revisionId in rvtSheet.SheetRevisions.Keys)
                            {
                                RevisionOnSheet ros = rvtSheet.SheetRevisions[revisionId];

                                var revisionFound = from revision in sheetData.Revisions where revision.Id == revisionId select revision;
                                if (revisionFound.Count() > 0)
                                {
                                    RevitRevision rvtRevision = revisionFound.First();
                                    sheetData.Sheets[i].SheetRevisions[revisionId].RvtRevision = rvtRevision;

                                    if (rvtRevision.LinkStatus.IsLinked)
                                    {
                                        if (ros.Include && viewRevisionIds.Contains(rvtRevision.LinkStatus.LinkedElementId))
                                        {
                                            sheetData.Sheets[i].SheetRevisions[revisionId].LinkStatus.IsLinked = true;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            //item deleted
                            sheetData.Sheets[i].LinkedSheets.Remove(linkedSheet);
                            bool linkedSheetDBUpdated = SheetDataWriter.ChangeLinkedSheet(linkedSheet, CommandType.DELETE);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to check link status of sheets.\n" + ex.Message, "Sheet Manager Updater - Check Sheet Links", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }