Example #1
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIDocument UIdoc = commandData.Application.ActiveUIDocument;
            Document   doc   = UIdoc.Document;

            var selection = doc.GetElement(UIdoc.Selection.GetElementIds().FirstOrDefault());

            try
            {
                if (doc.IsWorkshared)
                {
                    var wti = WorksharingUtils.GetWorksharingTooltipInfo(doc, selection.Id);
                    TaskDialog.Show(Tools.GetResourceManager("element_info"),
                                    $"Создал: {wti.Creator}\n" + $"Текущий владелец: {wti.Owner}\n" +
                                    $"Последний раз изменен: {wti.LastChangedBy}");
                    return(Result.Succeeded);
                }
                else
                {
                    TaskDialog.Show(Tools.GetResourceManager("element_info"), "Модель не совместная");
                    return(Result.Failed);
                }
            }
            catch (Exception)
            {
                return(Result.Cancelled);
            }
        }
Example #2
0
        private void ListInfo(Element elem, Document doc)
        {
            var message = string.Empty;

            message += "Element Id: " + elem.Id;

            // The workset the element belongs to
            WorksetId worksetId = elem.WorksetId;

            message += "\nWorkset Id : " + worksetId.ToString();

            // Model Updates Status of the element
            ModelUpdatesStatus updateStatus = WorksharingUtils.GetModelUpdatesStatus(doc, elem.Id);

            message += "\nUpdate status : " + updateStatus.ToString();

            // Checkout Status of the element
            CheckoutStatus checkoutStatus = WorksharingUtils.GetCheckoutStatus(doc, elem.Id);

            message += "\nCheckout status : " + checkoutStatus.ToString();

            // Getting WorksharingTooltipInfo of a given element Id
            WorksharingTooltipInfo tooltipInfo = WorksharingUtils.GetWorksharingTooltipInfo(doc, elem.Id);

            message += "\nCreator : " + tooltipInfo.Creator;
            message += "\nCurrent Owner : " + tooltipInfo.Owner;
            message += "\nLast Changed by : " + tooltipInfo.LastChangedBy;

            SCaddinsApp.WindowManager.ShowMessageBox("Additional Element Information", message);
        }
Example #3
0
        public CEG_Element(Document doc, Element ele)
        {
            Name = ele.Name;
            Id   = ele.Id.IntegerValue;
            WorksharingTooltipInfo worksharingTooltipInfo = WorksharingUtils.GetWorksharingTooltipInfo(doc, ele.Id);

            LastChangeBy = worksharingTooltipInfo.LastChangedBy;
            Owner        = worksharingTooltipInfo.Owner;
            Creater      = worksharingTooltipInfo.Creator;
        }
Example #4
0
        /// <summary>
        /// This node will output the username of the person who last changed the element if it is available. Keep in mind this only works with workshared documents!
        /// </summary>
        /// <param name="element">The element to check.</param>
        /// <returns name="lastChangedBy">The username of the person who last changed the element.</returns>
        public static string LastChangedBy(global::Revit.Elements.Element element)
        {
            Autodesk.Revit.DB.Document doc;
            try
            {
                doc = element.InternalElement.Document;
            }
            catch (Exception)
            {
                doc = DocumentManager.Instance.CurrentDBDocument;
            }

            WorksharingTooltipInfo tooltipInfo = WorksharingUtils.GetWorksharingTooltipInfo(doc, element.InternalElement.Id);

            return(tooltipInfo.LastChangedBy);
        }
Example #5
0
        public GroupInstanceItem(Element group)
        {
            var doc     = group.Document;
            var created = VerifyUsername(WorksharingUtils.GetWorksharingTooltipInfo(doc, group.Id).LastChangedBy);
            var levelId = group.LevelId == null
                ? ElementId.InvalidElementId
                : group.LevelId;
            var levelName = string.Empty;

            if (levelId != ElementId.InvalidElementId)
            {
                levelName = doc.GetElement(levelId).Name;
            }
            CreatedBy   = created;
            Level       = levelName;
            OwnerViewId = group.OwnerViewId == null
                ? -1
                : group.OwnerViewId.IntegerValue;
        }
