public static IHostPartition Transform(Transform transform, IHostPartition hostPartition) { if (transform == null || hostPartition == null) { return(null); } IHostPartition result = Analytical.Create.HostPartition(hostPartition.Guid, Geometry.Revit.Query.Transform(transform, hostPartition.Face3D), hostPartition.Type()); List <IOpening> openings = hostPartition.GetOpenings(); if (openings != null) { foreach (IOpening opening in openings) { result.AddOpening(Transform(transform, opening)); } } return(result); }
public static List <IPartition> ToSAM_Partitions(this HostObject hostObject, ConvertSettings convertSettings) { if (hostObject == null) { return(null); } List <IPartition> result = convertSettings?.GetObjects <IPartition>(hostObject.Id); if (result != null) { return(result); } ElementId elementId_Type = hostObject.GetTypeId(); if (elementId_Type == null || elementId_Type == ElementId.InvalidElementId) { return(null); } HostPartitionType hostPartitionType = ((HostObjAttributes)hostObject.Document.GetElement(elementId_Type)).ToSAM_HostPartitionType(convertSettings); if (hostPartitionType == null) { return(null); } List <Face3D> face3Ds = hostObject.Profiles(); if (face3Ds == null || face3Ds.Count == 0) { return(null); } LogicalOrFilter logicalOrFilter = new LogicalOrFilter(new List <ElementFilter>() { new ElementCategoryFilter(BuiltInCategory.OST_Windows), new ElementCategoryFilter(BuiltInCategory.OST_Doors) }); #if Revit2017 IEnumerable <ElementId> elementIds = null; #else IEnumerable <ElementId> elementIds = hostObject.GetDependentElements(logicalOrFilter); #endif if (hostObject is Autodesk.Revit.DB.Wall || hostObject is CurtainSystem) { List <Autodesk.Revit.DB.Panel> panels = Core.Revit.Query.Panels(hostObject as dynamic); if (panels != null && panels.Count > 0) { List <ElementId> elementIds_Temp = panels.ConvertAll(x => x.Id); if (elementIds != null && elementIds.Count() > 0) { elementIds_Temp.AddRange(elementIds); } elementIds = elementIds_Temp; } } result = new List <IPartition>(); foreach (Face3D face3D in face3Ds) { if (face3D == null) { continue; } IHostPartition hostPartition = Analytical.Create.HostPartition(face3D, hostPartitionType); hostPartition.UpdateParameterSets(hostObject); if (elementIds != null && elementIds.Count() > 0) { foreach (ElementId elementId in elementIds) { Element element = hostObject.Document.GetElement(elementId); if (element == null) { continue; } if (!(element is FamilyInstance)) { continue; } IOpening opening = ToSAM_Opening((FamilyInstance)element, convertSettings); if (opening != null) { opening = Analytical.Query.Project(hostPartition, opening); hostPartition.AddOpening(opening); } } } result.Add(hostPartition); } convertSettings?.Add(hostObject.Id, result); return(result); }
public static HoneybeeSchema.Door ToLadybugTools(this IOpening opening, BuildingModel buildingModel, Space space) { if (opening == null || buildingModel == null) { return(null); } OpeningType openingType = opening.Type(); if (openingType == null) { return(null); } //Opaque Windows to be replaced by Doors if (opening is Window && buildingModel.GetMaterialType(openingType.PaneMaterialLayers) != MaterialType.Opaque) { return(null); } IHostPartition hostPartition = buildingModel.GetHostPartition(opening); int index = -1; int index_Adjacent = -1; List <Space> spaces = null; if (hostPartition != null) { spaces = buildingModel.GetSpaces(hostPartition); if (spaces != null && spaces.Count != 0) { index = spaces.FindIndex(x => x.Guid == space.Guid); index = buildingModel.UniqueIndex(spaces[index]); index_Adjacent = spaces.FindIndex(x => x.Guid != space.Guid); index_Adjacent = buildingModel.UniqueIndex(spaces[index_Adjacent]); } } HoneybeeSchema.AnyOf <Outdoors, Surface> anyOf = null; if (index == -1 || index_Adjacent == -1) { anyOf = new Outdoors(); } else { bool reversed = index_Adjacent < index; List <string> uniqueNames = new List <string>(); uniqueNames.Add(Core.LadybugTools.Query.UniqueName(opening as SAMObject, index_Adjacent)); uniqueNames.Add(Query.UniqueName(hostPartition, index_Adjacent)); uniqueNames.Add(Query.UniqueName(spaces[index_Adjacent])); anyOf = new Surface(uniqueNames); } Face3D face3D = Geometry.LadybugTools.Convert.ToLadybugTools(opening); DoorEnergyPropertiesAbridged doorEnergyPropertiesAbridged = new DoorEnergyPropertiesAbridged(construction: Query.UniqueName(opening.Type(), !(index_Adjacent != -1 && index <= index_Adjacent))); return(new HoneybeeSchema.Door( identifier: Core.LadybugTools.Query.UniqueName(opening as SAMObject, index), geometry: face3D, boundaryCondition: anyOf, properties: new DoorPropertiesAbridged(doorEnergyPropertiesAbridged), displayName: opening.Name)); }