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


C# XYZ类代码示例

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


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

示例1: Execute

        public IExternalCommand.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            Application revit = commandData.Application;
            Document curDoc = revit.ActiveDocument;
            FamilySymbol symbol = null;
            ElementSetIterator selIt = curDoc.Selection.Elements.ForwardIterator();
            if (selIt.MoveNext())
            {
                FamilyInstance fi = selIt.Current as FamilyInstance;
                symbol = fi.Symbol;
            }
            if (symbol == null)
            {
                message = "Please select a family instance!";
                return IExternalCommand.Result.Cancelled;
            }

            XYZ startPoint = new XYZ(0, 30, 0);
            FamilyInstance createdFamily = curDoc.Create.NewFamilyInstance(ref startPoint, symbol, Autodesk.Revit.Structural.Enums.StructuralType.UnknownFraming);
            if (null == createdFamily)
            {
                message = "Create the family failed.";
                return IExternalCommand.Result.Failed;
            }

            return IExternalCommand.Result.Succeeded;
        }
开发者ID:guchanghai,项目名称:Cut,代码行数:27,代码来源:NewFamilyInstance.cs

示例2: ConvertBasePoint

        /// <summary>
        //MOVES THE CAMERA ACCORDING TO THE PROJECT BASE LOCATION 
        //function that changes the coordinates accordingly to the project base location to an absolute location (for BCF export)
        //if the value negative is set to true, does the opposite (for opening BCF views)
        /// </summary>
        /// <param name="c">center</param>
        /// <param name="view">view direction</param>
        /// <param name="up">up direction</param>
        /// <param name="negative">convert to/from</param>
        /// <returns></returns>
        public static ViewOrientation3D ConvertBasePoint(Document doc, XYZ c, XYZ view, XYZ up, bool negative)
        {
            //UIDocument uidoc = uiapp.ActiveUIDocument;
            //Document doc = uidoc.Document;

            //ElementCategoryFilter filter = new ElementCategoryFilter(BuiltInCategory.OST_ProjectBasePoint);
            //FilteredElementCollector collector = new FilteredElementCollector(doc);
            //System.Collections.Generic.IEnumerable<Element> elements = collector.WherePasses(filter).ToElements();

            double angle = 0;
            double x = 0;
            double y = 0;
            double z = 0;

            //VERY IMPORTANT
            //BuiltInParameter.BASEPOINT_EASTWEST_PARAM is the value of the BASE POINT LOCATION
            //position is the location of the BPL related to Revit's absolute origini!
            //if BPL is set to 0,0,0 not always it corresponds to Revit's origin

            ProjectLocation projectLocation = doc.ActiveProjectLocation;
            XYZ origin = new XYZ(0, 0, 0);
            ProjectPosition position = projectLocation.get_ProjectPosition(origin);

            int i = (negative) ? -1 : 1;
            //foreach (Element element in elements)
            //{
            //    MessageBox.Show(UnitUtils.ConvertFromInternalUnits(position.EastWest, DisplayUnitType.DUT_METERS).ToString() + "  " + element.get_Parameter(BuiltInParameter.BASEPOINT_EASTWEST_PARAM).AsValueString() + "\n" +
            //        UnitUtils.ConvertFromInternalUnits(position.NorthSouth, DisplayUnitType.DUT_METERS).ToString() + "  " + element.get_Parameter(BuiltInParameter.BASEPOINT_NORTHSOUTH_PARAM).AsValueString() + "\n" +
            //        UnitUtils.ConvertFromInternalUnits(position.Elevation, DisplayUnitType.DUT_METERS).ToString() + "  " + element.get_Parameter(BuiltInParameter.BASEPOINT_ELEVATION_PARAM).AsValueString() + "\n" +
            //        position.Angle.ToString() + "  " + element.get_Parameter(BuiltInParameter.BASEPOINT_ANGLETON_PARAM).AsDouble().ToString());
            //}
            x = i * position.EastWest;
            y = i * position.NorthSouth;
            z = i * position.Elevation;
            angle = i * position.Angle;

            if (negative) // I do the addition BEFORE
                c = new XYZ(c.X + x, c.Y + y, c.Z + z);

            //rotation
            double centX = (c.X * Math.Cos(angle)) - (c.Y * Math.Sin(angle));
            double centY = (c.X * Math.Sin(angle)) + (c.Y * Math.Cos(angle));

            XYZ newC = new XYZ();
            if (negative)
                newC = new XYZ(centX, centY, c.Z);
            else // I do the addition AFTERWARDS
                newC = new XYZ(centX + x, centY + y, c.Z + z);


            double viewX = (view.X * Math.Cos(angle)) - (view.Y * Math.Sin(angle));
            double viewY = (view.X * Math.Sin(angle)) + (view.Y * Math.Cos(angle));
            XYZ newView = new XYZ(viewX, viewY, view.Z);

            double upX = (up.X * Math.Cos(angle)) - (up.Y * Math.Sin(angle));
            double upY = (up.X * Math.Sin(angle)) + (up.Y * Math.Cos(angle));

            XYZ newUp = new XYZ(upX, upY, up.Z);
            return new ViewOrientation3D(newC, newUp, newView);
        }
