Exemple #1
0
        private static Result createDeliverableSheets(UIDocument uiDoc)
        {
            //ToDo: these might be good as settings in a future UI
            string _titleblockName = "E1 30 x 42 Horizontal: E1 30x42 Horizontal";
            //string _elementName = "C-2"; // "EllisShore_LumberWithClamps";
            //
            //int _3dViewScale = 48;
            //XYZ _3dViewportCenter = new XYZ(2.21129429621462, 0.656294714474886, 0);
            //
            //int _sectionViewScale = 32;
            //XYZ _sectionViewportCenter = new XYZ(0.7791340191012, 1.72774616204266, 0);

            int _floorplanViewScale      = 20;
            XYZ _floorplanViewportCenter = new XYZ(1.13879414318027, 1.16675126090371, -0.025);

            XYZ _scheduleBottomLeft = new XYZ(1.9435380772204, 2.43263378194158, 0);

            Document _doc = uiDoc.Document;

            //Get a BoundedView3DDefinition for each Level - Scope Box in the project
            var _levels = Getters.GetLevels(_doc);

            var _scopeBoxes = Getters.GetScopeBoxes(_doc);

            var    _boundedViewCreators = new List <BoundedViewCreator>();
            double _extraExtents        = 0.5;

            foreach (Level _level in _levels)
            {
                Level _levelAbove = _levels.FirstOrDefault(p => p.Elevation > _level.Elevation);
                if (_levelAbove == null)
                {
                    continue;
                }

                foreach (Element _scopeBox in _scopeBoxes)
                {
                    BoundingBoxXYZ _scopeBoxBounds = _scopeBox.get_BoundingBox(null);
                    BoundingBoxXYZ _viewBounds     = new BoundingBoxXYZ
                    {
                        Min = new XYZ(
                            _scopeBoxBounds.Min.X - _extraExtents,
                            _scopeBoxBounds.Min.Y - _extraExtents,
                            _level.Elevation - _extraExtents),
                        Max = new XYZ(
                            _scopeBoxBounds.Max.X + _extraExtents,
                            _scopeBoxBounds.Max.Y + _extraExtents,
                            _levelAbove.Elevation + _extraExtents)
                    };

                    _boundedViewCreators.Add(new BoundedViewCreator(_level, _scopeBox, _viewBounds));
                }
            }

            //Generate Views, set their Boundaries & Names, Adjust Visiblity Graphics
            OverrideGraphicSettings _70Transparent = new OverrideGraphicSettings();

            _70Transparent.SetSurfaceTransparency(70);

            List <Tuple <ElementId, string, List <View> > > _createdSheetIdViewIdSets = new List <Tuple <ElementId, string, List <View> > >();

            foreach (var _boundedViewCreator in _boundedViewCreators)
            {
                SheetCreator    _sheetCreator    = new SheetCreator(_doc);
                ScheduleCreator _scheduleCreator = new ScheduleCreator(_doc);

                //Create Sheet
                string    _pourName  = _boundedViewCreator.GetViewName(string.Empty);
                ViewSheet _sheetView = _sheetCreator.CreateSheet(_titleblockName, _pourName, _pourName);

                ////Create 3D View
                //View3D _3DView = _boundedViewCreator.CreateView3D(_3dViewScale);
                //_3DView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_VolumeOfInterest), true);
                //_3DView.SetCategoryOverrides(new ElementId(BuiltInCategory.OST_Floors), _70Transparent);

                //Create Floorplan View
                ViewPlan _floorPlanView = _boundedViewCreator.CreateViewPlan(_floorplanViewScale);
                _floorPlanView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_VolumeOfInterest), true);
                _floorPlanView.SetCategoryOverrides(new ElementId(BuiltInCategory.OST_Floors), _70Transparent);

                ////Create Section View
                //ViewSection _sectionView = _boundedViewCreator.CreateViewSection(_sectionViewScale);
                //_sectionView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_VolumeOfInterest), true);
                //_sectionView.SetCategoryOverrides(new ElementId(BuiltInCategory.OST_Floors), _70Transparent);

                //ToDo: get necessary parameters into shared parameters, so that they are visible in Project
                // //Create Schedule
                // ViewSchedule _viewSchedule = _scheduleCreator.CreateSchedule(false, _pourName + " Shoring");
                // ScheduleField _comments = _scheduleCreator.AppendField(_viewSchedule, "Comments"); //Pour Name
                // ScheduleField _count = _scheduleCreator.AppendField(_viewSchedule, "Count");
                // ScheduleField _familyAndType = _scheduleCreator.AppendField(_viewSchedule, "Family and Type");
                // //ScheduleField _material = _scheduleCreator.AppendField(_viewSchedule, "Material");
                // //ScheduleField _clampSpacing = _scheduleCreator.AppendField(_viewSchedule, "Clamp Spacing");
                // //ScheduleField _lowerShoreLength = _scheduleCreator.AppendField(_viewSchedule, "Lower Shore Length");
                // //ScheduleField _upperShoreLength = _scheduleCreator.AppendField(_viewSchedule, "Upper Shore Length");
                // ScheduleField _height = _scheduleCreator.AppendField(_viewSchedule, "Height");
                // ScheduleField _clearShoreHeight = _scheduleCreator.AppendField(_viewSchedule, "Clear Shore Height"); //Total Shore Length
                // //ScheduleField _shoreLength = _scheduleCreator.AppendField(_viewSchedule, "Shore Overlap");
                // //ScheduleField _lumberWidth = _scheduleCreator.AppendField(_viewSchedule, "Lumber Width");
                // //ScheduleField _lumberThickness = _scheduleCreator.AppendField(_viewSchedule, "Lumber Thickness");
                // ScheduleField _loadCapacity = _scheduleCreator.AppendField(_viewSchedule, "Load Capacity"); //Safe Working Load
                //
                // _scheduleCreator.AppendSortField(_viewSchedule, _familyAndType);
                // //_scheduleCreator.AppendSortField(_viewSchedule, _lowerShoreLength);
                // //_scheduleCreator.AppendSortField(_viewSchedule, _upperShoreLength);
                // _scheduleCreator.AppendSortField(_viewSchedule, _clearShoreHeight);
                //
                // _scheduleCreator.AppendFilter(_viewSchedule, _comments, ScheduleFilterType.Equal, _pourName);
                //
                // ScheduleSheetInstance _scheduleSheetInstance = ScheduleSheetInstance.Create(_doc, _sheetView.Id, _viewSchedule.Id, _scheduleBottomLeft);

                _createdSheetIdViewIdSets.Add(new Tuple <ElementId, string, List <View> >(
                                                  _sheetView.Id,
                                                  _pourName,
                                                  new List <View> { /*_3DView,*/
                    _floorPlanView,                                 /*_sectionView*/
                }
                                                  ));
            }

            _doc.Regenerate();

            foreach (var _createdSheetIdViewIdSet in _createdSheetIdViewIdSets)
            {
                foreach (View _view in _createdSheetIdViewIdSet.Item3)
                {
                    if (_view == null)
                    {
                        continue;
                    }

                    //if (_view is View3D) Viewport.Create(_doc, _createdSheetIdViewIdSet.Item1, _view.Id, _3dViewportCenter);
                    else if (_view is ViewPlan)
                    {
                        DimensionCreator.CreateDimensions(_view, _createdSheetIdViewIdSet.Item2);
                        Viewport.Create(_doc, _createdSheetIdViewIdSet.Item1, _view.Id, _floorplanViewportCenter);
                    }
                    //else if (_view is ViewSection) Viewport.Create(_doc, _createdSheetIdViewIdSet.Item1, _view.Id, _sectionViewportCenter);
                }
            }

            return(Result.Succeeded);
        }
