Compute geometry information and store geometry information.
Beispiel #1
0
        /// <summary>
        /// Do some check for the selection elements, includes geometry check.
        /// If the data doesn't meet our need, Exception will be thrown.
        /// </summary>
        private void Assert()
        {
            // Reserve all element ids for following iteration
            List <ElementId> selectedIds = new List <ElementId>();

            foreach (Autodesk.Revit.DB.ElementId elemId in m_rvtUIDoc.Selection.GetElementIds())
            {
                Autodesk.Revit.DB.Element elem = m_rvtUIDoc.Document.GetElement(elemId);
                selectedIds.Add(elem.Id);
            }
            if (selectedIds.Count == 0)
            {
                throw new Exception("Please select a concrete beam or column to create rebar.");
            }

            //
            // Construct filter to find expected rebar host
            // Structural type filters firstly
            LogicalOrFilter stFilter = new LogicalOrFilter(
                new ElementStructuralTypeFilter(StructuralType.Beam),
                new ElementStructuralTypeFilter(StructuralType.Column));
            // + StructuralMaterial
            LogicalAndFilter hostFilter = new LogicalAndFilter(stFilter,
                                                               new StructuralMaterialTypeFilter(StructuralMaterialType.Concrete));
            // Expected rebar host: it should be family instance
            FilteredElementCollector collector = new FilteredElementCollector(m_rvtUIDoc.Document, selectedIds);
            FamilyInstance           rebarHost = collector.OfClass(typeof(FamilyInstance)).WherePasses(hostFilter).FirstElement() as FamilyInstance;

            // Make sure the selected beam or column is rectangular.
            try
            {
                m_geometryData = new GeometrySupport(rebarHost);
            }
            catch
            {
                throw new Exception("Please select a beam or column in rectangular shape.");
            }

            m_rebarHost = rebarHost;

            // Judge the rebar host is a valid host.
            RebarHostData rebarHostData = RebarHostData.GetRebarHostData(rebarHost);

            if (rebarHostData == null || !rebarHostData.IsValidHost())
            {
                throw new Exception("The selected element is not a valid rebar host.");
            }

            // Make sure the selected beam or column doesn't contain any rebar.
            if (rebarHostData.GetRebarsInHost().Count > 0)
            {
                throw new Exception("Please select a beam or a column which doesn't contain any rebar.");
            }
        }
Beispiel #2
0
        /// <summary>
        /// Do some check for the selection elements, includes geometry check.
        /// If the data doesn't meet our need, Exception will be thrown.
        /// </summary>
        private void Assert()
        {
            // Reserve all element ids for following iteration
            List<ElementId> selectedIds = new List<ElementId>();
            foreach (Autodesk.Revit.DB.Element elem in m_rvtUIDoc.Selection.Elements)
            {
                selectedIds.Add(elem.Id);
            }
            if (selectedIds.Count == 0)
                throw new Exception("Please select a concrete beam or column to create rebar.");

            //
            // Construct filter to find expected rebar host
            // Structural type filters firstly
            LogicalOrFilter stFilter = new LogicalOrFilter(
                new ElementStructuralTypeFilter(StructuralType.Beam),
                new ElementStructuralTypeFilter(StructuralType.Column));
            // + StructuralMaterial
            LogicalAndFilter hostFilter = new LogicalAndFilter(stFilter,
                new StructuralMaterialTypeFilter(StructuralMaterialType.Concrete));
            // Expected rebar host: it should be family instance
            FilteredElementCollector collector = new FilteredElementCollector(m_rvtUIDoc.Document, selectedIds);
            FamilyInstance rebarHost = collector.OfClass(typeof(FamilyInstance)).WherePasses(hostFilter).FirstElement() as FamilyInstance;
            // Make sure the selected beam or column is rectangular.
            try
            {
                m_geometryData = new GeometrySupport(rebarHost);
            }
            catch
            {
                throw new Exception("Please select a beam or column in rectangular shape.");
            }

            m_rebarHost = rebarHost;

            // Judge the rebar host is a valid host.
            RebarHostData rebarHostData = RebarHostData.GetRebarHostData(rebarHost);
            if (rebarHostData == null || !rebarHostData.IsValidHost())
            {
                throw new Exception("The selected element is not a valid rebar host.");
            }

            // Make sure the selected beam or column doesn't contain any rebar.
            if (rebarHostData.GetRebarsInHost().Count > 0)
            {
                throw new Exception("Please select a beam or a column which doesn't contain any rebar.");
            }
        }