开发者ID:ArupAus,项目名称:issue-tracker,代码行数:70,代码来源:Utils.cs

示例3: CreateDimensionElement

        /// <summary>
        /// Create a new dimension element using the given
        /// references and dimension line end points.
        /// This method opens and commits its own transaction,
        /// assuming that no transaction is open yet and manual
        /// transaction mode is being used.
        /// Note that this has only been tested so far using
        /// references to surfaces on planar walls in a plan
        /// view.
        /// </summary>
        public static void CreateDimensionElement(
            View view,
            XYZ p1,
            Reference r1,
            XYZ p2,
            Reference r2)
        {
            Document doc = view.Document;

              ReferenceArray ra = new ReferenceArray();

              ra.Append( r1 );
              ra.Append( r2 );

              Line line = Line.CreateBound( p1, p2 );

              using( Transaction t = new Transaction( doc ) )
              {
            t.Start( "Create New Dimension" );

            Dimension dim = doc.Create.NewDimension(
              view, line, ra );

            t.Commit();
              }
        }
开发者ID:jeremytammik,项目名称:the_building_coder_samples,代码行数:36,代码来源:CmdDimensionWallsIterateFaces.cs

示例4: PointStringMm

 /// <summary>
 /// Возвращает строку для трехмерной точки XYZ
 /// или вектора с координатами этой точки
 /// преобразованную из футов в миллиметры
 /// и отформатированную до двух знаков после запятой
 /// </summary>
 public static string PointStringMm( XYZ p )
 {
     return string.Format( "({0};{1};{2})",
       RealString( p.X * _foot_to_mm ),
       RealString( p.Y * _foot_to_mm ),
       RealString( p.Z * _foot_to_mm ) );
 }
开发者ID:vchekalin,项目名称:LinkedElementLocation,代码行数:13,代码来源:Command.cs

示例5: Execute

        public IExternalCommand.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            Application revit = commandData.Application;
            Document curDoc = revit.ActiveDocument;

            //配置几何曲线
            CurveArray curves = new CurveArray();
            if (null == curves)
            {
                message = "Create the curves failed.";
                return IExternalCommand.Result.Failed;
            }
            XYZ first = new XYZ(0, 0, 0);
            XYZ second = new XYZ(10, 0, 0);
            XYZ third = new XYZ(10, 10, 0);
            XYZ fourth = new XYZ(0, 10, 0);
            curves.Append(revit.Create.NewLine(ref first, ref second, true));
            curves.Append(revit.Create.NewLine(ref second, ref third, true));
            curves.Append(revit.Create.NewLine(ref third, ref fourth, true));
            curves.Append(revit.Create.NewLine(ref fourth, ref first, true));
            // 利用几何曲线,类型,标高等创建地板对象
            Floor createdFloor = curDoc.Create.NewFloor(curves, true);
            if (null == createdFloor)
            {
                message = "Create floor failed.!";
                return IExternalCommand.Result.Failed;
            }

            return IExternalCommand.Result.Succeeded;
        }