Example #6
0
        public CEG_Product(Document doc, FamilyInstance familyInstance)
        {
            FamilyInstance = familyInstance;
            Id             = familyInstance.Id.IntegerValue;
            Parameter PA_CONTROL_MARK = familyInstance.LookupParameter("CONTROL_MARK");

            if (PA_CONTROL_MARK != null)
            {
                CONTROL_MARK = PA_CONTROL_MARK.AsString();
            }
            Parameter PA_CONTROL_NUMBER = familyInstance.LookupParameter("CONTROL_NUMBER");

            if (PA_CONTROL_NUMBER != null)
            {
                CONTROL_NUMBER = PA_CONTROL_NUMBER.AsString();
            }
            Parameter PA_WORKSET = familyInstance.LookupParameter("Workset");

            if (PA_WORKSET != null)
            {
                WORKSET = PA_WORKSET.AsValueString();
            }
            Parameter PA_DIM_LENGTH = familyInstance.LookupParameter("DIM_LENGTH");

            if (PA_DIM_LENGTH != null)
            {
                DIM_LENGTH = PA_DIM_LENGTH.AsValueString();
            }
            Parameter PA_DIM_WIDTH = familyInstance.LookupParameter("DIM_WIDTH");

            if (PA_DIM_WIDTH != null)
            {
                DIM_WIDTH = PA_DIM_WIDTH.AsValueString();
            }
            WorksharingTooltipInfo worksharingTooltipInfo = WorksharingUtils.GetWorksharingTooltipInfo(doc, familyInstance.Id);

            LastChangeBy = worksharingTooltipInfo.LastChangedBy;
            Owner        = worksharingTooltipInfo.Owner;
            Creater      = worksharingTooltipInfo.Creator;
        }
Example #7
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
        {
            Document   doc   = commandData.Application.ActiveUIDocument.Document;
            UIDocument uidoc = commandData.Application.ActiveUIDocument;

            if (doc.IsWorkshared)
            {
                try
                {
                    Reference reference = uidoc.Selection.PickObject(ObjectType.Element, "Select an element to get info about who created and last edited it:");
                    Element   element   = doc.GetElement(reference);
                    ElementId elementId = element.Id;

                    WorksharingTooltipInfo worksharingTooltipInfo = WorksharingUtils.GetWorksharingTooltipInfo(doc, elementId);

                    TaskDialog taskDialog = new TaskDialog("Element Created and Last Edited By");
                    taskDialog.MainInstruction = "Element: " + element.Name + "\n"
                                                 + "ElementId: " + elementId.ToString() + "\n\n"
                                                 + "Created by: " + worksharingTooltipInfo.Creator + "\n"
                                                 + "Last Edited by: " + worksharingTooltipInfo.LastChangedBy;
                    taskDialog.MainIcon      = TaskDialogIcon.TaskDialogIconInformation;
                    taskDialog.CommonButtons = TaskDialogCommonButtons.Close;
                    taskDialog.DefaultButton = TaskDialogResult.Close;

                    TaskDialogResult taskDialogResult = taskDialog.Show();

                    return(Result.Succeeded);
                }
                catch
                {
                    return(Result.Failed);
                }
            }
            else
            {
                TaskDialog.Show("Workshare Info", "This tool only works with Workshare Enabled Models.");
                return(Result.Succeeded);
            }
        }
Example #8
0
        //This is the primary method for gathering the Warning information from the Document
        private void SetData(Document doc)
        {
            //Create a new List to hold the Warning Type names
            List <string> warningType = new List <string>();

            //Add the first item to the list so it can be controlled
            warningType.Add("--NONE--");

            //Check to see if the DataTable has had columns created not. If not (first time) then create olumns with the correct type of storage element
            if (dtWarnings.Columns.Count == 0)
            {
                //This is a bit redundent because they are all "warnings" as "errors" can't be ignored, but if you use custom error handlers, this may be more useful
                dtWarnings.Columns.Add(new DataColumn("Severity", typeof(FailureSeverity)));
                dtWarnings.Columns.Add(new DataColumn("Description", typeof(string)));
                dtWarnings.Columns.Add(new DataColumn("Element Ids", typeof(ICollection <ElementId>)));
                dtWarnings.Columns.Add(new DataColumn("Name", typeof(string)));
                dtWarnings.Columns.Add(new DataColumn("Creator", typeof(string)));
                dtWarnings.Columns.Add(new DataColumn("Phase Created", typeof(string)));
                dtWarnings.Columns.Add(new DataColumn("Phase Demo'd", typeof(string)));
            }
            //Use these two parameters in case it is not a workshared project
            string elemName = "None";
            string userId   = "None";

            //Loop through every warning in the document
            foreach (FailureMessage warning in doc.GetWarnings())
            {
                //Use these two parameters when the elements cannot have a phase create / demolished
                string pCreate = "";
                string pDemo   = "";

                //Set Issue Description to a string variable
                string description = warning.GetDescriptionText();

                //Check to see if the Warning Type list already has this Warning Type in it, and add it if not
                if (!warningType.Contains(description))
                {
                    warningType.Add(description);
                }

                //Get all of the Element Ids of the elements associated with the warning
                ICollection <ElementId> failingElements = warning.GetFailingElements();

                //This is a bit redundent because they are all "warnings" as "errors" can't be ignored, but if you use custom error handlers, this may be more useful
                FailureSeverity severity = warning.GetSeverity();

                //Check to make sure there are Element Ids for the elements. Some warning types (MECH Systems) do not always provide Element Ids
                if (failingElements.OfType <ElementId>().FirstOrDefault() is ElementId first)
                {
                    //Get the First element of the warning elements in the Document
                    Element elem = doc.GetElement(first);
                    //Set the parameter to the actual name instead of "None" from above
                    elemName = elem.Name;
                    //Checks to see if the Element has any phases associated with it and sets the pCreate and pDemo variables previousy defined
                    if (elem.HasPhases())
                    {
                        if (elem.CreatedPhaseId != ElementId.InvalidElementId)
                        {
                            pCreate = doc.GetElement(elem.CreatedPhaseId).Name;
                        }
                        if (elem.DemolishedPhaseId != ElementId.InvalidElementId)
                        {
                            pDemo = doc.GetElement(elem.DemolishedPhaseId).Name;
                        }
                    }
                    //Checks to see if the Document has Worksharing enables and gets the User informaiton associated with the creation of the element for refernce
                    if (doc.IsWorkshared)
                    {
                        userId = WorksharingUtils.GetWorksharingTooltipInfo(doc, first).Creator;
                    }
                }

                //Add a reow to the DataTable with all of the informaiton for the warning
                dtWarnings.Rows.Add(severity, description, failingElements, elemName, userId, pCreate, pDemo);
            }

            //Set the DataGridView's data source to the DataTable
            dgWarnings.DataSource = dtWarnings;
            //Change the AutoSize mode to fill the width of the DataGridView as it resizes
            dgWarnings.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            //Changes the text to include the number of Wanrings for reference to the User
            dgWarnings.Columns[1].HeaderText   = "Description (" + dtWarnings.Rows.Count.ToString() + ")";
            dgWarnings.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            //Hides the column that contains the Element Ids to keep the DataGridView clean
            dgWarnings.Columns[2].Visible      = false;
            dgWarnings.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dgWarnings.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dgWarnings.Columns[5].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dgWarnings.Columns[6].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            //Set the DataGridView to sort based on the Description
            dgWarnings.Sort(dgWarnings.Columns[1], System.ComponentModel.ListSortDirection.Ascending);
            //Clears the auto selection of any rows in the DataGridivew so no elements are selected initially
            dgWarnings.ClearSelection();

            //Clears the Warning Type combo box of all items
            cboWarningType.DataSource = null;
            //Reset the Warning Type combo box with the List of warnings Types
            cboWarningType.DataSource = warningType.ToList();
        }
