Beispiel #1
0
        /// <summary>
        /// Get Base or SurveyPoint
        /// </summary>
        /// <param name="surveypoint"></param>
        /// <returns></returns>
        private static Point GetBaseOrSurveyPoint(bool surveypoint)
        {
            // Get Base or Survey point category
            RVT.BuiltInCategory category = (surveypoint)? RVT.BuiltInCategory.OST_SharedBasePoint : RVT.BuiltInCategory.OST_ProjectBasePoint;

            // Get Revit document
            RVT.Document doc = RevitServices.Persistence.DocumentManager.Instance.CurrentDBDocument;

            // Get all elements of the previously selected category
            Autodesk.Revit.DB.FilteredElementCollector collector = new RVT.FilteredElementCollector(doc).OfCategory(category);

            // Get the first element (should only be one)
            RVT.BasePoint element = (RVT.BasePoint)collector.ToElements().FirstOrDefault();

            if (element == null)
            {
                throw new Exception(Properties.Resources.CannotGetBaseOrSurveyPoint);
            }

            // Get the elements bounding box
            RVT.BoundingBoxXYZ box = element.get_BoundingBox(null);

            // Since the boundingbox is a point only, return Min or Max
            return(box.Max.ToPoint());
        }
Beispiel #2
0
        /// <summary>
        /// Reads from Revit selected elements identificators and collect in the list only that which has apprppriate label, material and category.
        /// </summary>
        /// <param name="server">Acces to cref="Server".</param>
        /// <param name="data">Acces to cref="ServiceData".</param>
        /// <returns>List identyficators of elements with result status.</returns>
        protected List <Tuple <ElementId, ResultStatus> > ReadListElementIdWithStatus(Server.Server server, Autodesk.Revit.DB.CodeChecking.ServiceData data)
        {
            Autodesk.Revit.DB.CodeChecking.Storage.StorageService  service         = Autodesk.Revit.DB.CodeChecking.Storage.StorageService.GetStorageService();
            Autodesk.Revit.DB.CodeChecking.Storage.StorageDocument storageDocument = service.GetStorageDocument(data.Document);
            Guid activePackageId = storageDocument.CalculationParamsManager.CalculationParams.GetInputResultPackageId(server.GetServerId());

            List <Tuple <ElementId, ResultStatus> > listElementId = new List <Tuple <ElementId, ResultStatus> >();

            foreach (Element element in data.Selection)
            {
                Autodesk.Revit.DB.CodeChecking.Storage.Label ccLabel = storageDocument.LabelsManager.GetLabel(element);
                if (ccLabel != null)
                {
                    Autodesk.Revit.DB.BuiltInCategory category = (Autodesk.Revit.DB.BuiltInCategory)element.Category.Id.IntegerValue;
                    StructuralAssetClass material = ccLabel.Material;

                    if (server.GetSupportedMaterials().Contains(material) &&
                        server.GetSupportedCategories(material).Contains(category))
                    {
                        ElementId id = new ElementId(element.Id.IntegerValue);

                        SchemaClass  label  = EngineData.ReadElementLabel(category, material, ccLabel, data);
                        ResultStatus status = new Autodesk.Revit.DB.CodeChecking.Storage.ResultStatus(Server.Server.ID, activePackageId);
                        EngineData.VerifyElementLabel(category, material, label, ref status);

                        listElementId.Add(new Tuple <ElementId, ResultStatus>(id, status));
                    }
                }
            }

            return(listElementId);
        }
        public static void filterParam(Element elementEx, Autodesk.Revit.DB.BuiltInCategory Cat, BuiltInParameter param01, BuiltInParameter param02,
                                       BuiltInParameter param03, BuiltInParameter param04, BuiltInParameter param05)
        {
            string elemParam01 = elementEx.get_Parameter(param01).AsValueString();
            string elemParam02 = elementEx.get_Parameter(param02).AsValueString();
            string elemParam03 = elementEx.get_Parameter(param03).AsValueString();
            string elemParam04 = elementEx.get_Parameter(param04).AsValueString();
            string elemParam05 = elementEx.get_Parameter(param05).AsValueString();

            FilteredElementCollector viewCollector = new FilteredElementCollector(doc, uidoc.ActiveView.Id);
            List <Element>           ducts         = new FilteredElementCollector(doc, uidoc.ActiveView.Id)
                                                     .OfCategory(Cat)
                                                     .Where(a => a.get_Parameter(param01).AsValueString() == elemParam01)
                                                     .Where(a => a.get_Parameter(param02).AsValueString() == elemParam02)
                                                     .Where(a => a.get_Parameter(param03).AsValueString() == elemParam03)
                                                     .Where(a => a.get_Parameter(param04).AsValueString() == elemParam04)
                                                     .Where(a => a.get_Parameter(param05).AsValueString() == elemParam05)
                                                     .ToList();

            foreach (Element x in ducts)
            {
                selectedElements.Add(x);
                ListOfElements.Add(x);
            }
        }
