C# Cad 拉伸 关键 GetStretchPoints MoveStretchPointsAt


  /// 
        /// 拉伸
        /// 
        [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();
            // Surface surface = new Autodesk.AutoCAD.DatabaseServices.Surface();  

            var ent1 = entitys[0];
            var ent2 = entitys[1];
            var newEntitys = new List();
            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(c =>
                    {
                        c.MoveStretchPointsAt(dddd, new Vector3d(100, 0, 0));
                    });
                }
            }
        }