Beispiel #1
0
        /// <summary> 将 CurveArray 中的曲线进行重新排列,以组成连续的曲线链 </summary>
        /// <param name="curveArr"> 要进行重组的曲线集合 </param>
        /// <param name="contigeousCurves"> 如果不能形成连续的曲线链,则返回 null </param>
        public static void GetContiguousCurvesFromCurves(CurveArray curveArr, out IList <Curve> contigeousCurves)
        {
            IList <Curve> curves = curveArr.Cast <Curve>().ToList();

            // Build a list of curves from the curve elements
            contigeousCurves = CurvesFormator.GetContiguousCurvesFromCurves(curves);
        }
Beispiel #2
0
        /// <summary> 将 CurveArray 中的曲线进行重新排列,以组成连续的曲线链 </summary>
        /// <param name="curveArr"> 要进行重组的曲线集合 </param>
        /// <param name="contigeousCurves"> 如果不能形成连续的曲线链,则返回 null,从外部调用来看,此参数可以与第一个参数curveArr赋同一个实参。 </param>
        public static void GetContiguousCurvesFromCurves(CurveArray curveArr, out CurveArray contigeousCurves)
        {
            IList <Curve> curves;

            // Build a list of curves from the curve elements
            CurvesFormator.GetContiguousCurvesFromCurves(curveArr, out curves);

            CurvesConverter.Convert(curves, out contigeousCurves);
        }
Beispiel #3
0
        /// <summary>
        /// 从选择的Curve Elements中,获得连续排列的多段曲线(不一定要封闭)。
        /// </summary>
        /// <param name="doc">曲线所在文档</param>
        /// <param name="SelectedCurves">多条曲线元素所对应的Reference,可以通过Selection.PickObjects返回。
        /// 注意,SelectedCurves中每一条曲线都必须是有界的(IsBound),否则,其GetEndPoint会报错。</param>
        /// <returns>如果输入的曲线可以形成连续的多段线,则返回重新排序后的多段线集合;
        /// 如果输入的曲线不能形成连续的多段线,则返回Nothing!</returns>
        public static IList <Curve> GetContiguousCurvesFromCurves(Document doc, IList <Reference> SelectedCurves)
        {
            IList <Curve> curves = new List <Curve>();

            // Build a list of curves from the curve elements
            foreach (Reference reference in SelectedCurves)
            {
                CurveElement curveElement = doc.GetElement(reference) as CurveElement;
                curves.Add(curveElement.GeometryCurve.Clone());
            }
            //
            curves = CurvesFormator.GetContiguousCurvesFromCurves(curves);
            return(curves);
        }
Beispiel #4
0
        /// <summary>
        /// 检测当前集合中的曲线是否符合指定的连续性要求
        /// </summary>
        /// <param name="curveIds">被检验的模型线集合</param>
        /// <param name="continueDraw">在检查连续性后是否要继续绘制</param>
        /// <returns></returns>
        private CurvesState ValidateCurves(List <ElementId> curveIds, out bool continueDraw)
        {
            CurvesState cs = CurvesState.Invalid;

            continueDraw = false;

            if (curveIds.Any())
            {
                List <Curve> curves = new List <Curve>();
                //将ElementId转换为对应的 Curve 对象
                foreach (var id in curveIds)
                {
                    curves.Add(((ModelCurve)doc.GetElement(id)).GeometryCurve);
                }

                // 根据不同的模式进行不同的检测
                if (this.CheckMode == CurveCheckMode.Connected) // 一条连续曲线链
                {
                    if (CurvesFormator.GetContiguousCurvesFromCurves(curves) != null)
                    {
                        cs           = CurvesState.Validated;
                        continueDraw = true;
                    }
                    else // 说明根本不连续
                    {
                        cs           = CurvesState.Invalid;
                        continueDraw = false;
                    }
                }
                else if (this.CheckMode == CurveCheckMode.Closed)
                {
                    IList <Curve> CurveChain = default(List <Curve>);

                    //  MessageBox.Show(GeoHelper.GetCurvesEnd(curves));
                    CurveChain = CurvesFormator.GetContiguousCurvesFromCurves(curves);

                    if (CurveChain == null) // 说明根本就不连续
                    {
                        cs           = CurvesState.Invalid;
                        continueDraw = false;
                    }
                    else // 说明起码是连续的
                    {
                        if (CurveChain.First().GetEndPoint(0).DistanceTo(CurveChain.Last().GetEndPoint(1)) <
                            GeoHelper.VertexTolerance)
                        {
                            // 说明整个连续曲线是首尾相接,即是闭合的。此时就不需要再继续绘制下去了
                            cs           = CurvesState.Validated;
                            continueDraw = false;
                        }
                        else
                        {
                            // 说明整个曲线是连续的,但是还没有闭合。此时就可以继续绘制下去
                            cs           = CurvesState.Validating;
                            continueDraw = true;
                        }
                    }
                }
                else if (this.CheckMode == (CurveCheckMode.HorizontalPlan | CurveCheckMode.Closed))
                {
                    if (CurvesFormator.IsInOnePlan(curves, new XYZ(0, 0, 1)))
                    {
                    }
                    return(CurvesState.Invalid);
                }
                else if (this.CheckMode == CurveCheckMode.Seperated)
                {
                    // 不用检测,直接符合
                    cs           = CurvesState.Validated;
                    continueDraw = true;
                }
            }
            else  // 说明当前集合中一个模型线元素都没有
            {
            }
            return(cs);
        }