Beispiel #4
0
        private ICollection <Element> getElementOrType(Autodesk.Revit.DB.BuiltInCategory categoryId, bool bElement)
        {
            FilteredElementCollector collector          = new FilteredElementCollector(doc);
            ElementCategoryFilter    categoryFilter     = new ElementCategoryFilter(categoryId);
            LogicalAndFilter         categoryTypeFilter = new LogicalAndFilter(categoryFilter, new ElementIsElementTypeFilter(bElement));

            return(collector.WherePasses(categoryTypeFilter).ToElements());
        }
 /// <summary>
 /// Initializes a new instance of the ObjectDataBase object with list of parameters.
 /// </summary>
 /// <param name="elementId">Element identificator.</param>
 /// <param name="elementCategory">Element category.</param>
 /// <param name="elementMaterial">Element material.</param>
 /// <param name="elementLabel">Element label.</param>
 public ObjectDataBase(ElementId elementId,
                       Autodesk.Revit.DB.BuiltInCategory elementCategory,
                       StructuralAssetClass elementMaterial,
                       Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass elementLabel)
 {
     category = elementCategory;
     material = elementMaterial;
     elemId   = new ElementId(elementId.IntegerValue);;
     label    = elementLabel;
 }
Beispiel #6
0
        //--------------------------------------------------------------

        public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
        {
            this.commandData = commandData;
            List <Autodesk.Revit.DB.Element>          revitElements   = new List <Autodesk.Revit.DB.Element>();
            ICollection <Autodesk.Revit.DB.ElementId> revitElementIds = commandData.Application.ActiveUIDocument.Selection.GetElementIds();

            foreach (Autodesk.Revit.DB.ElementId elId in revitElementIds)
            {
                Autodesk.Revit.DB.Element el = commandData.Application.ActiveUIDocument.Document.GetElement(elId);

                Autodesk.Revit.DB.BuiltInCategory cat = (Autodesk.Revit.DB.BuiltInCategory)el.Category.Id.IntegerValue;

                switch (cat)
                {
                case Autodesk.Revit.DB.BuiltInCategory.OST_StructuralColumns:
                case Autodesk.Revit.DB.BuiltInCategory.OST_StructuralFraming:
                case Autodesk.Revit.DB.BuiltInCategory.OST_Floors:
                case Autodesk.Revit.DB.BuiltInCategory.OST_StructuralFoundation:
                case Autodesk.Revit.DB.BuiltInCategory.OST_Walls:
                case Autodesk.Revit.DB.BuiltInCategory.OST_WallAnalytical:
                    revitElements.Add(el);
                    break;

                default:
                    break;
                }
            }

            if (revitElements.Count < 1)
            {
                MessageBox.Show("No structural columns, structural framings, slabs or no walls are selected.");
                return(Autodesk.Revit.UI.Result.Cancelled);
            }

            UIDocument uiDoc = commandData.Application.ActiveUIDocument;

            uiDoc.Selection.GetElementIds().Clear();

            MainWindow mainWindow = new MainWindow(revitElements, On_ElementSelected);

            mainWindow.ShowDialog();

            List <ElementId> elIds = new List <ElementId>();

            foreach (Autodesk.Revit.DB.Element el in revitElements)
            {
                elIds.Add(el.Id);
            }
            uiDoc.Selection.SetElementIds(elIds);
            uiDoc.RefreshActiveView();

            return(Autodesk.Revit.UI.Result.Succeeded);
        }
