当前位置: 首页>>代码示例>>C#>>正文


C# XYZ.GetLength方法代码示例

本文整理汇总了C#中XYZ.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# XYZ.GetLength方法的具体用法?C# XYZ.GetLength怎么用?C# XYZ.GetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XYZ的用法示例。


在下文中一共展示了XYZ.GetLength方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        public Result Execute(
            ExternalCommandData revit,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = revit.Application;
              UIDocument uidoc = uiapp.ActiveUIDocument;
              Document doc = uidoc.Document;

              using( Transaction tx = new Transaction( doc ) )
              {
            tx.Start( "Create Sloped Slab" );

            double width = 19.685039400;
            double length = 59.055118200;
            double height = 9.84251968503937;

            XYZ[] pts = new XYZ[] {
              new XYZ( 0.0, 0.0, height ),
              new XYZ( width, 0.0, height ),
              new XYZ( width, length, height ),
              new XYZ( 0, length, height )
            };

            CurveArray profile
              = uiapp.Application.Create.NewCurveArray();

            Line line = null;

            int n = pts.GetLength( 0 );

            XYZ q = pts[n - 1];

            foreach( XYZ p in pts )
            {
              line = Line.CreateBound( q, p );
              profile.Append( line );
              q = p;
            }

            Level level
              = new FilteredElementCollector( doc )
            .OfClass( typeof( Level ) )
            .Where<Element>(
              e => e.Name.Equals( "CreateSlopedSlab" ) )
              .FirstOrDefault<Element>() as Level;

            if( null == level )
            {
              level = doc.Create.NewLevel( height );
              level.Name = "Sloped Slab";
            }

            Floor floor = doc.Create.NewSlab(
              profile, level, line, 0.5, true );

            tx.Commit();
              }
              return Result.Succeeded;
        }
开发者ID:nbright,项目名称:the_building_coder_samples,代码行数:60,代码来源:CmdCreateSlopedSlab.cs

示例2: ToSphericalCoordinates

        public static void ToSphericalCoordinates(XYZ input, out double r, out double theta, out double phi)
        {
            // set length
            r = input.GetLength();

            // if the length is too small the angles will be degenerate, just set them as 0
            if (Math.Abs(r) < System.Double.Epsilon)
            {
                theta = 0;
                phi = 0;
                return;
            }

            // get the length of the projection on the xy plane
            var rInXYPlane = (new XYZ(input.X, input.Y, 0)).GetLength();

            // if projected length is 0, xyz is pointing up, down, or is origin
            if (Math.Abs(rInXYPlane) < System.Double.Epsilon)
            {
                // this should have already been detected when r is 0, but check anyway
                if (Math.Abs(input.Z) < System.Double.Epsilon)
                {
                    theta = 0;
                    phi = 0;
                    return;
                }
                else // determine whether vector is above or below - if above phi is 0
                {
                    theta = 0;
                    phi = input.Z > 0 ? 0 : Math.PI;
                    return;
                }
            }

            // if x is 0, this indicates vector is at 90 or 270
            if (Math.Abs(input.X) < System.Double.Epsilon)
            {
                theta = input.Y > 0 ? Math.PI / 2 : 3 * Math.PI / 2;
            }
            else
            {
                theta = Math.Atan(input.Y / input.X);
            }

            // phew...
            phi = Math.Acos(input.Z / r);
        }
开发者ID:riteshchandawar,项目名称:Dynamo,代码行数:47,代码来源:XYZ.cs

示例3: DrawModelLineLoop

        /// <summary>
        /// Create model lines representing a closed 
        /// planar loop in the given sketch plane.
        /// </summary>
        static void DrawModelLineLoop(
            SketchPlane sketchPlane,
            XYZ[] corners)
        {
            Autodesk.Revit.Creation.Document factory
            = sketchPlane.Document.Create;

              int n = corners.GetLength( 0 );

              for( int i = 0; i < n; ++i )
              {
            int j = 0 == i ? n - 1 : i - 1;

            factory.NewModelCurve( Line.CreateBound(
              corners[j], corners[i] ), sketchPlane );
              }
        }
开发者ID:jeremytammik,项目名称:DirectShapeFromFace,代码行数:21,代码来源:CreateDirectShape.cs


注:本文中的XYZ.GetLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。