/***************************************************/ /**** Public methods ****/ /***************************************************/ public static List <IOpening> CurtainPanels(this CurtainGrid curtainGrid, Document document, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null) { if (curtainGrid == null) { return(null); } List <IOpening> result = new List <IOpening>(); List <Element> panels = curtainGrid.GetPanelIds().Select(x => document.GetElement(x)).ToList(); List <CurtainCell> cells = curtainGrid.GetCurtainCells().ToList(); if (panels.Count != cells.Count) { return(null); } for (int i = 0; i < panels.Count; i++) { FamilyInstance panel = panels[i] as FamilyInstance; if (panel == null || panel.get_BoundingBox(null) == null) { continue; } foreach (PolyCurve pc in cells[i].CurveLoops.FromRevit()) { if (panel.Category.Id.IntegerValue == (int)Autodesk.Revit.DB.BuiltInCategory.OST_Doors) { result.Add(panel.DoorFromRevit(settings, refObjects)); } else { result.Add(panel.WindowFromRevit(settings, refObjects)); } } } return(result); }
/***************************************************/ public static IEnumerable <IBHoMObject> FromRevit(this FamilyInstance familyInstance, Discipline discipline, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null) { switch (discipline) { case Discipline.Structural: if (typeof(BH.oM.Structure.Elements.Bar).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue)) { return(familyInstance.BarsFromRevit(settings, refObjects).Cast <IBHoMObject>()); } else { return(null); } case Discipline.Physical: case Discipline.Architecture: if (typeof(BH.oM.Physical.Elements.Window).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue)) { return new List <IBHoMObject> { familyInstance.WindowFromRevit(settings, refObjects) } } ; if (typeof(BH.oM.Physical.Elements.Door).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue)) { return new List <IBHoMObject> { familyInstance.DoorFromRevit(settings, refObjects) } } ; if (typeof(BH.oM.Physical.Elements.Column).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue) || familyInstance.StructuralType == StructuralType.Column) { return new List <IBHoMObject> { familyInstance.ColumnFromRevit(settings, refObjects) } } ; if (typeof(BH.oM.Physical.Elements.Bracing).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue) || familyInstance.StructuralType == StructuralType.Brace) { return new List <IBHoMObject> { familyInstance.BracingFromRevit(settings, refObjects) } } ; if (typeof(BH.oM.Physical.Elements.Beam).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue)) { return new List <IBHoMObject> { familyInstance.BeamFromRevit(settings, refObjects) } } ; else { return(null); } case Discipline.Environmental: return(new List <IBHoMObject> { familyInstance.EnvironmentPanelFromRevit(settings, refObjects) }); default: return(null); } }
/***************************************************/ public static IEnumerable <IBHoMObject> FromRevit(this FamilyInstance familyInstance, Discipline discipline, Transform transform = null, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null) { if (AdaptiveComponentInstanceUtils.IsAdaptiveComponentInstance(familyInstance)) { BH.oM.Adapters.Revit.Elements.ModelInstance instance = familyInstance.ModelInstanceFromRevit(settings, refObjects); if (instance != null && transform?.IsIdentity == false) { TransformMatrix bHoMTransform = transform.FromRevit(); instance = instance.Transform(bHoMTransform) as BH.oM.Adapters.Revit.Elements.ModelInstance; } return(new List <IBHoMObject> { instance }); } else { IEnumerable <IElement> result = null; switch (discipline) { case Discipline.Structural: if (typeof(Bar).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue)) { result = familyInstance.BarsFromRevit(settings, refObjects); } break; case Discipline.Physical: case Discipline.Architecture: if (typeof(BH.oM.Physical.Elements.Window).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue)) { result = new List <IElement> { familyInstance.WindowFromRevit(settings, refObjects) } } ; else if (typeof(BH.oM.Physical.Elements.Door).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue)) { result = new List <IElement> { familyInstance.DoorFromRevit(settings, refObjects) } } ; else if (typeof(BH.oM.Physical.Elements.Column).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue) || familyInstance.StructuralType == StructuralType.Column) { result = new List <IElement> { familyInstance.ColumnFromRevit(settings, refObjects) } } ; else if (typeof(BH.oM.Physical.Elements.Bracing).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue) || familyInstance.StructuralType == StructuralType.Brace) { result = new List <IElement> { familyInstance.BracingFromRevit(settings, refObjects) } } ; else if (typeof(BH.oM.Physical.Elements.Beam).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue)) { result = new List <IElement> { familyInstance.BeamFromRevit(settings, refObjects) } } ; break; case Discipline.Environmental: result = new List <IElement> { familyInstance.EnvironmentPanelFromRevit(settings, refObjects) }; break; case Discipline.Facade: if (typeof(BH.oM.Facade.Elements.Opening).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue)) { result = new List <IElement> { familyInstance.FacadeOpeningFromRevit(settings, refObjects) } } ; else if (typeof(BH.oM.Facade.Elements.FrameEdge).BuiltInCategories().Contains((BuiltInCategory)familyInstance.Category.Id.IntegerValue)) { result = new List <IElement> { familyInstance.FrameEdgeFromRevit(settings, refObjects) } } ; break; } if (result != null && transform?.IsIdentity == false) { TransformMatrix bHoMTransform = transform.FromRevit(); result = result.Select(x => x?.ITransform(bHoMTransform)); } return(result?.Cast <IBHoMObject>().ToList()); } }
/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static Door DoorFromRevit(this FamilyInstance familyInstance, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null) { return(familyInstance.DoorFromRevit(null, settings, refObjects)); }