Beispiel #7
0
        /// <summary>
        /// Reads from Revit information about selected elements and store it in the list with elements data.
        /// </summary>
        /// <param name="data">Acces to cref="ServiceData".</param>
        /// <param name="listElementStatus">List identyficators of elements with result status.</param>
        /// <param name="parameters">Common parameters.</param>
        /// <returns>List of elements data.</returns>
        protected List <ObjectDataBase> ReadListElementData(Autodesk.Revit.DB.CodeChecking.ServiceData data, List <Tuple <ElementId, ResultStatus> > listElementStatus, CommonParametersBase parameters)
        {
            Autodesk.Revit.DB.CodeChecking.Storage.StorageService  service         = Autodesk.Revit.DB.CodeChecking.Storage.StorageService.GetStorageService();
            Autodesk.Revit.DB.CodeChecking.Storage.StorageDocument storageDocument = service.GetStorageDocument(data.Document);

            List <ObjectDataBase> listElementData = new List <ObjectDataBase>();

            foreach (Tuple <ElementId, ResultStatus> elemStatus in listElementStatus)
            {
                Element element = data.Document.GetElement(elemStatus.Item1);
                if (element != null)
                {
                    Autodesk.Revit.DB.CodeChecking.Storage.Label ccLabel = storageDocument.LabelsManager.GetLabel(element);
                    if (ccLabel != null)
                    {
                        Autodesk.Revit.DB.BuiltInCategory category = (Autodesk.Revit.DB.BuiltInCategory)element.Category.Id.IntegerValue;
                        StructuralAssetClass material = ccLabel.Material;
                        Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass label  = EngineData.ReadElementLabel(category, material, ccLabel, data);
                        Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass result = EngineData.CreateElementResult(category, material);

                        ObjectDataBase         objectData       = new ObjectDataBase(elemStatus.Item1, category, material, label);
                        List <SectionDataBase> listSectionsData = new List <SectionDataBase>();
                        List <CalcPoint>       listCalcPoints   = EngineData.CreateCalcPointsForElement(data, parameters, elemStatus.Item1);
                        foreach (CalcPoint p in listCalcPoints)
                        {
                            SectionDataBase sectBase = new SectionDataBase(p, objectData);
                            SectionDataBase sectData = EngineData.CreateSectionData(sectBase);

                            listSectionsData.Add(sectData);
                        }

                        ElementDataBase elemBase = new ElementDataBase(result, listCalcPoints, listSectionsData, elemStatus.Item2, data.Document, objectData);
                        ElementDataBase elemData = EngineData.CreateElementData(elemBase);

                        listElementData.Add(elemData);
                    }
                }
            }

            return(listElementData);
        }
Beispiel #8
0
 public ICollection <Element> getCategoryTypeElements(Autodesk.Revit.DB.BuiltInCategory categoryId)
 {
     return(getElementOrType(categoryId, false));
 }
Beispiel #9
0
        static Result Import3DMFileToProject
        (
            DB.Document doc,
            string filePath,
            DB.BuiltInCategory builtInCategory
        )
        {
            try
            {
                DB.DirectShapeLibrary.GetDirectShapeLibrary(doc).Reset();

                using (var model = File3dm.Read(filePath))
                {
                    var scaleFactor = RhinoMath.UnitScale(model.Settings.ModelUnitSystem, Revit.ModelUnitSystem);

                    using (var trans = new DB.Transaction(doc, "Import 3D Model"))
                    {
                        if (trans.Start() == DB.TransactionStatus.Started)
                        {
                            var categoryId = new DB.ElementId(builtInCategory);
                            var materials  = GetMaterialsByName(doc);

                            var type = DB.DirectShapeType.Create(doc, Path.GetFileName(filePath), categoryId);

                            foreach (var obj in model.Objects.Where(x => !x.Attributes.IsInstanceDefinitionObject && x.Attributes.Space == ActiveSpace.ModelSpace))
                            {
                                if (!obj.Attributes.Visible)
                                {
                                    continue;
                                }

                                var geometryList = ImportObject(doc, model, obj.Geometry, obj.Attributes, materials, scaleFactor).ToArray();
                                if (geometryList?.Length > 0)
                                {
                                    try { type.AppendShape(geometryList); }
                                    catch (Autodesk.Revit.Exceptions.ArgumentException) { }
                                }
                            }

                            var ds = DB.DirectShape.CreateElement(doc, type.Category.Id);
                            ds.SetTypeId(type.Id);

                            var library = DB.DirectShapeLibrary.GetDirectShapeLibrary(doc);
                            if (!library.ContainsType(type.UniqueId))
                            {
                                library.AddDefinitionType(type.UniqueId, type.Id);
                            }

                            ds.SetShape(DB.DirectShape.CreateGeometryInstance(doc, type.UniqueId, DB.Transform.Identity));

                            if (trans.Commit() == DB.TransactionStatus.Committed)
                            {
                                var elements = new DB.ElementId[] { ds.Id };
                                Revit.ActiveUIDocument.Selection.SetElementIds(elements);
                                Revit.ActiveUIDocument.ShowElements(elements);

                                return(Result.Succeeded);
                            }
                        }
                    }
                }
            }
            finally
            {
                DB.DirectShapeLibrary.GetDirectShapeLibrary(doc).Reset();
            }

            return(Result.Failed);
        }
