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


C# Vector3d.Negate方法代码示例

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


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

示例1: ChangeBasePoint

        public void ChangeBasePoint()
        {
            // Вставка блока
            var blRefId = AcadLib.Blocks.BlockInsert.Insert(OldName);

            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;

            // Выбор новой базовой точки
            var ptInput = ed.GetPointWCS("\nВыбор новой базовой точки блока:");

            using (var t = db.TransactionManager.StartTransaction())
            {
                var blRef = blRefId.GetObject(OpenMode.ForRead, false, true) as BlockReference;
                var ptNewBase = ptInput- blRef.Position;
                // Вектор смещения базовой точки вхождения блока
                var ptBaseInBtr = ptNewBase.TransformBy(blRef.BlockTransform);
                var vec = new Vector3d(ptBaseInBtr.ToArray());
                // Вектор смещения объектов в блоке
                var vecBtr = vec.Negate();

                // Перемещение всех объектов блока на заданные вектор
                var matInBtr = Matrix3d.Displacement(vecBtr);
                var btr = IdBtr.GetObject(OpenMode.ForRead) as BlockTableRecord;
                foreach (var idEnt in btr)
                {
                    var ent = idEnt.GetObject(OpenMode.ForWrite, false, true) as Entity;
                    ent.TransformBy(matInBtr);
                }

                // Перемещение всех вхождений блока
                MatChangeBasePoint = Matrix3d.Displacement(vec);
                var refs = btr.GetBlockReferenceIds(true, false);
                foreach (ObjectId itemBlRefId in refs)
                {
                    var itemBlRef = itemBlRefId.GetObject( OpenMode.ForWrite, false, true) as BlockReference;
                    itemBlRef.TransformBy(MatChangeBasePoint);
                }

                if (IsDynamic)
                {
                    btr.UpdateAnonymousBlocks();
                    var anonyms = btr.GetAnonymousBlockIds();
                    foreach (ObjectId idAnonymBtr in anonyms)
                    {
                        var anonymBtr = idAnonymBtr.GetObject(OpenMode.ForRead) as BlockTableRecord;
                        var refsAnonym = anonymBtr.GetBlockReferenceIds(true, false);
                        foreach (ObjectId idBlRefAnonym in refsAnonym)
                        {
                            var blRefAnonym = idBlRefAnonym.GetObject( OpenMode.ForWrite, false, true) as BlockReference;
                            blRefAnonym.TransformBy(MatChangeBasePoint);
                        }
                    }
                }
                t.Commit();
            }
            IsChangeBasePoint = true;
        }
开发者ID:vildar82,项目名称:RedefineBlockInFolder,代码行数:59,代码来源:RedefineBlock.cs

示例2: ProjectPolyline

 /// <summary>
 /// Creates a new Polyline that is the result of projecting the polyline parallel to 'direction' onto 'plane' and returns it.
 /// </summary>
 /// <param name="pline">The polyline (any type) to project.</param>
 /// <param name="plane">The plane onto which the curve is to be projected.</param>
 /// <param name="direction">Direction (in WCS coordinates) of the projection.</param>
 /// <returns>The projected Polyline.</returns>
 internal static Polyline ProjectPolyline(Curve pline, Plane plane, Vector3d direction)
 {
     if (!(pline is Polyline) && !(pline is Polyline2d) && !(pline is Polyline3d))
         return null;
     plane = new Plane(Point3d.Origin.OrthoProject(plane), direction);
     using (DBObjectCollection oldCol = new DBObjectCollection())
     using (DBObjectCollection newCol = new DBObjectCollection())
     {
         pline.Explode(oldCol);
         foreach (DBObject obj in oldCol)
         {
             Curve crv = obj as Curve;
             if (crv != null)
             {
                 Curve flat = crv.GetProjectedCurve(plane, direction);
                 newCol.Add(flat);
             }
             obj.Dispose();
         }
         PolylineSegmentCollection psc = new PolylineSegmentCollection();
         for (int i = 0; i < newCol.Count; i++)
         {
             if (newCol[i] is Ellipse)
             {
                 psc.AddRange(new PolylineSegmentCollection((Ellipse)newCol[i]));
                 continue;
             }
             Curve crv = (Curve)newCol[i];
             Point3d start = crv.StartPoint;
             Point3d end = crv.EndPoint;
             double bulge = 0.0;
             if (crv is Arc)
             {
                 Arc arc = (Arc)crv;
                 double angle = arc.Center.GetVectorTo(start).GetAngleTo(arc.Center.GetVectorTo(end), arc.Normal);
                 bulge = Math.Tan(angle / 4.0);
             }
             psc.Add(new PolylineSegment(start.Convert2d(plane), end.Convert2d(plane), bulge));
         }
         foreach (DBObject o in newCol) o.Dispose();
         Polyline projectedPline = psc.Join(new Tolerance(1e-9, 1e-9))[0].ToPolyline();
         projectedPline.Normal = direction;
         projectedPline.Elevation =
             plane.PointOnPlane.TransformBy(Matrix3d.WorldToPlane(new Plane(Point3d.Origin, direction))).Z;
         if (!pline.StartPoint.Project(plane, direction).IsEqualTo(projectedPline.StartPoint, new Tolerance(1e-9, 1e-9)))
         {
             projectedPline.Normal = direction = direction.Negate();
             projectedPline.Elevation =
                 plane.PointOnPlane.TransformBy(Matrix3d.WorldToPlane(new Plane(Point3d.Origin, direction))).Z;
         }
         return projectedPline;
     }
 }
开发者ID:vildar82,项目名称:AcadLib,代码行数:60,代码来源:GeomExt.cs


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