예제 #1
0
        private static List <FamilyInstance> placeShoresForClearShoreHeights(BuildingLoadModel buildingLoadModel, Level topLevel, IEnumerable <FamilySymbol> familySymbols)
        {
            Document _doc = topLevel.Document;

            List <FamilyInstance> _temporaryShores = new List <FamilyInstance>();

            foreach (LevelLoadModel _levelLoadModel in buildingLoadModel.LevelLoadModels)
            {
                if (_levelLoadModel.Level.Id == topLevel.Id)
                {
                    continue;
                }

                foreach (FamilySymbol _familySymbol in familySymbols)
                {
                    FamilyInstance _temporaryShore = _doc.Create.NewFamilyInstance(new XYZ(0, 0, _levelLoadModel.Level.Elevation), _familySymbol, Autodesk.Revit.DB.Structure.StructuralType.Column);
                    _temporaryShore?.LookupParameter("Height")?.Set(_levelLoadModel.ClearShoreHeight);

                    _temporaryShores.Add(_temporaryShore);
                }
            }

            _doc.Regenerate();

            return(_temporaryShores);
        }
예제 #2
0
        private static void addLevelLoadModels(BuildingLoadModel buildingLoadModel, IEnumerable <Level> levels, IEnumerable <Floor> floors, Level _topLevel, IEnumerable <ILoadModel> loadModels)
        {
            double _concreteDensityPoundsForcePerCubicFoot = 153.0;

            LevelLoadModel _levelLoadModelAbove = null;

            foreach (Level _level in levels)
            {
                Floor _levelFloor = floors.FirstOrDefault(p => p.LevelId == _level.Id);

                double _floorThickness = _levelFloor == null
                    ? 0.0
                    : _levelFloor.get_Parameter(BuiltInParameter.FLOOR_ATTR_THICKNESS_PARAM).AsDouble();

                BoundingBoxXYZ _levelFloorBounds = _levelFloor.get_BoundingBox(null);

                double _topOfSlabElevation = _levelFloorBounds == null
                    ? 0.0
                    : _levelFloorBounds.Max.Z;

                double _bottomOfSlabElevation = _levelFloorBounds == null
                    ? 0.0
                    : _levelFloorBounds.Min.Z;

                LevelLoadModel _levelLoadModel = new LevelLoadModel()
                {
                    Name                      = _level.Name,
                    Level                     = _level,
                    ElevationFeet             = _level.Elevation,
                    ConcreteDepthFeet         = _floorThickness,
                    TopOfSlabElevationFeet    = _topOfSlabElevation,
                    BottomOfSlabElevationFeet = _bottomOfSlabElevation,
                    ClearShoreHeight          = _levelLoadModelAbove == null
                        ? 0.0
                        : _levelLoadModelAbove.BottomOfSlabElevationFeet - _topOfSlabElevation,
                };

                _levelLoadModel.LoadModels.AddRange(loadModels.Where(p => p.Name == _levelLoadModel.Name));
                _levelLoadModel.addFloorDemandLoadModel(_levelFloor, _concreteDensityPoundsForcePerCubicFoot * _floorThickness);

                buildingLoadModel.LevelLoadModels.Add(_levelLoadModel);

                _levelLoadModelAbove = _levelLoadModel;
            }
        }
        public static Result CreateVisualizationSheets(UIDocument uiDoc)
        {
            //ToDo: these objects would be better passed to/from a UI, or possibly stored somewhere as settings

            BuildingLoadModel _buildingLoadModel = new BuildingLoadModel(0, 0, 7.0, 7.0, 7.0, 7.0, 7.0);

            List <ILoadModel> _levelLiveLoadPerSquareFoots = new List <ILoadModel>
            {
                LoadModel.Create("ROOF", LoadType.Capacity, 40),
                LoadModel.Create("Level 18", LoadType.Capacity, 24),
                LoadModel.Create("Level 17", LoadType.Capacity, 24),
                LoadModel.Create("Level 16", LoadType.Capacity, 24),
                LoadModel.Create("Level 15", LoadType.Capacity, 24),
                LoadModel.Create("Level 14", LoadType.Capacity, 24),
                LoadModel.Create("Level 13", LoadType.Capacity, 24),
                LoadModel.Create("Level 12", LoadType.Capacity, 24),
                LoadModel.Create("Level 11", LoadType.Capacity, 24),
                LoadModel.Create("Level 10", LoadType.Capacity, 24),
                LoadModel.Create("Level 09", LoadType.Capacity, 24),
                LoadModel.Create("Level 08", LoadType.Capacity, 24),
                LoadModel.Create("Level 07", LoadType.Capacity, 24),
                LoadModel.Create("Level 06", LoadType.Capacity, 24),
                LoadModel.Create("Level 05", LoadType.Capacity, 24),
                LoadModel.Create("Level 04", LoadType.Capacity, 24),
                LoadModel.Create("Level 03", LoadType.Capacity, 24),
                LoadModel.Create("Level 02", LoadType.Capacity, 100),
                LoadModel.Create("Level 01", LoadType.Capacity, 100),
                LoadModel.Create("P01", LoadType.Capacity, 40),
                LoadModel.Create("P02", LoadType.Capacity, 40),
                LoadModel.Create("P03", LoadType.Capacity, 40),
                LoadModel.Create("P04", LoadType.Capacity, 40),
                LoadModel.Create("P05", LoadType.Capacity, 40),

                LoadModel.Create("ROOF", LoadType.LiveLoad, 40),
                LoadModel.Create("Level 18", LoadType.LiveLoad, 40),
                LoadModel.Create("Level 17", LoadType.LiveLoad, 40),
                LoadModel.Create("Level 16", LoadType.LiveLoad, 40),
                LoadModel.Create("Level 15", LoadType.LiveLoad, 40),
                LoadModel.Create("Level 14", LoadType.LiveLoad, 40),
                LoadModel.Create("Level 13", LoadType.LiveLoad, 40),
                LoadModel.Create("Level 12", LoadType.LiveLoad, 40),
                LoadModel.Create("Level 11", LoadType.LiveLoad, 40),
                LoadModel.Create("Level 10", LoadType.LiveLoad, 40),
                LoadModel.Create("Level 09", LoadType.LiveLoad, 40),
                LoadModel.Create("Level 08", LoadType.LiveLoad, 40),
                LoadModel.Create("Level 07", LoadType.LiveLoad, 40),
                LoadModel.Create("Level 06", LoadType.LiveLoad, 40),
                LoadModel.Create("Level 05", LoadType.LiveLoad, 40),
                LoadModel.Create("Level 04", LoadType.LiveLoad, 40),
                LoadModel.Create("Level 03", LoadType.LiveLoad, 40),
                LoadModel.Create("Level 02", LoadType.LiveLoad, 100),
                LoadModel.Create("Level 01", LoadType.LiveLoad, 100),
                LoadModel.Create("P01", LoadType.LiveLoad, 45),
                LoadModel.Create("P02", LoadType.LiveLoad, 45),
                LoadModel.Create("P03", LoadType.LiveLoad, 45),
                LoadModel.Create("P04", LoadType.LiveLoad, 45),
                LoadModel.Create("P05", LoadType.LiveLoad, 45),

                LoadModel.Create("Level 18", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                LoadModel.Create("Level 17", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                LoadModel.Create("Level 16", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                LoadModel.Create("Level 15", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                LoadModel.Create("Level 14", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                LoadModel.Create("Level 13", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                LoadModel.Create("Level 12", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                LoadModel.Create("Level 11", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                LoadModel.Create("Level 10", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                LoadModel.Create("Level 09", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                LoadModel.Create("Level 08", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                LoadModel.Create("Level 07", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                LoadModel.Create("Level 06", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                LoadModel.Create("Level 05", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                LoadModel.Create("Level 04", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                LoadModel.Create("Level 03", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                LoadModel.Create("Level 02", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                LoadModel.Create("Level 01", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                LoadModel.Create("P01", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                LoadModel.Create("P02", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                LoadModel.Create("P03", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                LoadModel.Create("P04", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                LoadModel.Create("P05", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
            };

            Result _result = Result.Cancelled;

            using (Transaction _trans = new Transaction(uiDoc.Document, "Create Visualization View"))
            {
                _trans.Start();
                try
                {
                    _result = createVisualizationSheets(uiDoc, _buildingLoadModel, _levelLiveLoadPerSquareFoots);

                    _trans.Commit();
                }
                catch (Exception _ex)
                {
                    _trans.RollBack();
#if DEBUG
                    string _error = _ex.Message + Environment.NewLine + Environment.NewLine + _ex.StackTrace;
                    TaskDialog.Show("Error", _error);
#endif
                    return(Result.Failed);
                }
            }

            return(_result);
        }
        private static Result createVisualizationSheets(UIDocument uiDoc, BuildingLoadModel buildingLoadModel, IEnumerable <ILoadModel> levelLiveLoadPerSquareFoots)
        {
            //Setup
            Document _doc = uiDoc.Document;

            double _concreteDensityPoundsForcePerCubicFoot = 153.0;

            XYZ _capacityViewCoordinate = new XYZ(2.17649771769026, 0.766954561856788, 0);
            XYZ _combinedViewCoordinate = new XYZ(0.780872717690263, 0.766954561856788, 0);
            XYZ _demandViewCoordinate   = new XYZ(0.780872717690263, 1.83481042377296, 0);

            var _levels = Getters.GetLevels(_doc).OrderByDescending(p => p.Elevation).ToList();

            var _floors            = Getters.GetFloors(_doc).OrderBy(p => p.get_BoundingBox(null)?.Max.Z).ToList();
            var _structuralColumns = new FilteredElementCollector(_doc).OfCategory(BuiltInCategory.OST_StructuralColumns).OfType <FamilyInstance>().OrderBy(p => p.get_BoundingBox(null)?.Max.Z).ToList();
            var _structuralFraming = new FilteredElementCollector(_doc).OfCategory(BuiltInCategory.OST_StructuralFraming).OfType <FamilyInstance>().OrderBy(p => p.get_BoundingBox(null)?.Max.Z).ToList();
            var _walls             = new FilteredElementCollector(_doc).OfClass(typeof(Wall)).OfType <Wall>().OrderBy(p => p.get_BoundingBox(null)?.Max.Z).ToList();

            BoundingBoxXYZ _modelExtents =
                GeometryHelpers.GetElementsBBox(
                    new FilteredElementCollector(_doc).WhereElementIsViewIndependent().WhereElementIsNotElementType().ToList());

            _modelExtents.Min = new XYZ(_modelExtents.Min.X, _modelExtents.Min.Y, _levels.LastOrDefault().Elevation - 1.0);

            Category _directShapeCategory = Category.GetCategory(_doc, BuiltInCategory.OST_GenericModel);

            Level _levelAbove  = null;
            Level _bottomLevel = _levels.LastOrDefault();
            Level _topLevel    = _levels.FirstOrDefault();

            //Begin to generate our VisualizationDeliverables - these are sheets with 3 plan-orientation isometric views.
            //  NOTE - isometric views were used so that semi-transparent color overrides can be overlayed over each other to represent demands vs capacities
            //  ToDo: it would be valuable to scale transparency by percentage of overall demand/capacity
            List <VisualizationDeliverable> _visualizationDeliverables = new List <VisualizationDeliverable>();

            foreach (Level _level in _levels)
            {
                if (_levelAbove == null)
                {
                    _levelAbove = _level;
                }

                //Get the elements that are on our current Level
                List <Floor>          _currentLevelFloors            = _floors.Where(p => p.LevelId == _level.Id).ToList();
                List <FamilyInstance> _currentLevelStructuralColumns = new List <FamilyInstance>();
                List <FamilyInstance> _currentLevelStructuralFraming = new List <FamilyInstance>();
                List <Wall>           _currentLevelWalls             = new List <Wall>();

                BoundingBoxXYZ _levelBounds = new BoundingBoxXYZ
                {
                    Min = new XYZ(_modelExtents.Min.X, _modelExtents.Min.Y, _level.Elevation),
                    Max = new XYZ(_modelExtents.Max.X, _modelExtents.Max.Y, _levelAbove.Elevation)
                };

                BoundingBoxIsInsideFilter   _withinLevelBoundsFilter     = new BoundingBoxIsInsideFilter(new Outline(_levelBounds.Min, _levelBounds.Max));
                BoundingBoxIntersectsFilter _intersectsLevelBoundsFilter = new BoundingBoxIntersectsFilter(new Outline(_levelBounds.Min, _levelBounds.Max));

                if (_structuralColumns.Count > 0)
                {
                    _currentLevelStructuralColumns = new FilteredElementCollector(_doc, _structuralColumns.Select(p => p.Id).ToList()).WherePasses(_intersectsLevelBoundsFilter).OfType <FamilyInstance>().ToList();
                }
                else
                {
                    _currentLevelStructuralColumns = new List <FamilyInstance>();
                }

                if (_structuralFraming.Count > 0)
                {
                    _currentLevelStructuralFraming = new FilteredElementCollector(_doc, _structuralFraming.Select(p => p.Id).ToList()).WherePasses(_withinLevelBoundsFilter).OfType <FamilyInstance>().ToList();
                }
                else
                {
                    _currentLevelStructuralFraming = new List <FamilyInstance>();
                }

                if (_walls.Count > 0)
                {
                    _currentLevelWalls = new FilteredElementCollector(_doc, _walls.Select(p => p.Id).ToList()).WherePasses(_withinLevelBoundsFilter).OfType <Wall>().ToList();
                }
                else
                {
                    _currentLevelWalls = new List <Wall>();
                }

                //Generate LoadModels to populate a full LevelLoadModel
                LevelLoadModel _currentLevelLoadModel = LevelLoadModel.Create(_level);
                foreach (Floor _floor in _currentLevelFloors)
                {
                    //The "top" floor is where the initial Demand is determined, which is to be supported via reshores propagating down through the building
                    //ToDo: it would be valuable to be able to pick which Level to start from
                    if (_level.Id == _topLevel.Id)
                    {
                        Parameter _floorThicknessParameter = _floor.get_Parameter(BuiltInParameter.FLOOR_ATTR_THICKNESS_PARAM);
                        double    _floorThickness          = _floorThicknessParameter == null
                            ? 0.0
                            : _floorThicknessParameter.AsDouble();

                        _currentLevelLoadModel.addFloorDemandLoadModel(_floor, _concreteDensityPoundsForcePerCubicFoot * _floorThickness);
                    }

                    //Add loads from other sources that are also distributed evenly along a level
                    ILoadModel _floorCapacityLoadModel = levelLiveLoadPerSquareFoots.FirstOrDefault(p => p.Name == _level.Name);
                    if (_floorCapacityLoadModel == null)
                    {
                        continue;
                    }

                    List <LoadModel> _floorLoadModels = _currentLevelLoadModel.addFloorCapacityLoadModel(_floor, _floorCapacityLoadModel.PoundsForcePerSquareFoot);

                    foreach (ILoadModel _loadModel in levelLiveLoadPerSquareFoots.Where(p => p.Name.Equals(_level.Name)))
                    {
                        List <ILoadModel> _otherLoadModels = new List <ILoadModel>();
                        foreach (LoadModel _floorLoadModel in _floorLoadModels)
                        {
                            LoadModel _otherLoadModel = LoadModel.Create();
                            _otherLoadModel.Name     = _loadModel.Name;
                            _otherLoadModel.LoadType = _loadModel.LoadType;
                            _otherLoadModel.PoundsForcePerSquareFoot = _loadModel.PoundsForcePerSquareFoot;
                            _otherLoadModel.AreaSquareFeetXY         = _floorLoadModel.AreaSquareFeetXY;
                            _otherLoadModel.HeightFeetZ = _floorLoadModel.HeightFeetZ;
                            _otherLoadModel.OriginXFeet = _floorLoadModel.OriginXFeet;
                            _otherLoadModel.OriginYFeet = _floorLoadModel.OriginYFeet;

                            _otherLoadModel.Curves     = _floorLoadModel.Curves;
                            _otherLoadModel.PlanarFace = _floorLoadModel.PlanarFace;
                            _otherLoadModel.Element    = _floorLoadModel.Element;

                            _currentLevelLoadModel.addLoadModel(_otherLoadModel);
                        }
                    }
                }
                foreach (FamilyInstance _structuralColumn in _currentLevelStructuralColumns)
                {
                    _currentLevelLoadModel.addFamilyInstanceLoadModel(_structuralColumn, LoadType.Demand, buildingLoadModel.StructuralColumnWeightPerSquareFoot);
                    _currentLevelLoadModel.addFamilyInstanceLoadModel(_structuralColumn, LoadType.Capacity, buildingLoadModel.StructuralColumnWeightPerSquareFoot);
                }
                foreach (FamilyInstance _structuralFrame in _currentLevelStructuralFraming)
                {
                    _currentLevelLoadModel.addFamilyInstanceLoadModel(_structuralFrame, LoadType.Demand, buildingLoadModel.StructuralBeamWeightPerSquareFoot);
                }
                foreach (Wall _wall in _currentLevelWalls)
                {
                    _currentLevelLoadModel.addWallLoadModel(_wall, LoadType.Demand, buildingLoadModel.StructuralWallWeightPerSquareFoot);
                    _currentLevelLoadModel.addWallLoadModel(_wall, LoadType.Capacity, buildingLoadModel.StructuralWallWeightPerSquareFoot);
                }

                //Set the Solid elements that we will project through the building, to represent demands/capacities
                LoadModel.SetSolids(_currentLevelLoadModel.LoadModels.OfType <LoadModel>(), _level, _topLevel, _bottomLevel);

                VisualizationDeliverable _visualizationDeliverable = new VisualizationDeliverable(_currentLevelLoadModel)
                {
                    Floors            = _currentLevelFloors,
                    StructuralColumns = _currentLevelStructuralColumns,
                    StructuralFraming = _currentLevelStructuralFraming,
                    Walls             = _currentLevelWalls,
                };
                _visualizationDeliverables.Add(_visualizationDeliverable);

                _levelAbove = _level;
            }

            //Now that we've gathered all of our LoadModels, let's read the data about their actual demands/capacities
            buildingLoadModel.LevelLoadModels = _visualizationDeliverables.Select(p => p.LevelLoadModel as ILevelLoadModel).Where(p => p != null).ToList();

            buildingLoadModel.ReadLoads();

            foreach (LoadModel _loadModel in _visualizationDeliverables.Select(p => p.LevelLoadModel).SelectMany(p => p.LoadModels))
            {
                _loadModel.SetDirectShapeWithParameters(_doc, _directShapeCategory.Id, _loadModel.Name);
            }

            //Update Levels in the model with Load details
            foreach (LevelLoadModel _levelLoadModel in _visualizationDeliverables.Select(p => p.LevelLoadModel))
            {
                _levelLoadModel.SetLevelParameters();
            }

            //Color our active View for the visualization
            colorActiveView(_doc, _visualizationDeliverables);

            //ToDo: something happened which broke colors being correctly applied to these sheets - will need to sort this out
            //createSheetsAndViews(_doc, _visualizationDeliverables, _modelExtents);
            //
            //colorViews(_doc, _visualizationDeliverables);
            //
            //createViewports(_doc, _visualizationDeliverables, _capacityViewCoordinate, _combinedViewCoordinate, _demandViewCoordinate);

            return(Result.Succeeded);
        }
예제 #5
0
        private static Dictionary <double, double> getClearShoreHeightCapacityMappings(BuildingLoadModel buildingLoadModel, Level topLevel, FamilySymbol familySymbol)
        {
            Document _doc = topLevel.Document;

            List <FamilyInstance> _temporaryShores = new List <FamilyInstance>();

            foreach (LevelLoadModel _levelLoadModel in buildingLoadModel.LevelLoadModels)
            {
                if (_levelLoadModel.Level.Id == topLevel.Id)
                {
                    continue;
                }

                FamilyInstance _temporaryShore = _doc.Create.NewFamilyInstance(new XYZ(0, 0, _levelLoadModel.Level.Elevation), familySymbol, Autodesk.Revit.DB.Structure.StructuralType.Column);
                _temporaryShore?.LookupParameter("Height")?.Set(_levelLoadModel.ClearShoreHeight);

                _temporaryShores.Add(_temporaryShore);
            }

            _doc.Regenerate();

            Dictionary <double, double> _clearShoreHeightCapacityMappings = new Dictionary <double, double>();

            foreach (FamilyInstance _temporaryShore in _temporaryShores)
            {
                Parameter _clearShoreHeightParameter = _temporaryShore.get_Parameter(Ids.ClearShoreHeightId);
                double    _clearShoreHeight          = _clearShoreHeightParameter == null
                    ? 0.0
                    : Math.Round(_clearShoreHeightParameter.AsDouble(), 9);

                if (_clearShoreHeightCapacityMappings.ContainsKey(_clearShoreHeight))
                {
                    continue;
                }

                Parameter _loadCapacityParameter = _temporaryShore.get_Parameter(Ids.LoadCapacityParameterId);
                double    _loadCapacity          = _loadCapacityParameter == null
                    ? 0.0
                    : UnitUtils.ConvertFromInternalUnits(_loadCapacityParameter.AsDouble(), DisplayUnitType.DUT_POUNDS_FORCE_PER_SQUARE_FOOT);

                _clearShoreHeightCapacityMappings.Add(_clearShoreHeight, _loadCapacity);
            }

            _doc.Delete(_temporaryShores.Select(p => p.Id).ToList());

            return(_clearShoreHeightCapacityMappings);
        }
예제 #6
0
        public static Result PlaceTemporaryShoring(UIDocument uiDoc)
        {
            Result _result = Result.Cancelled;

            using (Transaction _trans = new Transaction(uiDoc.Document, "Place Temporary Shoring"))
            {
                _trans.Start();
                try
                {
                    //ToDo: these objects would be better passed to/from a UI, or possibly stored somewhere as settings
                    BuildingLoadModel _buildingLoadModel = new BuildingLoadModel(0, 0, 7.0, 7.0, 7.0, 7.0, 7.0);

                    List <ILoadModel> _loadModels = new List <ILoadModel>
                    {
                        LoadModel.Create("Level 18", LoadType.Capacity, 24),
                        LoadModel.Create("Level 17", LoadType.Capacity, 24),
                        LoadModel.Create("Level 16", LoadType.Capacity, 24),
                        LoadModel.Create("Level 15", LoadType.Capacity, 24),
                        LoadModel.Create("Level 14", LoadType.Capacity, 24),
                        LoadModel.Create("Level 13", LoadType.Capacity, 24),
                        LoadModel.Create("Level 12", LoadType.Capacity, 24),
                        LoadModel.Create("Level 11", LoadType.Capacity, 24),
                        LoadModel.Create("Level 10", LoadType.Capacity, 24),
                        LoadModel.Create("Level 09", LoadType.Capacity, 24),
                        LoadModel.Create("Level 08", LoadType.Capacity, 24),
                        LoadModel.Create("Level 07", LoadType.Capacity, 24),
                        LoadModel.Create("Level 06", LoadType.Capacity, 24),
                        LoadModel.Create("Level 05", LoadType.Capacity, 24),
                        LoadModel.Create("Level 04", LoadType.Capacity, 24),
                        LoadModel.Create("Level 03", LoadType.Capacity, 24),
                        LoadModel.Create("Level 02", LoadType.Capacity, 100),
                        LoadModel.Create("Level 01", LoadType.Capacity, 100),
                        LoadModel.Create("P1", LoadType.Capacity, 40),
                        LoadModel.Create("P2", LoadType.Capacity, 40),
                        LoadModel.Create("P3", LoadType.Capacity, 40),
                        LoadModel.Create("P4", LoadType.Capacity, 40),
                        LoadModel.Create("P5", LoadType.Capacity, 40),

                        LoadModel.Create("ROOF", LoadType.LiveLoad, 40),
                        LoadModel.Create("Level 18", LoadType.LiveLoad, 40),
                        LoadModel.Create("Level 17", LoadType.LiveLoad, 40),
                        LoadModel.Create("Level 16", LoadType.LiveLoad, 40),
                        LoadModel.Create("Level 15", LoadType.LiveLoad, 40),
                        LoadModel.Create("Level 14", LoadType.LiveLoad, 40),
                        LoadModel.Create("Level 13", LoadType.LiveLoad, 40),
                        LoadModel.Create("Level 12", LoadType.LiveLoad, 40),
                        LoadModel.Create("Level 11", LoadType.LiveLoad, 40),
                        LoadModel.Create("Level 10", LoadType.LiveLoad, 40),
                        LoadModel.Create("Level 09", LoadType.LiveLoad, 40),
                        LoadModel.Create("Level 08", LoadType.LiveLoad, 40),
                        LoadModel.Create("Level 07", LoadType.LiveLoad, 40),
                        LoadModel.Create("Level 06", LoadType.LiveLoad, 40),
                        LoadModel.Create("Level 05", LoadType.LiveLoad, 40),
                        LoadModel.Create("Level 04", LoadType.LiveLoad, 40),
                        LoadModel.Create("Level 03", LoadType.LiveLoad, 40),
                        LoadModel.Create("Level 02", LoadType.LiveLoad, 100),
                        LoadModel.Create("Level 01", LoadType.LiveLoad, 100),
                        LoadModel.Create("P1", LoadType.LiveLoad, 45),
                        LoadModel.Create("P2", LoadType.LiveLoad, 45),
                        LoadModel.Create("P3", LoadType.LiveLoad, 45),
                        LoadModel.Create("P4", LoadType.LiveLoad, 45),
                        LoadModel.Create("P5", LoadType.LiveLoad, 45),

                        LoadModel.Create("Level 18", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                        LoadModel.Create("Level 17", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                        LoadModel.Create("Level 16", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                        LoadModel.Create("Level 15", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                        LoadModel.Create("Level 14", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                        LoadModel.Create("Level 13", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                        LoadModel.Create("Level 12", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                        LoadModel.Create("Level 11", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                        LoadModel.Create("Level 10", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                        LoadModel.Create("Level 09", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                        LoadModel.Create("Level 08", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                        LoadModel.Create("Level 07", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                        LoadModel.Create("Level 06", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                        LoadModel.Create("Level 05", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                        LoadModel.Create("Level 04", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                        LoadModel.Create("Level 03", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                        LoadModel.Create("Level 02", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                        LoadModel.Create("Level 01", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                        LoadModel.Create("P1", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                        LoadModel.Create("P2", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                        LoadModel.Create("P3", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                        LoadModel.Create("P4", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                        LoadModel.Create("P5", LoadType.Formwork, _buildingLoadModel.FormWeightPerSquareFoot),
                    };


                    _result = placeTemporaryShoring(uiDoc, _buildingLoadModel, _loadModels, @"C:\ProgramData\Autodesk\Revit\Addins\2021\ApatosReshoring\Reshoring Poles Ellis 4x4.rfa", "6-on-6");

                    _trans.Commit();
                }
                catch (Exception _ex)
                {
                    _trans.RollBack();
#if DEBUG
                    string _error = _ex.Message + Environment.NewLine + Environment.NewLine + _ex.StackTrace;
                    TaskDialog.Show("Error", _error);
#endif
                    return(Result.Failed);
                }
            }

            return(_result);
        }
예제 #7
0
        private static Result placeTemporaryShoring(UIDocument uiDoc, BuildingLoadModel buildingLoadModel, List <ILoadModel> loadModels, string reshoringFamilyPathName, string reshoringFamilySymbol)
        {
            //Setup
            Document _doc = uiDoc.Document;

            //ToDo: it would be valuable to let users pick which Family & Type they want to use - so they can rapidly understand differences in layout for different reshores
            Dictionary <string, FamilyDefinition> _familyMappings = new List <string> {
                @"C:\ProgramData\Autodesk\Revit\Addins\2021\ApatosReshoring\Reshoring Poles 6x6.rfa",
                @"C:\ProgramData\Autodesk\Revit\Addins\2021\ApatosReshoring\Reshoring Poles Ellis 4x4.rfa",
                @"C:\ProgramData\Autodesk\Revit\Addins\2021\ApatosReshoring\Reshoring Poles Titan-HV.rfa",
                @"C:\ProgramData\Autodesk\Revit\Addins\2021\ApatosReshoring\Reshoring Poles Titan-XL.rfa",
            }.ToDictionary(p => Path.GetFileNameWithoutExtension(p),
                           p => FamilyHelpers.GetOrLoadFamilyDefinition(_doc, p));

            string       _familyName           = Path.GetFileNameWithoutExtension(reshoringFamilyPathName);
            FamilySymbol _temporaryShoreSymbol = null;

            if (_familyMappings.ContainsKey(_familyName))
            {
                Family _family = _familyMappings[_familyName]?.Family;
                foreach (ElementId _symbolID in _family.GetFamilySymbolIds())
                {
                    FamilySymbol _familySymbol = _doc.GetElement(_symbolID) as FamilySymbol;
                    if (_familySymbol == null)
                    {
                        continue;
                    }

                    if (_familySymbol.Name != reshoringFamilySymbol)
                    {
                        continue;
                    }

                    _temporaryShoreSymbol = _familySymbol;
                    if (_temporaryShoreSymbol != null)
                    {
                        break;
                    }
                }
            }

            if (_temporaryShoreSymbol == null)
            {
                return(Result.Failed);
            }
            if (_temporaryShoreSymbol.IsActive == false)
            {
                _temporaryShoreSymbol.Activate();
            }

            var _levels = Getters.GetLevels(uiDoc.Document).OrderByDescending(p => p.Elevation).ToList();
            var _floors = Getters.GetFloors(_doc).OrderBy(p => p.get_BoundingBox(null)?.Max.Z).ToList();

            Level _topLevel = _levels.FirstOrDefault();

            //Add Level Loads
            addLevelLoadModels(buildingLoadModel, _levels, _floors, _topLevel, loadModels);
            buildingLoadModel.ReadLoads();

            //Place Temporary Shores
            Dictionary <double, double> _clearShoreHeightCapacityMappings = getClearShoreHeightCapacityMappings(buildingLoadModel, _topLevel, _temporaryShoreSymbol);

            LevelLoadModel _levelLoadModelAbove = buildingLoadModel.LevelLoadModels.OfType <LevelLoadModel>().FirstOrDefault(p => p.Level.Id == _topLevel.Id);

            if (_levelLoadModelAbove == null)
            {
                return(Result.Failed);
            }

            Dictionary <LevelLoadModel, double> _levelLoadModelXDistances = new Dictionary <LevelLoadModel, double>();
            Dictionary <LevelLoadModel, double> _levelLoadModelYDistances = new Dictionary <LevelLoadModel, double>();
            LevelLoadModel _lowestReshoredLevelLoadModel = null;
            double         _levelAboveDemand             = _levelLoadModelAbove.ReshoreDemandPoundsForcePerSquareFoot;

            foreach (LevelLoadModel _levelLoadModel in buildingLoadModel.LevelLoadModels)
            {
                if (_levelAboveDemand > 0.0)
                {
                    if (_levelLoadModel.Level.Id == _topLevel.Id)
                    {
                        continue;
                    }

                    double _roundedClearShoreHeight = Math.Round(_levelLoadModel.ClearShoreHeight, 9);
                    if (_clearShoreHeightCapacityMappings.ContainsKey(_roundedClearShoreHeight) == false)
                    {
                        continue;
                    }

                    double _loadCapacityPerShore = _clearShoreHeightCapacityMappings[_roundedClearShoreHeight];
                    double _minimumAreaPerShore  = _loadCapacityPerShore / _levelAboveDemand;

                    double _allowedAreaSquareSideLength = Math.Sqrt(_minimumAreaPerShore);
                    double _roundedSideLength           = Math.Floor(_allowedAreaSquareSideLength);

                    //safer to round both down & have a smaller area
                    _levelLoadModelXDistances.Add(_levelLoadModel, _roundedSideLength);
                    _levelLoadModelYDistances.Add(_levelLoadModel, _roundedSideLength);

                    //Adjust our Capacity & Demand, then determine if we can stop adding temportary reshoring
                    _levelLoadModel.ReshoreDemandPoundsForcePerSquareFoot = _levelAboveDemand;

                    _levelAboveDemand -= _levelLoadModel.CapacityPoundsForcePerSquareFoot;
                }
                else
                {
                    if (_lowestReshoredLevelLoadModel == null)
                    {
                        _lowestReshoredLevelLoadModel = _levelLoadModelAbove;
                    }
                    _levelLoadModel.ReshoreDemandPoundsForcePerSquareFoot = 0.0;
                }

                _levelLoadModelAbove = _levelLoadModel;
            }

            //Update Level parameters
            foreach (LevelLoadModel _levelLoadModel in buildingLoadModel.LevelLoadModels)
            {
                _levelLoadModel.SetLevelParameters();
            }

            //Place temporary reshoring
            List <FamilyInstance> _temporaryShores = new List <FamilyInstance>();

            _levelLoadModelAbove = buildingLoadModel.LevelLoadModels.OfType <LevelLoadModel>().FirstOrDefault(p => p.Level.Id == _topLevel.Id);
            foreach (LevelLoadModel _levelLoadModel in buildingLoadModel.LevelLoadModels.Where(p => p.ReshoreDemandPoundsForcePerSquareFoot > 0.0))
            {
                if (_levelLoadModel.Level.Id == _topLevel.Id)
                {
                    continue;
                }

                if (_levelLoadModelXDistances.ContainsKey(_levelLoadModel) == false || _levelLoadModelYDistances.ContainsKey(_levelLoadModel) == false)
                {
                    break;
                }

                double _sideXLength = _levelLoadModelXDistances[_levelLoadModel];
                double _sideYLength = _levelLoadModelYDistances[_levelLoadModel];

                //ToDo: add 1, subtract 1 from each side & check if their total area is closer to the calculated area than a square
                //ToDo: do this twice, and take the "middle" option

                List <Floor> _levelAboveFloors = _floors.Where(p => p.LevelId == _levelLoadModelAbove.Level.Id).ToList();

                List <FamilyInstance> _temporaryReshores = new List <FamilyInstance>();

                foreach (Floor _floor in _levelAboveFloors)
                {
                    BoundingBoxXYZ _currentFloorBounds = _floor.get_BoundingBox(null);

                    List <double> _xCoords = new List <double>();
                    for (double _x = 0.0; _x <= _currentFloorBounds.Max.X - _currentFloorBounds.Min.X; _x += _sideXLength)
                    {
                        _xCoords.Add(_x);
                    }

                    List <double> _yCoords = new List <double>();
                    for (double _y = 0.0; _y <= _currentFloorBounds.Max.Y - _currentFloorBounds.Min.Y; _y += _sideYLength)
                    {
                        _yCoords.Add(_y);
                    }

                    foreach (double _x in _xCoords)
                    {
                        foreach (double _y in _yCoords)
                        {
                            XYZ _insertionCoordinate = new XYZ(
                                _currentFloorBounds.Min.X + _x,
                                _currentFloorBounds.Min.Y + _y,
                                _levelLoadModel.ElevationFeet);

                            FamilyInstance _temporaryShore = _doc.Create.NewFamilyInstance(_insertionCoordinate, _temporaryShoreSymbol, Autodesk.Revit.DB.Structure.StructuralType.Column);

                            Parameter _heightParam = _temporaryShore.LookupParameter("Height");
                            if (_heightParam != null && _heightParam.IsReadOnly == false)
                            {
                                _heightParam.Set(_levelLoadModel.ClearShoreHeight);
                            }

                            _temporaryShores.Add(_temporaryShore);
                        }
                    }
                }
            }


            //Regenerate so that the latest locations are updated in the model for our newly placed reshores - the intersects filters below will fail without this
            _doc.Regenerate();

            var _scopeBoxes = Getters.GetScopeBoxes(_doc);
            Dictionary <ElementId, string> _shoreIdScopeBoxNames = new Dictionary <ElementId, string>();

            foreach (Element _scopeBox in _scopeBoxes)
            {
                List <Element> _columnsInScopeBox = Getters.GetInsideElements(_doc, _temporaryShores, _scopeBox.get_BoundingBox(null));

                foreach (Level _level in _levels)
                {
                    List <Element> _columnsInScopeBoxOnLevel = _columnsInScopeBox.Where(p => ((p.Location as LocationPoint)?.Point.Z - _level.Elevation) <= 1.0).ToList();

                    string _pourName = Helpers.Views.BoundedViewCreator.GetViewName(_level, _scopeBox, string.Empty, string.Empty);

                    foreach (Element _column in _columnsInScopeBoxOnLevel)
                    {
                        _column.get_Parameter(Ids.PourNameParameterId)?.Set(_pourName);
                    }
                }
            }

            return(Result.Succeeded);
        }
예제 #8
0
        private void doStuff_Click(object sender, RoutedEventArgs e)
        {
            //ToDo: update this CSPROJ to accomodate change in shape of UI objects


            BuildingLoadModel _buildingLoadModel = new BuildingLoadModel
            {
                ConstructionLiveLoadTotalPounds     = 1.5,
                LevelsAboveGroundCount              = 2,
                LevelsBelowGroundCount              = 3,
                FormWeightPerSquareFoot             = 4,
                StructuralBeamWeightPerSquareFoot   = 5.5,
                StructuralColumnWeightPerSquareFoot = 6.5,
                StructuralWallWeightPerSquareFoot   = 7.5,
                AdditionalWeightPerSquareFoot       = 8.5,
            };

            LevelLoadModel _levelLoadModel = new LevelLoadModel
            {
                Name                                  = "My Level 1",
                ElevationFeet                         = 9.5,
                TopOfSlabElevationFeet                = 10.5,
                ConcreteDepthFeet                     = 11.5,
                CapacityPoundsForcePerSquareFoot      = 12.5,
                DemandPoundsForcePerSquareFoot        = 13.5,
                ReshoreDemandPoundsForcePerSquareFoot = 14.5,
            };

            _buildingLoadModel.LevelLoadModels.Add(_levelLoadModel);

            LoadModel _capacity = new LoadModel
            {
                LoadType = Enums.LoadType.Capacity,
                Name     = "My Capacity 1",
                //AmountPerSquareFoot = 15.5,
                //MinX = 16.123456789,
                //MinY = 17.123456789,
                //MaxX = 18.123456789,
                //MaxY = 19.123456789,
            };

            LoadModel _demand = new LoadModel
            {
                LoadType = Enums.LoadType.Demand,
                Name     = "My Demand 1",
                //AmountPerSquareFoot = 20.5,
                //MinX = 21.123456789,
                //MinY = 22.123456789,
                //MaxX = 23.123456789,
                //MaxY = 24.123456789,
            };

            LoadModel _liveLoad = new LoadModel
            {
                LoadType = Enums.LoadType.ReshoreDemand,
                Name     = "My Reshore Demand 1",
                //AmountPerSquareFoot = 25.5,
                //MinX = 26.123456789,
                //MinY = 27.123456789,
                //MaxX = 28.123456789,
                //MaxY = 29.123456789,
            };

            LoadModel _reshoreCapacity = new LoadModel
            {
                LoadType = Enums.LoadType.ReshoreDemand,
                Name     = "My Reshore Demand 1",
                //AmountPerSquareFoot = 30.5,
                //MinX = 31.123456789,
                //MinY = 32.123456789,
                //MaxX = 33.123456789,
                //MaxY = 34.123456789,
            };

            //_levelLoadModel.CapacityModels.Add(_capacity);
            //_levelLoadModel.DemandModels.Add(_demand);
            //_levelLoadModel.LiveLoadModels.Add(_liveLoad);
            //_levelLoadModel.ReshoreDemandModels.Add(_reshoreCapacity);

            //string _filePathName = @"C:\$\AEC Hackathon 2020 (models)\BuildingLoadModel.xml";
            ////Serializable.BuildingLoadModel.SerializeToXml(_buildingLoadModel, _filePathName);
            //Helpers.Extension.ToXML(_buildingLoadModel);
            //Process.Start(System.IO.Path.GetDirectoryName(_filePathName));
            BuildingLoadInputs _buildingLoadInputs = new BuildingLoadInputs(_buildingLoadModel);

            _buildingLoadInputs.ShowDialog();
            if (_buildingLoadInputs.DialogResult != true)
            {
                return;
            }
        }