Beispiel #10
0
        public bool SolveOptionalType(ref Optional <DB.FamilySymbol> type, DB.Document doc, DB.BuiltInCategory category, string paramName)
        {
            bool wasMissing = type.IsMissing;

            if (wasMissing)
            {
                type = doc.GetElement(doc.GetDefaultFamilyTypeId(new DB.ElementId(category))) as DB.FamilySymbol ??
                       throw new ArgumentException("No suitable type has been found.", paramName);
            }

            else if (type.Value == null)
            {
                throw new ArgumentNullException(paramName);
            }

            else if (!type.Value.Document.Equals(doc))
            {
                throw new ArgumentException($"{nameof(SolveOptionalType)} failed to assign a type from a diferent document.", nameof(type));
            }

            if (!type.Value.IsActive)
            {
                type.Value.Activate();
            }

            return(wasMissing);
        }
Beispiel #11
0
        public bool SolveOptionalCategory(ref Optional <DB.Category> category, DB.Document doc, DB.BuiltInCategory builtInCategory, string paramName)
        {
            bool wasMissing = category.IsMissing;

            if (wasMissing)
            {
                if (doc.IsFamilyDocument)
                {
                    category = doc.OwnerFamily.FamilyCategory;
                }

                if (category.IsMissing)
                {
                    category = Autodesk.Revit.DB.Category.GetCategory(doc, builtInCategory) ??
                               throw new ArgumentException("No suitable Category has been found.", paramName);
                }
            }

            else if (category.Value == null)
            {
                throw new ArgumentNullException(paramName);
            }

            return(wasMissing);
        }
