示例#1
0
        /***************************************************/
        /****               Public Methods              ****/
        /***************************************************/

        public static oM.Physical.Elements.Wall WallFromRevit(this Wall wall, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null)
        {
            if (wall == null)
            {
                return(null);
            }

            settings = settings.DefaultIfNull();

            oM.Physical.Elements.Wall bHoMWall = refObjects.GetValue <oM.Physical.Elements.Wall>(wall.Id);
            if (bHoMWall != null)
            {
                return(bHoMWall);
            }

            if (wall.StackedWallOwnerId != null && wall.StackedWallOwnerId != ElementId.InvalidElementId)
            {
                return(null);
            }

            if (wall.CurtainGrid != null)
            {
                bHoMWall = wall.WallFromRevit_Curtain(settings, refObjects);
            }
            else
            {
                bHoMWall = wall.WallFromRevit_Solid(settings, refObjects);
            }

            if (bHoMWall == null)
            {
                return(null);
            }

            HostObjAttributes hostObjAttributes = wall.Document.GetElement(wall.GetTypeId()) as HostObjAttributes;
            string            materialGrade     = wall.MaterialGrade(settings);

            oM.Physical.Constructions.Construction construction = hostObjAttributes.ConstructionFromRevit(materialGrade, settings, refObjects);
            bHoMWall.Construction = construction;

            bHoMWall.Name = wall.FamilyTypeFullName();

            //Set identifiers, parameters & custom data
            bHoMWall.SetIdentifiers(wall);
            bHoMWall.CopyParameters(wall, settings.ParameterSettings);
            bHoMWall.SetProperties(wall, settings.ParameterSettings);

            refObjects.AddOrReplace(wall.Id, bHoMWall);
            return(bHoMWall);
        }
示例#2
0
        /***************************************************/

        public static Element ToRevit(this oM.Physical.Elements.Wall wall, Document document, RevitSettings settings = null, Dictionary <Guid, List <int> > refObjects = null)
        {
            return(wall.ToRevitWall(document, settings, refObjects));
        }
示例#3
0
        /***************************************************/
        /****              Public methods               ****/
        /***************************************************/

        public static Wall ToRevitWall(this oM.Physical.Elements.Wall wall, Document document, RevitSettings settings = null, Dictionary <Guid, List <int> > refObjects = null)
        {
            if (wall == null || wall.Location == null || document == null)
            {
                return(null);
            }

            PlanarSurface planarSurface = wall.Location as PlanarSurface;

            if (planarSurface == null)
            {
                return(null);
            }

            Wall revitWall = refObjects.GetValue <Wall>(document, wall.BHoM_Guid);

            if (revitWall != null)
            {
                return(revitWall);
            }

            settings = settings.DefaultIfNull();

            WallType wallType = wall.Construction.ToRevitElementType(document, new List <BuiltInCategory> {
                BuiltInCategory.OST_Walls
            }, settings, refObjects) as WallType;

            if (wallType == null)
            {
                wallType = wall.ElementType(document, settings);
            }

            if (wallType == null)
            {
                Compute.ElementTypeNotFoundWarning(wall);
                return(null);
            }

            BoundingBox bbox = wall.Location.IBounds();

            if (bbox == null)
            {
                return(null);
            }

            double bottomElevation = bbox.Min.Z.FromSI(UnitType.UT_Length);
            double topElevation    = bbox.Max.Z.FromSI(UnitType.UT_Length);

            Level level = document.LevelBelow(bottomElevation, settings);

            if (level == null)
            {
                return(null);
            }

            revitWall = Wall.Create(document, planarSurface.ExternalBoundary.IToRevitCurves(), wallType.Id, level.Id, false);
            revitWall.CheckIfNullPush(wall);
            if (revitWall == null)
            {
                return(null);
            }

            // Copy parameters from BHoM object to Revit element
            revitWall.CopyParameters(wall, settings);

            // Update top and bottom offset constraints
            Level bottomLevel = document.GetElement(revitWall.LookupParameterElementId(BuiltInParameter.WALL_BASE_CONSTRAINT)) as Level;

            revitWall.SetParameter(BuiltInParameter.WALL_BASE_OFFSET, bottomElevation - bottomLevel.ProjectElevation, false);

            Level topLevel = document.GetElement(revitWall.LookupParameterElementId(BuiltInParameter.WALL_HEIGHT_TYPE)) as Level;

            if (topLevel != null)
            {
                revitWall.SetParameter(BuiltInParameter.WALL_TOP_OFFSET, topElevation - topLevel.ProjectElevation, false);
            }
            else
            {
                revitWall.SetParameter(BuiltInParameter.WALL_USER_HEIGHT_PARAM, topElevation - bottomElevation, false);
            }

            refObjects.AddOrReplace(wall, revitWall);
            return(revitWall);
        }