Example #1
0
 /// <summary>
 /// Update BCFView to have consistent values with the MainWindow
 /// </summary>
 private void UpdateBCFView()
 {
     try
     {
         selectedComponent = filteredComponents[selectedComponentIndex];
         int       fileIndex         = bcfView.SelectedIndex;
         int       markupIndex       = bcfView.BCFFiles[fileIndex].SelectedMarkup;
         ViewPoint selectedViewpoint = bcfView.BCFFiles[fileIndex].Markups[markupIndex].SelectedViewpoint;
         int       viewpointIndex    = bcfView.BCFFiles[fileIndex].Markups[markupIndex].Viewpoints.IndexOf(selectedViewpoint);
         var       componentFound    = from comp in selectedViewpoint.VisInfo.Components where comp.Guid == selectedComponent.Guid select comp;
         if (componentFound.Count() > 0)
         {
             int componentIndex = selectedViewpoint.VisInfo.Components.IndexOf(componentFound.First());
             if (componentIndex > -1)
             {
                 bcfView.BCFFiles[fileIndex].Markups[markupIndex].Viewpoints[viewpointIndex].VisInfo.Components[componentIndex].Action         = filteredComponents[selectedComponentIndex].Action;
                 bcfView.BCFFiles[fileIndex].Markups[markupIndex].Viewpoints[viewpointIndex].VisInfo.Components[componentIndex].Responsibility = filteredComponents[selectedComponentIndex].Responsibility;
                 bcfView.BCFFiles[fileIndex].Markups[markupIndex].SelectedViewpoint = bcfView.BCFFiles[fileIndex].Markups[markupIndex].Viewpoints[viewpointIndex];
             }
         }
     }
     catch (Exception ex)
     {
         string message = ex.Message;
     }
 }