Beispiel #12
0
        /// <summary>
        /// Retrive family instance hosted in boundary elements
        /// This is the base function for Windows and Doors
        /// </summary>
        /// <param name="cat">The category of hosted elements</param>
        /// <returns></returns>
        private List <FamilyInstance> BoundaryFamilyInstance(DB.BuiltInCategory cat)
        {
            List <FamilyInstance> output = new List <FamilyInstance>();

            //the document of the room
            DB.Document doc = InternalElement.Document; // DocumentManager.Instance.CurrentDBDocument;

            //Find boundary elements and their associated document
            List <DB.ElementId> boundaryElements  = new List <DB.ElementId>();
            List <DB.Document>  boundaryDocuments = new List <DB.Document>();

            foreach (DB.BoundarySegment segment in InternalBoundarySegments)
            {
                DB.Element boundaryElement = doc.GetElement(segment.ElementId);
                if (boundaryElement.GetType() == typeof(DB.RevitLinkInstance))
                {
                    DB.RevitLinkInstance linkInstance = boundaryElement as DB.RevitLinkInstance;
                    boundaryDocuments.Add(linkInstance.GetLinkDocument());
                    boundaryElements.Add(segment.LinkElementId);
                }
                else
                {
                    boundaryDocuments.Add(doc);
                    boundaryElements.Add(segment.ElementId);
                }
            }

            // Create a category filter
            DB.ElementCategoryFilter filter = new DB.ElementCategoryFilter(cat);
            // Apply the filter to the elements in these documents,
            // Use shortcut WhereElementIsNotElementType() to find family instances in all boundary documents
            boundaryDocuments = boundaryDocuments.Distinct().ToList();
            List <DB.FamilyInstance> familyInstances = new List <DB.FamilyInstance>();

            foreach (DB.Document boundaryDocument in boundaryDocuments)
            {
                DB.FilteredElementCollector collector = new DB.FilteredElementCollector(boundaryDocument);
                familyInstances.AddRange(collector.WherePasses(filter).WhereElementIsNotElementType().ToElements().Cast <DB.FamilyInstance>().ToList());
            }

            //Find all family instance hosted on a boundary element
            IEnumerable <DB.FamilyInstance> boundaryFamilyInstances = familyInstances.Where(s => boundaryElements.Contains(s.Host.Id));

            //loop on these boundary family instance to find to and from room
            foreach (DB.FamilyInstance boundaryFamilyInstance in boundaryFamilyInstances)
            {
                DB.Phase familyInstancePhase = boundaryFamilyInstance.Document.GetElement(boundaryFamilyInstance.CreatedPhaseId) as DB.Phase;
                if (boundaryFamilyInstance.get_FromRoom(familyInstancePhase) != null)
                {
                    if (boundaryFamilyInstance.get_FromRoom(familyInstancePhase).Id == InternalRoom.Id)
                    {
                        output.Add(ElementWrapper.ToDSType(boundaryFamilyInstance, true) as FamilyInstance);
                        continue;
                    }
                }

                if (boundaryFamilyInstance.get_ToRoom(familyInstancePhase) != null)
                {
                    if (boundaryFamilyInstance.get_ToRoom(familyInstancePhase).Id == InternalRoom.Id)
                    {
                        output.Add(ElementWrapper.ToDSType(boundaryFamilyInstance, true) as FamilyInstance);
                    }
                }
            }

            output = output.Distinct().ToList();
            return(output);
        }
Beispiel #13
0
        /// <summary>
        /// Reads parameters of user element label.
        /// </summary>
        /// <param name="category">Category of the element.</param>
        /// <param name="material">Material of the element.</param>
        /// <param name="label">Acces to the Revit storage with labels."</param>
        /// <param name="data">Acces to cref="ServiceData".</param>
        /// <returns>User label of the element.</returns>
        public Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass ReadElementLabel(Autodesk.Revit.DB.BuiltInCategory category, Autodesk.Revit.DB.StructuralAssetClass material, Autodesk.Revit.DB.CodeChecking.Storage.Label label, Autodesk.Revit.DB.CodeChecking.ServiceData data)
        {
            if (label != null)
            {
                switch (material)
                {
                case StructuralAssetClass.Concrete:
                    switch (category)
                    {
                    default:
                        break;

                    case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical: return(label.GetEntity <LabelColumn>(data.Document));

                    case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical: return(label.GetEntity <LabelBeam>(data.Document));
                    }
                    break;

                case StructuralAssetClass.Metal:
                    break;
                }
            }

            return(null);
        }
