當前位置: 首頁>>代碼示例>>C#>>正文


C# Autodesk.ControlPoints方法代碼示例

本文整理匯總了C#中Autodesk.ControlPoints方法的典型用法代碼示例。如果您正苦於以下問題:C# Autodesk.ControlPoints方法的具體用法?C# Autodesk.ControlPoints怎麽用?C# Autodesk.ControlPoints使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Autodesk的用法示例。


在下文中一共展示了Autodesk.ControlPoints方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Convert

        /// <summary>
        /// Convert a DS BSplineCurve to a Revit NurbSpline
        /// </summary>
        /// <param name="crv"></param>
        /// <returns></returns>
        private static Autodesk.Revit.DB.Curve Convert(Autodesk.DesignScript.Geometry.NurbsCurve crv)
        {
            if (crv.Degree == 1 && crv.ControlPoints().Length == 2 && !crv.IsRational)
            {
                return Autodesk.Revit.DB.Line.CreateBound(crv.ControlPoints()[0].ToXyz(), 
                    crv.ControlPoints()[1].ToXyz());
            }

            if (crv.Degree <= 2)
            {
                throw new Exception("Could not convert the curve to a Revit curve");
            }

            // presumably checking if the curve is circular is quite expensive, we don't do it
            return Autodesk.Revit.DB.NurbSpline.Create(crv.ControlPoints().ToXyzs(),
                crv.Weights(),
                crv.Knots(),
                crv.Degree,
                crv.IsClosed,
                crv.IsRational );
        }
開發者ID:algobasket,項目名稱:Dynamo,代碼行數:26,代碼來源:ProtoToRevitCurve.cs

示例2: Convert

        private static Autodesk.Revit.DB.Curve Convert(Autodesk.DesignScript.Geometry.NurbsCurve crv)
        {
            // line
            if (crv.Degree == 1 && crv.ControlPoints().Length == 2 && !crv.IsRational)
            {
                return Autodesk.Revit.DB.Line.CreateBound(crv.ControlPoints()[0].ToXyz(false), 
                    crv.ControlPoints()[1].ToXyz(false));
            }

            // polyline - not allowed
            if (crv.Degree == 1)
            {
                throw new Exception(
                    "Degree 1 Nurbs Curves are not allowed in Revit!  Try splitting the curve into "
                        +
                        "individual linear pieces");
            }

            // bezier
            if (crv.Degree == 2 && crv.ControlPoints().Count() == 3 && !crv.IsRational)
            {
                var converted = NurbsUtils.ElevateBezierDegree(crv, 3);

                return Autodesk.Revit.DB.NurbSpline.Create(converted.ControlPoints().ToXyzs(false),
                    converted.Weights(),
                    converted.Knots(),
                    converted.Degree,
                    converted.IsClosed,
                    converted.IsRational);
            }

            // degree 2 curve
            if (crv.Degree == 2)
            {
                // TODO: general NURBS degree elevation
                var numSamples = crv.ControlPoints().Count() + 1;
                var pts = Enumerable.Range(0, numSamples).Select(x => x/(double)numSamples)
                    .Select(crv.PointAtParameter);

                var resampledCrv = NurbsCurve.ByPointsTangents(
                    pts,
                    crv.TangentAtParameter(0).Normalized(),
                    crv.TangentAtParameter(1).Normalized());

                return Autodesk.Revit.DB.NurbSpline.Create(resampledCrv.ControlPoints().ToXyzs(false),
                    resampledCrv.Weights(),
                    resampledCrv.Knots(),
                    resampledCrv.Degree,
                    resampledCrv.IsClosed,
                    resampledCrv.IsRational);
            }

            // general implementation
            return Autodesk.Revit.DB.NurbSpline.Create(crv.ControlPoints().ToXyzs(false),
                crv.Weights(),
                crv.Knots(),
                crv.Degree,
                crv.IsClosed,
                crv.IsRational);

        }
開發者ID:heegwon,項目名稱:Dynamo,代碼行數:61,代碼來源:ProtoToRevitCurve.cs


注:本文中的Autodesk.ControlPoints方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。