Example #2
0
 /// <summary>
 /// Move to the next component
 /// </summary>
 /// <param name="param"></param>
 public void MoveComponentExecuted(object param)
 {
     try
     {
         if (null != param)
         {
             string direction = param.ToString().ToLower();
             if (direction == "forward")
             {
                 if (selectedComponentIndex < filteredComponents.Count - 1)
                 {
                     int index = selectedComponentIndex + 1;
                     selectedComponent           = filteredComponents[index];
                     this.SelectedComponentIndex = index;
                 }
             }
             else if (direction == "backward")
             {
                 if (selectedComponentIndex > 0)
                 {
                     int index = selectedComponentIndex - 1;
                     selectedComponent           = filteredComponents[index];
                     this.SelectedComponentIndex = index;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         string message = ex.Message;
     }
 }
        public Dictionary <string, RevitComponent> CollectElementInfo()
        {
            Dictionary <string, RevitComponent> dictionary = new Dictionary <string, RevitComponent>();

            try
            {
                foreach (RevitLinkProperties rlp in linkDictionary.Values)
                {
                    Document doc = rlp.LinkedDocument;
                    FilteredElementCollector collector     = new FilteredElementCollector(doc);
                    IList <Element>          foundElements = collector
                                                             .WhereElementIsNotElementType()
                                                             .WhereElementIsViewIndependent()
                                                             .WherePasses(new LogicalOrFilter(new ElementIsElementTypeFilter(false), new ElementIsElementTypeFilter(true))).ToElements();

                    var distinctElements = from elem in foundElements select elem;
#if RELEASE2014
                    var elementsFiltered = from elem in distinctElements where null != elem.Category select elem;
#else
                    var elementsFiltered = from elem in distinctElements where null != elem.Category && elem.Category.CategoryType == CategoryType.Model select elem;
#endif

                    if (elementsFiltered.Count() > 0)
                    {
                        foreach (Element element in elementsFiltered)
                        {
                            RevitComponent rvtComp = new RevitComponent()
                            {
                                ElementId      = element.Id,
                                IfcGuid        = element.IfcGUID(),
                                IfcProjectGuid = rlp.IfcProjectGuid
                            };

                            if (!dictionary.ContainsKey(rvtComp.IfcGuid))
                            {
                                dictionary.Add(rvtComp.IfcGuid, rvtComp);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
            return(dictionary);
        }
Example #4
0
        public void ApplyViewExecuted(object param)
        {
            try
            {
                selectedComponent = filteredComponents[selectedComponentIndex];
                if (selectedComponent.IsLinked)
                {
                    this.IsHighlightChecked = false;
                    this.IsIsolateChecked   = false;
                }

                m_handler.ViewModel = this;
                m_handler.Request.Make(RequestId.ApplyViews);
                m_event.Raise();
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
        }
Example #5
0
        /// <summary>
        /// Refresh components after selection of topic or viewpoint is changed
        /// </summary>
        public void RefreshComponents()
        {
            try
            {
                this.SelectedBCF    = bcfView.BCFFiles[bcfView.SelectedIndex];
                this.SelectedMarkup = selectedBCF.Markups[selectedBCF.SelectedMarkup];
                ViewPoint selectedViewPoint = selectedMarkup.SelectedViewpoint;
                if (null != selectedViewPoint)
                {
                    int viewpointInex = selectedMarkup.Viewpoints.IndexOf(selectedViewPoint);

                    this.Comments        = new ObservableCollection <Comment>();
                    this.SelectedComment = null;

                    var commentFound = from comment in selectedMarkup.Comment where comment.Viewpoint.Guid == selectedViewPoint.Guid select comment;
                    if (commentFound.Count() > 0)
                    {
                        this.Comments        = new ObservableCollection <Comment>(commentFound.ToList());
                        this.SelectedComment = comments[0];
                    }

                    if (null != selectedViewPoint.VisInfo)
                    {
                        this.SelectedComponent      = null;
                        this.SelectedComponentIndex = -1;
                        this.RvtComponents.Clear();

                        var           selectedProjects = from header in selectedMarkup.Header where linkDictionary.ContainsKey(header.IfcProject) select header.IfcProject;
                        List <string> ifcProjectGuids  = (selectedProjects.Count() > 0) ? selectedProjects.ToList() : linkDictionary.Keys.ToList();

                        ObservableCollection <Component> componentsToUpdate = new ObservableCollection <Component>();
                        foreach (Component comp in selectedViewPoint.VisInfo.Components)
                        {
                            int            compIndex    = selectedViewPoint.VisInfo.Components.IndexOf(comp);
                            RevitComponent rvtComponent = null;

                            if (!string.IsNullOrEmpty(comp.IfcGuid) && compDictionary.ContainsKey(comp.IfcGuid))
                            {
                                RevitComponent sampleComp = compDictionary[comp.IfcGuid];
                                if (linkDictionary.ContainsKey(sampleComp.IfcProjectGuid))
                                {
                                    RevitLinkProperties rlp         = linkDictionary[sampleComp.IfcProjectGuid];
                                    Element             compElement = rlp.LinkedDocument.GetElement(sampleComp.ElementId);
                                    if (null != compElement)
                                    {
                                        rvtComponent = new RevitComponent(comp, compElement, rlp);
                                    }
                                }
                            }

                            if (null != rvtComponent)
                            {
                                var foundAction = from ext in selectedBCF.ExtensionColor.Extensions where ext.Guid == rvtComponent.Action.Guid select ext;
                                if (foundAction.Count() > 0)
                                {
                                    rvtComponent.Action = foundAction.First();
                                }

                                var foundResponsibility = from ext in selectedBCF.ExtensionColor.Extensions where ext.Guid == rvtComponent.Responsibility.Guid select ext;
                                if (foundResponsibility.Count() > 0)
                                {
                                    rvtComponent.Responsibility = foundResponsibility.First();
                                }

                                if (string.IsNullOrEmpty(comp.ElementName))
                                {
                                    componentsToUpdate.Add(comp);

                                    bcfView.BCFFiles[bcfView.SelectedIndex].Markups[selectedBCF.SelectedMarkup].Viewpoints[viewpointInex].VisInfo.Components[compIndex].ElementName = rvtComponent.ElementName;
                                }
                                this.RvtComponents.Add(rvtComponent);
                            }
                        }

                        if (componentsToUpdate.Count > 0)
                        {
                            bool updatedDB = BCFDBWriter.BCFDBWriter.UpdateComponents(componentsToUpdate);
                        }

                        ApplyCategoryFilter();

                        UpdateBackgroundView();
                    }
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
        }