开发者ID:guchanghai,项目名称:Cut,代码行数:30,代码来源:NewFloor.cs

示例6: ParseXYZ

        /// <summary>
        /// de-serialize vector passed from UI trough options 
        /// </summary>
        private static XYZ ParseXYZ(string value)
        {
            XYZ retVal = null;

            //split string to components by removing seprator characters
            string[] separator = new string[] { ",", "(", ")", " " };
            string[] sList = new string[3] { "", "", "" };
            sList = value.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            //should remain only 3 values if everything is OK

            try
            {
                double valX = double.Parse(sList[0]); //parsing values
                double valY = double.Parse(sList[1]);
                double valZ = double.Parse(sList[2]);
                //if no exception then put it in return value
                retVal = new XYZ(valX, valY, valZ);
            }
            catch (FormatException)
            {

            }
            //return null if there is a problem or a value 
            return retVal;
        }
开发者ID:whztt07,项目名称:RevitIFC,代码行数:28,代码来源:ExportOptionsCache.cs

示例7: CreateHelix

        public void CreateHelix()
        {
            double increment = 0.1;
            double current = 0;
            XYZ startPt;
            XYZ endPt;
            XYZ zAxis = GeomUtils.kZAxis;
            XYZ origin = GeomUtils.kOrigin;
            Line line;
            Plane plane = m_revitApp.Application.Create.NewPlane(zAxis, origin);
            SketchPlane sketchPlane = SketchPlane.Create(m_revitApp.ActiveUIDocument.Document, plane);
            CurveArray curveArray = new CurveArray();

            startPt = new XYZ(Math.Cos(current), Math.Sin(current), current);
            current += increment;

            while (current <= GeomUtils.kTwoPi) {
                endPt = new XYZ(Math.Cos(current), Math.Sin(current), current);

                line = Line.CreateBound(startPt, endPt);
                curveArray.Append(line);

                startPt = endPt;
                current += increment;
            }

            m_revitApp.ActiveUIDocument.Document.Create.NewModelCurveArray(curveArray, sketchPlane);
        }
开发者ID:halad,项目名称:RevitLookup,代码行数:28,代码来源:TestGeometry.cs

示例8: NewMaxBound

 private static XYZ NewMaxBound(XYZ oldMaxBound, IList<XYZ> vertices)
 {
     XYZ maxBound = oldMaxBound;
     foreach (XYZ vertex in vertices)
         maxBound = new XYZ(Math.Max(maxBound.X, vertex.X), Math.Max(maxBound.Y, vertex.Y), Math.Max(maxBound.Z, vertex.Z));
     return maxBound;
 }
开发者ID:whztt07,项目名称:RevitIFC,代码行数:7,代码来源:BoundingBoxExporter.cs

示例9: BuildOrientation3D

 /// <summary>
 /// Build Orientation3D object for eye point and a target point 
 /// </summary>
 /// <param name="eyePoint"></param>
 /// <param name="target"></param>
 /// <returns></returns>
 protected static ViewOrientation3D BuildOrientation3D(XYZ eyePoint, XYZ target)
 {
     var globalUp = XYZ.BasisZ;
     var direction = target.Subtract(eyePoint);
     var up = direction.CrossProduct(globalUp).CrossProduct(direction);
     return new ViewOrientation3D(eyePoint, up, direction);
 }
开发者ID:heegwon,项目名称:Dynamo,代码行数:13,代码来源:View3D.cs