Example #9
0
        private void LoadData(Document doc)
        {
            this.Doc = doc;
            List <ViewSheet> list  = this.AllViewSheets(doc);
            List <View>      list2 = new List <View>();

            foreach (ViewSheet viewSheet in list)
            {
                List <View> list3 = this.AllLegendInSheet(viewSheet, doc);
                bool        flag  = list3.Count < 1;
                if (!flag)
                {
                    foreach (View view in list3)
                    {
                        bool flag2 = this.Dic.ContainsKey(view.Id.IntegerValue);
                        if (flag2)
                        {
                            string str = string.Concat(new string[]
                            {
                                "  + [",
                                viewSheet.SheetNumber,
                                "_",
                                viewSheet.Name,
                                "]"
                            });
                            LegendExtension legendExtension = this.Dic[view.Id.IntegerValue];
                            legendExtension.ListSheets += str;
                        }
                        else
                        {
                            LegendExtension        legendExtension2       = new LegendExtension();
                            WorksharingTooltipInfo worksharingTooltipInfo = WorksharingUtils.GetWorksharingTooltipInfo(doc, view.Id);
                            legendExtension2.Name          = view.Name;
                            legendExtension2.Id            = view.Id.IntegerValue;
                            legendExtension2.Creator       = worksharingTooltipInfo.Creator;
                            legendExtension2.LastChangedBy = worksharingTooltipInfo.LastChangedBy;
                            legendExtension2.ListSheets    = string.Concat(new string[]
                            {
                                "[",
                                viewSheet.SheetNumber,
                                "_",
                                viewSheet.Name,
                                "]"
                            });
                            list2.Add(view);
                            this.Dic.Add(view.Id.IntegerValue, legendExtension2);
                        }
                    }
                }
            }
            foreach (View view2 in this.AllLegends(doc))
            {
                foreach (View view3 in list2)
                {
                    bool flag3 = view2.Id.IntegerValue == view3.Id.IntegerValue;
                    if (!flag3)
                    {
                        bool flag4 = this.Dic.ContainsKey(view2.Id.IntegerValue);
                        if (!flag4)
                        {
                            LegendExtension        legendExtension3        = new LegendExtension();
                            WorksharingTooltipInfo worksharingTooltipInfo2 = WorksharingUtils.GetWorksharingTooltipInfo(doc, view2.Id);
                            legendExtension3.Name          = view2.Name;
                            legendExtension3.Id            = view2.Id.IntegerValue;
                            legendExtension3.Creator       = worksharingTooltipInfo2.Creator;
                            legendExtension3.LastChangedBy = worksharingTooltipInfo2.LastChangedBy;
                            legendExtension3.ListSheets    = "";
                            this.Dic.Add(view2.Id.IntegerValue, legendExtension3);
                        }
                    }
                }
            }
        }