Beispiel #14
0
        /// <summary>
        /// Creates new instance of class with results for the element.
        /// </summary>
        /// <param name="category">Category of the element.</param>
        /// <param name="material">Material of the element.</param>
        /// <returns>User result schema object for the element.</returns>
        public Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass CreateElementResult(Autodesk.Revit.DB.BuiltInCategory category, Autodesk.Revit.DB.StructuralAssetClass material)
        {
            switch (material)
            {
            case StructuralAssetClass.Concrete:
                switch (category)
                {
                default:
                    break;

                case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical:
                    return(new ResultBeam());

                case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical:
                    return(new ResultColumn());
                }
                break;

            case StructuralAssetClass.Metal:
                break;
            }

            return(null);
        }
        /// <summary>
        /// Creates list of cref="ICalculationObject".
        /// </summary>
        /// <param name="category">Category of the element.</param>
        /// <param name="material">Material of the element.</param>
        /// <returns>List of cref="ICalculationObject".</returns>
        public List <ICalculationObject> CalculationScenarioList(Autodesk.Revit.DB.BuiltInCategory category, Autodesk.Revit.DB.StructuralAssetClass material)
        {
            List <ICalculationObject> scenario = new List <ICalculationObject>();

            /// <structural_toolkit_2015>
            switch (material)
            {
            case StructuralAssetClass.Concrete:
                switch (category)
                {
                case BuiltInCategory.OST_BeamAnalytical:
                case BuiltInCategory.OST_ColumnAnalytical:
                {
                    PrepareSectionData calcObj = new PrepareSectionData();
                    calcObj.Type          = CalculationObjectType.Section;
                    calcObj.ErrorResponse = ErrorResponse.SkipOnError;
                    calcObj.Categories    = new List <BuiltInCategory>()
                    {
                        BuiltInCategory.OST_BeamAnalytical, BuiltInCategory.OST_ColumnAnalytical
                    };
                    scenario.Add(calcObj);
                }
                    {
                        ModifyElementForces calcObj = new ModifyElementForces();
                        calcObj.Type          = CalculationObjectType.Element;
                        calcObj.ErrorResponse = ErrorResponse.SkipOnError;
                        calcObj.Categories    = new List <BuiltInCategory>()
                        {
                            BuiltInCategory.OST_BeamAnalytical, BuiltInCategory.OST_ColumnAnalytical
                        };
                        scenario.Add(calcObj);
                    }
                    {
                        CalculateSection calcObj = new CalculateSection();
                        calcObj.Type          = CalculationObjectType.Section;
                        calcObj.ErrorResponse = ErrorResponse.SkipOnError;
                        calcObj.Categories    = new List <BuiltInCategory>()
                        {
                            BuiltInCategory.OST_BeamAnalytical, BuiltInCategory.OST_ColumnAnalytical
                        };
                        scenario.Add(calcObj);
                    }
                    {
                        CalculateDeflection calcObj = new CalculateDeflection();
                        calcObj.Type          = CalculationObjectType.Element;
                        calcObj.ErrorResponse = ErrorResponse.SkipOnError;
                        calcObj.Categories    = new List <BuiltInCategory>()
                        {
                            BuiltInCategory.OST_BeamAnalytical
                        };
                        scenario.Add(calcObj);
                    }
                    {
                        FillResultData calcObj = new FillResultData();
                        calcObj.Type          = CalculationObjectType.Element;
                        calcObj.ErrorResponse = ErrorResponse.RunOnError;
                        calcObj.Categories    = new List <BuiltInCategory>()
                        {
                            BuiltInCategory.OST_BeamAnalytical, BuiltInCategory.OST_ColumnAnalytical
                        };
                        scenario.Add(calcObj);
                    }
                    break;

                case Autodesk.Revit.DB.BuiltInCategory.OST_FloorAnalytical:
                case Autodesk.Revit.DB.BuiltInCategory.OST_FoundationSlabAnalytical:
                case Autodesk.Revit.DB.BuiltInCategory.OST_WallAnalytical:
                {
                    PrepareSectionData calcObj = new PrepareSectionData();
                    calcObj.Type          = CalculationObjectType.Section;
                    calcObj.ErrorResponse = ErrorResponse.SkipOnError;
                    calcObj.Categories    = new List <BuiltInCategory>()
                    {
                        BuiltInCategory.OST_FloorAnalytical, BuiltInCategory.OST_FoundationSlabAnalytical, BuiltInCategory.OST_WallAnalytical
                    };
                    scenario.Add(calcObj);
                }
                    {
                        ModifyElementForces calcObj = new ModifyElementForces();
                        calcObj.Type          = CalculationObjectType.Element;
                        calcObj.ErrorResponse = ErrorResponse.SkipOnError;
                        calcObj.Categories    = new List <BuiltInCategory>()
                        {
                            BuiltInCategory.OST_FloorAnalytical, BuiltInCategory.OST_FoundationSlabAnalytical, BuiltInCategory.OST_WallAnalytical
                        };
                        scenario.Add(calcObj);
                    }
                    {
                        CalculateSection calcObj = new CalculateSection();
                        calcObj.Type          = CalculationObjectType.Section;
                        calcObj.ErrorResponse = ErrorResponse.SkipOnError;
                        calcObj.Categories    = new List <BuiltInCategory>()
                        {
                            BuiltInCategory.OST_FloorAnalytical, BuiltInCategory.OST_FoundationSlabAnalytical, BuiltInCategory.OST_WallAnalytical
                        };
                        scenario.Add(calcObj);
                    }
                    {
                        FillResultData calcObj = new FillResultData();
                        calcObj.Type          = CalculationObjectType.Element;
                        calcObj.ErrorResponse = ErrorResponse.RunOnError;
                        calcObj.Categories    = new List <BuiltInCategory>()
                        {
                            BuiltInCategory.OST_FloorAnalytical, BuiltInCategory.OST_FoundationSlabAnalytical, BuiltInCategory.OST_WallAnalytical
                        };
                        scenario.Add(calcObj);
                    }
                    break;
                }
                break;
            }
            /// </structural_toolkit_2015>

            return(scenario);
        }