示例10: ImportInstance

        internal ImportInstance(string satPath, XYZ translation = null)
        {
            translation = translation ?? XYZ.Zero;

            TransactionManager.Instance.EnsureInTransaction(Document);

            var options = new SATImportOptions()
            {
                Unit = ImportUnit.Foot
            };

            var id = Document.Import(satPath, options, Document.ActiveView);
            var element = Document.GetElement(id);
            var importInstance = element as Autodesk.Revit.DB.ImportInstance;

            if (importInstance == null)
            {
                throw new Exception("Could not obtain ImportInstance from imported Element");
            }

            InternalSetImportInstance(importInstance);
            InternalUnpinAndTranslateImportInstance(translation);

            this.Path = satPath;

            TransactionManager.Instance.TransactionTaskDone();
        }
开发者ID:algobasket,项目名称:Dynamo,代码行数:27,代码来源:ImportInstance.cs

示例11: nextMove

 private void nextMove()
 {
     lock (this) {
         if (this.endPosition != null && !this.position.Equals (this.endPosition)) {
             double realSpeed = this.speed / 1000.0 * moving.Interval;
             double distance = getDistance (endPosition, position);
             double u = realSpeed / (distance - realSpeed);
             XYZ<double> nextPosition = new XYZ<double> (0, 0, 0);
             nextPosition.x = (position.x + u * endPosition.x) / (1 + u);
             nextPosition.y = (position.y + u * endPosition.y) / (1 + u);
             nextPosition.z = (position.z + u * endPosition.z) / (1 + u);
             this.position = nextPosition;
             if (realSpeed >= distance)
                 this.position = this.endPosition;
             this.minecraft.SendPacket (new object[] {
                 (byte)PacketID.PlayerPosition,
                 this.position.x,
                 this.position.y,
                 this.position.y + this.height,
                 this.position.z,
                 this.onGround
             }
             );
             this.minecraft.map.updateMap ();
         }
     }
 }
开发者ID:zaitsevyan,项目名称:MinecraftBrainBot,代码行数:27,代码来源:Player.cs

示例12: apply

        public void apply()
        {
            if (m_particleA.isFree() || m_particleB.isFree())
            {

                XYZ a2b = m_particleA.getPosition().Subtract(m_particleB.getPosition());

                double a2bDistance = Math.Abs(Math.Sqrt(a2b.X * a2b.X + a2b.Y * a2b.Y + a2b.Z * a2b.Z)); // MDJ vector norm http://mathworld.wolfram.com/VectorNorm.html != a2b.Normalize();

                if (a2bDistance == 0)
                {
                    a2b = new XYZ(0, 0, 0);
                }
                else
                {
                    a2b = a2b / a2bDistance;
                }

                double springForce = -(a2bDistance - m_restLength) * m_springConstant;

                XYZ Va2b = m_particleA.getVelocity() - m_particleB.getVelocity();

                double dampingForce = -m_Damping * (a2b.DotProduct(Va2b));

                // forceB is same as forceA in opposite direction
                double r = springForce + dampingForce;

                a2b = a2b * r;

                if (m_particleA.isFree())
                    m_particleA.addForce(a2b);
                if (m_particleB.isFree())
                    m_particleB.addForce(-a2b);
            }
        }
开发者ID:Dewb,项目名称:Dynamo,代码行数:35,代码来源:dynParticleSpring.cs

示例13: Evaluate

        public override FScheme.Value Evaluate(FSharpList<FScheme.Value> args)
        {
            var t = (Transform)((FScheme.Value.Container)args[0]).Item;
            double width = ((FScheme.Value.Number)args[1]).Item;
            double height = ((FScheme.Value.Number)args[2]).Item;

            //ccw from upper right
            var p0 = new XYZ(width / 2, height / 2, 0);
            var p3 = new XYZ(-width / 2, height / 2, 0);
            var p2 = new XYZ(-width / 2, -height / 2, 0);
            var p1 = new XYZ(width / 2, -height / 2, 0);

            p0 = t.OfPoint(p0);
            p1 = t.OfPoint(p1);
            p2 = t.OfPoint(p2);
            p3 = t.OfPoint(p3);

            var l1 = dynRevitSettings.Doc.Application.Application.Create.NewLineBound(p0, p1);
            var l2 = dynRevitSettings.Doc.Application.Application.Create.NewLineBound(p1, p2);
            var l3 = dynRevitSettings.Doc.Application.Application.Create.NewLineBound(p2, p3);
            var l4 = dynRevitSettings.Doc.Application.Application.Create.NewLineBound(p3, p0);

            var cl = new Autodesk.Revit.DB.CurveLoop();
            cl.Append(l1);
            cl.Append(l2);
            cl.Append(l3);
            cl.Append(l4);

            return FScheme.Value.NewContainer(cl);
        }
