C# Cad 拉伸 关键 GetStretchPoints MoveStretchPointsAt

  /// <summary>
        /// 拉伸
        /// </summary>
        [CommandMethod("ALS")]
        public void Tensile()
        {
            var ids = Editor.Selection($"\n选择图形");
            ids = ids.Deletes();
            if (ids == null || !ids.Any()) return;

            var beginPoint = Editor.Point("\n指定绘图起点");
            if (beginPoint.IsNull()) return;

            var entitys = ids.QOpenForRead<Entity>();
            // Surface surface = new Autodesk.AutoCAD.DatabaseServices.Surface();  

            var ent1 = entitys[0];
            var ent2 = entitys[1];
            var newEntitys = new List<Entity>();
            newEntitys.Add(ent2);

            //var ddd = ent1.JoinEntities(newEntitys.ToArray()); 
            foreach (var item in entitys)
            {
                IntegerCollection dddd = new IntegerCollection();
                var stretchPoints = new Point3dCollection();
                item.GetStretchPoints(stretchPoints);

                for (int i = 0; i < stretchPoints.Count; i++)
                {
                    var p = stretchPoints[i];
                    if (p.Coincide(beginPoint, 0.01))
                    {
                        dddd.Add(i);
                    }
                }
                if (dddd.Count > 0)
                {
                    item.ObjectId.QOpenForWrite<Entity>(c =>
                    {
                        c.MoveStretchPointsAt(dddd, new Vector3d(100, 0, 0));
                    });
                }
            }
        }

出处 原创 https://www.cnblogs.com/shangdishijiao/p/15686414.html

posted @ 2021-12-14 09:50  上帝视角  阅读(516)  评论(0编辑  收藏  举报