Beispiel #16
0
        /// <summary>
        /// Verify parameters of user element label.
        /// </summary>
        /// <param name="category">Category of the element.</param>
        /// <param name="material">Material of the element.</param>
        /// <param name="label">Element label."</param>
        /// <param name="status">Reference to element's status".</param>
        public void VerifyElementLabel(Autodesk.Revit.DB.BuiltInCategory category, StructuralAssetClass material, Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass label,
                                       ref Autodesk.Revit.DB.CodeChecking.Storage.ResultStatus status)
        {
            if (label != null)
            {
                switch (material)
                {
                case StructuralAssetClass.Concrete:
                    switch (category)
                    {
                    default:
                        break;

                    case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical:
                    {
                        LabelColumn labelCol = label as LabelColumn;
                        if (labelCol != null)
                        {
                            if (labelCol.EnabledInternalForces.Count == 0)
                            {
                                status.AddError(Resources.ResourceManager.GetString("ErrNoChosenInternalForces"));
                            }
                            List <string> errors = VerifySteel(labelCol.LongitudinalReinforcement, true);
                            foreach (string s in errors)
                            {
                                status.AddError(s);
                            }
                            errors = VerifySteel(labelCol.TransversalReinforcement, false);
                            foreach (string s in errors)
                            {
                                status.AddError(s);
                            }
                        }
                    }
                    break;

                    case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical:
                    {
                        LabelBeam labelBm = label as LabelBeam;
                        if (labelBm != null)
                        {
                            if (labelBm.EnabledInternalForces.Count == 0)
                            {
                                status.AddError(Resources.ResourceManager.GetString("ErrNoChosenInternalForces"));
                            }
                            List <string> errors = VerifySteel(labelBm.LongitudinalReinforcement, true);
                            foreach (string s in errors)
                            {
                                status.AddError(s);
                            }
                            errors = VerifySteel(labelBm.TransversalReinforcement, false);
                            foreach (string s in errors)
                            {
                                status.AddError(s);
                            }
                        }
                    }
                    break;
                    }
                    break;

                case StructuralAssetClass.Metal:
                    break;
                }
            }
        }
Beispiel #17
0
        /// <summary>
        /// Creates new instance of class with results for the element.
        /// </summary>
        /// <param name="category">Category of the element.</param>
        /// <param name="material">Material of the element.</param>
        /// <returns>User result schema object for the element.</returns>
        public Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass CreateElementResult(Autodesk.Revit.DB.BuiltInCategory category, Autodesk.Revit.DB.StructuralAssetClass material)
        {
            switch (material)
            {
            case StructuralAssetClass.Concrete:
                switch (category)
                {
                default:
                    break;

                case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical:
                    return(new ResultBeam());

                case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical:
                    return(new ResultColumn());

                /// <structural_toolkit_2015>
                case Autodesk.Revit.DB.BuiltInCategory.OST_FloorAnalytical:
                    return(new ResultFloor());

                case Autodesk.Revit.DB.BuiltInCategory.OST_FoundationSlabAnalytical:
                    return(new ResultFloor());

                case Autodesk.Revit.DB.BuiltInCategory.OST_WallAnalytical:
                    return(new ResultWall());
                    /// </structural_toolkit_2015>
                }
                break;

            case StructuralAssetClass.Metal:
                break;
            }

            return(null);
        }