开发者ID:riteshchandawar,项目名称:Dynamo,代码行数:30,代码来源:Rectangle.cs

示例14: CreateAxis

        /// <summary>
        /// Creates IfcAxis2Placement3D object.
        /// </summary>
        /// <param name="file">
        /// The IFC file.
        /// </param>
        /// <param name="origin">
        /// The origin.
        /// </param>
        /// <param name="zDirection">
        /// The Z direction.
        /// </param>
        /// <param name="xDirection">
        /// The X direction.
        /// </param>
        /// <returns>
        /// The handle.
        /// </returns>
        public static IFCAnyHandle CreateAxis(IFCFile file, XYZ origin, XYZ zDirection, XYZ xDirection)
        {
            IFCAnyHandle directionOpt = IFCAnyHandle.Create();
            IFCAnyHandle refOpt = IFCAnyHandle.Create();
            IFCAnyHandle location = IFCAnyHandle.Create();

            if (origin != null)
            {
                IList<double> measure = new List<double>();
                measure.Add(origin.X); measure.Add(origin.Y); measure.Add(origin.Z);
                location = CreateCartesianPoint(file, measure);
            }
            else
            {
                location = ExporterIFCUtils.GetGlobal3DOriginHandle();
            }

            bool exportzDirectionAndxDirection = (zDirection != null && xDirection != null && (!MathUtil.IsAlmostEqual(zDirection[2], 1.0) || !MathUtil.IsAlmostEqual(xDirection[0], 1.0)));

            if (exportzDirectionAndxDirection)
            {
                IList<double> axisPts = new List<double>();
                axisPts.Add(zDirection.X); axisPts.Add(zDirection.Y); axisPts.Add(zDirection.Z);
                directionOpt = CreateDirection(file, axisPts);
            }

            if (exportzDirectionAndxDirection)
            {
                IList<double> axisPts = new List<double>();
                axisPts.Add(xDirection.X); axisPts.Add(xDirection.Y); axisPts.Add(xDirection.Z);
                refOpt = CreateDirection(file, axisPts);
            }

            return file.CreateAxis2Placement3D(location, directionOpt, refOpt);
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:53,代码来源:ExporterUtil.cs

示例15: GetClosestFace

        public static Tuple<Face, Reference> GetClosestFace(Document document, XYZ p)
        {
            Face resultFace = null;
            Reference resultReference = null;

            double min_distance = double.MaxValue;
            FilteredElementCollector collector = new FilteredElementCollector(document);
            var walls = collector.OfClass(typeof (Wall));
            foreach (Wall wall in walls)
            {
                IList<Reference> sideFaces =
                    HostObjectUtils.GetSideFaces(wall, ShellLayerType.Interior);
                // access the side face
                Face face = document.GetElement(sideFaces[0]).GetGeometryObjectFromReference(sideFaces[0]) as Face;
                var intersection = face.Project(p);

                if (intersection != null)
                {
                    if (intersection.Distance < min_distance)
                    {
                        resultFace = face;
                        resultReference = sideFaces[0];
                        min_distance = intersection.Distance;
                    }
                }
            }
            //resultFace.
            return new Tuple<Face,Reference>( resultFace, resultReference);
        }
开发者ID:KonbOgonb,项目名称:revit-psElectro-bridge,代码行数:29,代码来源:FindWallHelper.cs


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