예제 #1
0
        public static void CreateBox(ClashItems elements)
        {
            View activeView = (View3D)RevitTools.Doc.ActiveView;

            if (MainUserControl._CropBox)
            {
                BoundingBoxXYZ boundingBoxXYZ = elements.ElementA.get_BoundingBox(activeView);
                activeView.CropBox = boundingBoxXYZ;
            }
            else
            {
                activeView.CropBox = null;
            }
        }
예제 #2
0
        public static void Focus(ClashItems elements)
        {
            if (MainUserControl._CropBox)
            {
                CreateBox(elements);
            }
            View activeView = RevitTools.Doc.ActiveView;

            ResetView();
            var listOfId = new List <ElementId>();

            listOfId.Add(elements.ElementA.Id);
            listOfId.Add(elements.ElementB.Id);
            RevitTools.Uidoc.Selection.SetElementIds(listOfId);
            RevitTools.Uidoc.ShowElements(listOfId);
        }
예제 #3
0
        public static List <ClashItems> clashingElements(Document doc, Application app, Document link = null)
        {
            //TODO : Create a separate addin to save configuration

            var linkedElements    = new List <Element>();
            var localElements     = new List <Element>();
            var ClashingElementsA = new List <Element>();
            var ClashingElementsB = new List <Element>();

            //If second document was not provided, use first doc
            var SecondDocument = FormTools.linkedDocument == null ? doc : FormTools.linkedDocument;

            //Get the transformation of the linked model from the project location
            var transform = GetTransform(doc, SecondDocument);

            Autodesk.Revit.DB.Options opt = new Options();
            var ActiveViewBB = doc.ActiveView as View3D;

            //Hard coded selection
            LogicalOrFilter          filterLinkedCategories = new LogicalOrFilter(FormTools.SelectedCategories);
            FilteredElementCollector collector = new FilteredElementCollector(SecondDocument).WherePasses(filterLinkedCategories).WhereElementIsNotElementType();

            linkedElements = collector.ToElements() as List <Element>;

            var ClashItemsList = new List <ClashItems>();

            foreach (Element elementB in linkedElements)
            {
                GeometryElement geom           = elementB.get_Geometry(opt);
                GeometryElement geomTranslated = geom;
                // Get bounding box from transformed geometry
                // By default use element geoemtry to extract bbox
                var bbox = geom.GetBoundingBox();
                if (transform != null)
                {
                    //If translation is valid, use it to override the bbox
                    geomTranslated = geom.GetTransformed(transform);
                    bbox           = geomTranslated.GetBoundingBox();
                }

                if (belongsToView(ActiveViewBB, bbox))
                {
                    //VisibleLinkedElements.Add(geomTranslated);
                    Outline outline = new Outline(bbox.Min, bbox.Max);
                    BoundingBoxIntersectsFilter bbFilter = new BoundingBoxIntersectsFilter(outline);

                    LogicalOrFilter logicalOrFilter = new LogicalOrFilter(FormTools.SelectedHostCategories);

                    FilteredElementCollector bbClashingCollector = new FilteredElementCollector(doc, doc.ActiveView.Id).WherePasses(logicalOrFilter).WherePasses(bbFilter);

                    foreach (Element elementA in bbClashingCollector.ToElements())
                    {
                        if (!ClashingElementsA.Contains(elementA))
                        {
                            if (getClashWithSolid(doc, geomTranslated, elementA))
                            {
                                ClashItems clashItems = new ClashItems
                                {
                                    ElementA = elementA,
                                    ElementB = elementB
                                };

                                ClashItemsList.Add(clashItems);
                            }
                        }
                    }
                }
            }

            return(ClashItemsList);
        }