Exemple #2
0
        private static Result createPourSheets(UIDocument uiDoc)
        {
            //ToDo: these might be good as settings in a future UI
            string _titleblockName = "E1 30 x 42 Horizontal: E1 30x42 Horizontal";
            //string _elementName = "C-2"; // "EllisShore_LumberWithClamps";
            //
            //int _3dViewScale = 48;
            //XYZ _3dViewportCenter = new XYZ(2.21129429621462, 0.656294714474886, 0);
            //
            //int _sectionViewScale = 32;
            //XYZ _sectionViewportCenter = new XYZ(0.7791340191012, 1.72774616204266, 0);

            int _floorplanViewScale      = 24;
            XYZ _floorplanViewportCenter = new XYZ(1.23473112570493, 1.15208223453682, 0);

            XYZ _columnScheduleBottomLeft = new XYZ(2.31721454780864, 2.37688649933288, 0);
            XYZ _levelScheduleBottomLeft  = new XYZ(0.156336990263879, 2.37688649933288, 0);

            Document _doc = uiDoc.Document;

            //Get a BoundedView3DDefinition for each Level - Scope Box in the project
            var _levels = Getters.GetLevels(_doc);

            var _scopeBoxes = Getters.GetScopeBoxes(_doc);

            var    _boundedViewCreators = new List <BoundedViewCreator>();
            double _extraExtents        = 0.5;

            foreach (Level _level in _levels)
            {
                Level _levelAbove = _levels.FirstOrDefault(p => p.Elevation > _level.Elevation);
                if (_levelAbove == null)
                {
                    continue;
                }

                foreach (Element _scopeBox in _scopeBoxes)
                {
                    BoundingBoxXYZ _scopeBoxBounds = _scopeBox.get_BoundingBox(null);
                    BoundingBoxXYZ _viewBounds     = new BoundingBoxXYZ
                    {
                        Min = new XYZ(
                            _scopeBoxBounds.Min.X - _extraExtents,
                            _scopeBoxBounds.Min.Y - _extraExtents,
                            _level.Elevation - _extraExtents),
                        Max = new XYZ(
                            _scopeBoxBounds.Max.X + _extraExtents,
                            _scopeBoxBounds.Max.Y + _extraExtents,
                            _levelAbove.Elevation + _extraExtents)
                    };

                    _boundedViewCreators.Add(new BoundedViewCreator(_level, _scopeBox, _viewBounds));
                }
            }

            //Generate Views, set their Boundaries & Names, Adjust Visiblity Graphics
            OverrideGraphicSettings _70Transparent = new OverrideGraphicSettings();

            _70Transparent.SetSurfaceTransparency(70);

            List <Tuple <ElementId, string, List <View> > > _createdSheetIdViewIdSets = new List <Tuple <ElementId, string, List <View> > >();

            foreach (var _boundedViewCreator in _boundedViewCreators)
            {
                SheetCreator _sheetCreator = new SheetCreator(_doc);


                //Create Sheet
                string    _pourName  = _boundedViewCreator.GetViewName(string.Empty, string.Empty);
                ViewSheet _viewSheet = _sheetCreator.CreateSheet(_titleblockName, _pourName, _pourName);

                ////Create 3D View
                //View3D _3DView = _boundedViewCreator.CreateView3D(_3dViewScale);
                //_3DView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_VolumeOfInterest), true);
                //_3DView.SetCategoryOverrides(new ElementId(BuiltInCategory.OST_Floors), _70Transparent);

                //Create Floorplan View
                ViewPlan _floorPlanView = _boundedViewCreator.CreateViewPlan(_floorplanViewScale);
                _floorPlanView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_VolumeOfInterest), true);
                _floorPlanView.SetCategoryOverrides(new ElementId(BuiltInCategory.OST_Floors), _70Transparent);

                ////Create Section View
                //ViewSection _sectionView = _boundedViewCreator.CreateViewSection(_sectionViewScale);
                //_sectionView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_VolumeOfInterest), true);
                //_sectionView.SetCategoryOverrides(new ElementId(BuiltInCategory.OST_Floors), _70Transparent);

                //Create Schedules
                ViewSchedule          _columnSchedule = ScheduleCreator.CreatePourColumnSchedule(_doc, _pourName, " Reshores");
                ScheduleSheetInstance _columnScheduleSheetInstance = ScheduleSheetInstance.Create(_doc, _viewSheet.Id, _columnSchedule.Id, _columnScheduleBottomLeft);

                ViewSchedule          _levelSchedule = ScheduleCreator.CreatePourLoadSchedule(_doc, _boundedViewCreator.Level?.Name, " - " + _boundedViewCreator.ScopeBox?.Name + " Loads");
                ScheduleSheetInstance _levelScheduleSheetInstance = ScheduleSheetInstance.Create(_doc, _viewSheet.Id, _levelSchedule.Id, _levelScheduleBottomLeft);

                _createdSheetIdViewIdSets.Add(new Tuple <ElementId, string, List <View> >(
                                                  _viewSheet.Id,
                                                  _pourName,
                                                  new List <View> { /*_3DView,*/
                    _floorPlanView,                                 /*_sectionView*/
                }
                                                  ));
            }

            _doc.Regenerate();

            FamilySymbol _tagSymbol = new FilteredElementCollector(_doc)
                                      .OfCategory(BuiltInCategory.OST_MultiCategoryTags)
                                      .OfClass(typeof(FamilySymbol)).OfType <FamilySymbol>()
                                      .FirstOrDefault(p => p.FamilyName.Contains("Mark"));

            foreach (var _createdSheetIdViewIdSet in _createdSheetIdViewIdSets)
            {
                foreach (View _view in _createdSheetIdViewIdSet.Item3)
                {
                    if (_view == null)
                    {
                        continue;
                    }

                    //if (_view is View3D) Viewport.Create(_doc, _createdSheetIdViewIdSet.Item1, _view.Id, _3dViewportCenter);
                    else if (_view is ViewPlan)
                    {
                        DimensionCreator.CreateDimensions(_view);
                        TagCreator.CreateTags(_view, _tagSymbol);
                        Viewport.Create(_doc, _createdSheetIdViewIdSet.Item1, _view.Id, _floorplanViewportCenter);
                    }
                    //else if (_view is ViewSection) Viewport.Create(_doc, _createdSheetIdViewIdSet.Item1, _view.Id, _sectionViewportCenter);
                }
            }

            return(Result.Succeeded);
        }