/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static oM.Environment.Elements.Panel EnvironmentPanelFromRevit(this FamilyInstance familyInstance, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null) { //Create a BuildingElement from the familyInstance geometry settings = settings.DefaultIfNull(); oM.Environment.Elements.Panel panel = refObjects.GetValue <oM.Environment.Elements.Panel>(familyInstance.Id); if (panel != null) { return(panel); } PlanarSurface openingSurface = familyInstance.OpeningSurface(null, settings) as PlanarSurface; ICurve outline = openingSurface?.ExternalBoundary; if (outline == null) { return(null); } panel = new oM.Environment.Elements.Panel() { ExternalEdges = outline.ToEdges(), Name = familyInstance.FamilyTypeFullName(), }; //Set ExtendedProperties OriginContextFragment originContext = new OriginContextFragment() { ElementID = familyInstance.Id.IntegerValue.ToString(), TypeName = familyInstance.FamilyTypeFullName() }; originContext.SetProperties(familyInstance.Symbol, settings.ParameterSettings); originContext.SetProperties(familyInstance, settings.ParameterSettings); panel.Fragments.Add(originContext); PanelAnalyticalFragment panelAnalytical = new PanelAnalyticalFragment(); panelAnalytical.SetProperties(familyInstance.Symbol, settings.ParameterSettings); panelAnalytical.SetProperties(familyInstance, settings.ParameterSettings); panel.Fragments.Add(panelAnalytical); PanelContextFragment panelContext = new PanelContextFragment(); panelContext.SetProperties(familyInstance.Symbol, settings.ParameterSettings); panelContext.SetProperties(familyInstance, settings.ParameterSettings); panel.Fragments.Add(panelContext); BuildingResultFragment buildingResults = new BuildingResultFragment(); buildingResults.SetProperties(familyInstance.Symbol, settings.ParameterSettings); buildingResults.SetProperties(familyInstance, settings.ParameterSettings); panel.Fragments.Add(buildingResults); oM.Environment.Elements.PanelType?panelType = familyInstance.Category.PanelType(); if (panelType.HasValue) { panel.Type = panelType.Value; } else { panel.Type = oM.Environment.Elements.PanelType.Undefined; } //Set identifiers, parameters & custom data panel.SetIdentifiers(familyInstance); panel.CopyParameters(familyInstance, settings.ParameterSettings); panel.SetProperties(familyInstance, settings.ParameterSettings); refObjects.AddOrReplace(familyInstance.Id, panel); return(panel); }
/***************************************************/ /**** Internal Methods ****/ /***************************************************/ internal static oM.Environment.Elements.Panel EnvironmentPanelFromRevit(this Element element, ICurve crv, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null) { settings = settings.DefaultIfNull(); oM.Environment.Elements.Panel panel = refObjects.GetValue <oM.Environment.Elements.Panel>(element.Id); if (panel != null) { return(panel); } ElementType elementType = element.Document.GetElement(element.GetTypeId()) as ElementType; panel = new oM.Environment.Elements.Panel() { ExternalEdges = crv.ToEdges(), Name = element.FamilyTypeFullName(), }; //Set ExtendedProperties OriginContextFragment originContext = new OriginContextFragment() { ElementID = element.Id.IntegerValue.ToString(), TypeName = element.FamilyTypeFullName() }; originContext.SetProperties(element, settings.ParameterSettings); originContext.SetProperties(elementType, settings.ParameterSettings); panel.Fragments.Add(originContext); PanelAnalyticalFragment panelAnalytical = new PanelAnalyticalFragment(); panelAnalytical.SetProperties(element, settings.ParameterSettings); panelAnalytical.SetProperties(elementType, settings.ParameterSettings); panel.Fragments.Add(panelAnalytical); PanelContextFragment panelContext = new PanelContextFragment(); panelContext.SetProperties(element, settings.ParameterSettings); panelContext.SetProperties(elementType, settings.ParameterSettings); panel.Fragments.Add(panelContext); BuildingResultFragment buildingResults = new BuildingResultFragment(); buildingResults.SetProperties(element, settings.ParameterSettings); buildingResults.SetProperties(elementType, settings.ParameterSettings); panel.Fragments.Add(buildingResults); oM.Environment.Elements.PanelType?panelType = element.Category.PanelType(); if (panelType.HasValue) { panel.Type = panelType.Value; } else { panel.Type = oM.Environment.Elements.PanelType.Undefined; } //Set identifiers, parameters & custom data panel.SetIdentifiers(element); panel.CopyParameters(element, settings.ParameterSettings); panel.SetProperties(element, settings.ParameterSettings); refObjects.AddOrReplace(element.Id, panel); return(panel); }
/***************************************************/ public static List <oM.Environment.Elements.Panel> EnvironmentPanelsFromRevit(this Wall wall, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null) { settings = settings.DefaultIfNull(); List <oM.Environment.Elements.Panel> panels = refObjects.GetValues <oM.Environment.Elements.Panel>(wall.Id); if (panels != null && panels.Count > 0) { return(panels); } if (wall.StackedWallOwnerId != null && wall.StackedWallOwnerId != ElementId.InvalidElementId) { return(null); } Dictionary <PlanarSurface, List <PlanarSurface> > surfaces = wall.PanelSurfaces(wall.FindInserts(true, true, true, true), settings); if (surfaces == null) { return(panels); } BH.oM.Physical.Constructions.Construction constrtuction = wall.WallType.ConstructionFromRevit(null, settings, refObjects); panels = new List <oM.Environment.Elements.Panel>(); foreach (PlanarSurface surface in surfaces.Keys) { //Create the BuildingElement oM.Environment.Elements.Panel panel = new oM.Environment.Elements.Panel() { ExternalEdges = surface.ExternalBoundary.ToEdges(), Name = wall.FamilyTypeFullName(), }; //Set ExtendedProperties OriginContextFragment originContext = new OriginContextFragment() { ElementID = wall.Id.IntegerValue.ToString(), TypeName = wall.FamilyTypeFullName() }; originContext.SetProperties(wall.WallType, settings.ParameterSettings); originContext.SetProperties(wall, settings.ParameterSettings); panel.AddFragment(originContext); PanelAnalyticalFragment panelAnalytical = new PanelAnalyticalFragment(); panelAnalytical.SetProperties(wall.WallType, settings.ParameterSettings); panelAnalytical.SetProperties(wall, settings.ParameterSettings); panel.AddFragment(panelAnalytical); PanelContextFragment panelContext = new PanelContextFragment(); panelContext.SetProperties(wall.WallType, settings.ParameterSettings); panelContext.SetProperties(wall, settings.ParameterSettings); panel.AddFragment(panelContext); BuildingResultFragment buildingResults = new BuildingResultFragment(); buildingResults.SetProperties(wall.WallType, settings.ParameterSettings); buildingResults.SetProperties(wall, settings.ParameterSettings); panel.AddFragment(buildingResults); panel.Construction = constrtuction; panel.Type = oM.Environment.Elements.PanelType.Wall; //Set identifiers, parameters & custom data panel.SetIdentifiers(wall); panel.CopyParameters(wall, settings.ParameterSettings); panel.SetProperties(wall, settings.ParameterSettings); refObjects.AddOrReplace(wall.Id, panel); panels.Add(panel); } return(panels); }