provide some common geometry judgement and calculate method
Пример #1
0
        /// <summary>
        /// get necessary data when create AreaReinforcement on a horizontal floor
        /// </summary>
        /// <param name="floor">floor on which to create AreaReinforcemen</param>
        /// <param name="refer">reference of the horizontal face on the floor</param>
        /// <param name="curves">curves compose the horizontal face of the floor</param>
        /// <returns>is successful</returns>
        public bool GetFloorGeom(Floor floor, ref Reference refer, ref IList <Curve> curves)
        {
            //get horizontal face's reference
            FaceArray faces = GeomUtil.GetFaces(floor);

            foreach (Face face in faces)
            {
                if (GeomUtil.IsHorizontalFace(face))
                {
                    refer = face.Reference;
                    break;
                }
            }
            if (null == refer)
            {
                return(false);
            }
            //get analytical model profile
            AnalyticalModel model = floor.GetAnalyticalModel();

            if (null == model)
            {
                return(false);
            }

            curves = model.GetCurves(AnalyticalCurveType.ActiveCurves);

            if (!GeomUtil.IsRectangular(curves))
            {
                return(false);
            }
            curves = AddInlaidCurves(curves, 0.5);

            return(true);
        }
Пример #2
0
        /// <summary>
        /// get necessary data when create AreaReinforcement on a horizontal floor
        /// </summary>
        /// <param name="floor">floor on which to create AreaReinforcemen</param>
        /// <param name="refer">reference of the horizontal face on the floor</param>
        /// <param name="curves">curves compose the horizontal face of the floor</param>
        /// <returns>is successful</returns>
        public bool GetFloorGeom(Floor floor, ref Reference refer, ref IList <Curve> curves)
        {
            //get horizontal face's reference
            FaceArray faces = GeomUtil.GetFaces(floor);

            foreach (Face face in faces)
            {
                if (GeomUtil.IsHorizontalFace(face))
                {
                    refer = face.Reference;
                    break;
                }
            }
            if (null == refer)
            {
                return(false);
            }
            //get analytical model profile
            AnalyticalPanel model    = null;
            Document        document = floor.Document;
            AnalyticalToPhysicalAssociationManager assocManager = AnalyticalToPhysicalAssociationManager.GetAnalyticalToPhysicalAssociationManager(document);

            if (assocManager != null)
            {
                ElementId associatedElementId = assocManager.GetAssociatedElementId(floor.Id);
                if (associatedElementId != ElementId.InvalidElementId)
                {
                    Element associatedElement = document.GetElement(associatedElementId);
                    if (associatedElement != null && associatedElement is AnalyticalPanel)
                    {
                        model = associatedElement as AnalyticalPanel;
                    }
                }
            }
            if (null == model)
            {
                return(false);
            }

            curves = model.GetOuterContour().ToList();
            if (!GeomUtil.IsRectangular(curves))
            {
                return(false);
            }
            curves = AddInlaidCurves(curves, 0.5);

            return(true);
        }
Пример #3
0
        /// <summary>
        /// create CurveArray which contain 8 curves, 4 is exterior lines and 4 is interior lines
        /// </summary>
        /// <param name="curves"></param>
        /// <param name="scale"></param>
        /// <returns></returns>
        private IList <Curve> AddInlaidCurves(IList <Curve> curves, double scale)
        {
            //because curves is readonly, can't use method Curve.Append(Curve)
            List <Line> lines = new List <Line>();

            for (int i = 0; i < 4; i++)
            {
                Line temp = curves[i] as Line;
                lines.Add(temp);
            }

            //length and width of the rectangle
            double length = GeomUtil.GetLength(lines[0]);
            double width  = GeomUtil.GetLength(lines[1]);

            for (int i = 0; i < 2; i++)
            {
                //height line
                Line   tempLine1   = lines[i * 2];
                Line   scaledLine1 = GeomUtil.GetScaledLine(tempLine1, scale);
                double distance1   = scale / 2 * width;
                Line   movedLine1  = GeomUtil.GetXYParallelLine(scaledLine1, distance1);
                lines.Add(movedLine1);

                //width line
                Line   tempLine2   = lines[i * 2 + 1];
                Line   scaledLine2 = GeomUtil.GetScaledLine(tempLine2, scale);
                double distance2   = scale / 2 * length;
                Line   movedLine2  = GeomUtil.GetXYParallelLine(scaledLine2, distance2);
                lines.Add(movedLine2);
            }

            //add all 8 lines into return array
            IList <Curve> allLines = new List <Curve>();

            for (int i = 0; i < 8; i++)
            {
                allLines.Add(lines[i]);
            }
            return(allLines);
        }