<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Streatch Command code in C#.net to streatch multiple segements of closed polygon in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/streatch-command-code-in-c-net-to-streatch-multiple-segements-of/m-p/12485933#M6012</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a PolylineStretchJig example (the 'indexes' parameter contains the polyline indexes to stretch).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;class PolylineStretchJig : EntityJig
{
    Polyline _pline;
    Plane _plane;
    Dictionary&amp;lt;int, Point2d&amp;gt; _vertices;
    Point3d _basePoint, _dragPoint;

    public PolylineStretchJig(Polyline pline, Point3d basePoint, List&amp;lt;int&amp;gt; indexes) : base(pline)
    {
        _pline = pline;
        _plane = new Plane(Point3d.Origin, pline.Normal);
        _vertices = indexes.ToDictionary(i =&amp;gt; i, i =&amp;gt; pline.GetPoint2dAt(i));
        _basePoint = basePoint;
    }

    protected override SamplerStatus Sampler(JigPrompts prompts)
    {
        var jppo = new JigPromptPointOptions()
        {
            Message = "\nSpecify second point: ",
            BasePoint = _basePoint,
            UseBasePoint = true
        };
        var result = prompts.AcquirePoint(jppo);
        if (result.Value.IsEqualTo(_dragPoint))
            return SamplerStatus.NoChange;
        _dragPoint = result.Value;
        return SamplerStatus.OK;
    }

    protected override bool Update()
    {
        Vector2d vector = (_dragPoint - _basePoint).Convert2d(_plane);
        foreach (var vertex in _vertices)
        {
            _pline.SetPointAt(vertex.Key, vertex.Value + vector);
        }
        return true;
    }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A testing command (should work as expected when View == Top).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;public void Test()
{
    var doc = Application.DocumentManager.MdiActiveDocument;
    var db = doc.Database;
    var ed = doc.Editor;

    var promptEntityOptions = new PromptEntityOptions("\nSelect Polyline to strech: ");
    promptEntityOptions.SetRejectMessage("\nSelected object is not a polyline.");
    promptEntityOptions.AddAllowedClass(typeof(Polyline), true);
    var promptEntityResult = ed.GetEntity(promptEntityOptions);
    if (promptEntityResult.Status != PromptStatus.OK)
        return;

    var promptPointResult = ed.GetPoint("\nSelect vertices to stretch: ");
    if (promptPointResult.Status != PromptStatus.OK)
        return;

    var promptCornerResult = ed.GetCorner("\nSpecify the opposite corner", promptPointResult.Value);
    if (promptCornerResult.Status != PromptStatus.OK)
        return;

    using (var tr = db.TransactionManager.StartTransaction())
    {
        var ucs = ed.CurrentUserCoordinateSystem;
        var extents = new Extents3d();
        extents.AddPoint(promptPointResult.Value);
        extents.AddPoint(promptCornerResult.Value);
        extents.TransformBy(ucs);

        var pline = (Polyline)tr.GetObject(promptEntityResult.ObjectId, OpenMode.ForWrite);
        var indexes = new List&amp;lt;int&amp;gt;();

        bool IsPointInside(Point3d pt) =&amp;gt;
            extents.MinPoint.X &amp;lt;= pt.X &amp;amp;&amp;amp;
            extents.MinPoint.Y &amp;lt;= pt.Y &amp;amp;&amp;amp;
            extents.MinPoint.Z &amp;lt;= pt.Z &amp;amp;&amp;amp;
            pt.X &amp;lt;= extents.MaxPoint.X &amp;amp;&amp;amp;
            pt.Y &amp;lt;= extents.MaxPoint.Y &amp;amp;&amp;amp;
            pt.Z &amp;lt;= extents.MaxPoint.Z;
        for (int i = 0; i &amp;lt; pline.NumberOfVertices; i++)
        {
            if (IsPointInside(pline.GetPoint3dAt(i)))
                indexes.Add(i);
        }
        if (indexes.Count == 0)
            return;

        promptPointResult = ed.GetPoint("\nSpecify base point: ");
        if (promptPointResult.Status != PromptStatus.OK)
            return;
        var basePoint = promptPointResult.Value.TransformBy(ucs);

        var jig = new PolylineStretchJig(pline, basePoint, indexes);
        var promptResult = ed.Drag(jig);
        if (promptResult.Status != PromptStatus.OK)
            return;
        tr.Commit();
    }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 09 Jan 2024 14:08:42 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2024-01-09T14:08:42Z</dc:date>
    <item>
      <title>Streatch Command code in C#.net to streatch multiple segements of closed polygon</title>
      <link>https://forums.autodesk.com/t5/net-forum/streatch-command-code-in-c-net-to-streatch-multiple-segements-of/m-p/12485208#M6009</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I want to streatch multiple segments of closed polygon using C#.net as we can streatch with AutoCAD command.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 08:04:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/streatch-command-code-in-c-net-to-streatch-multiple-segements-of/m-p/12485208#M6009</guid>
      <dc:creator>kbharathy9</dc:creator>
      <dc:date>2024-01-09T08:04:01Z</dc:date>
    </item>
    <item>
      <title>Re: Streatch Command code in C#.net to streatch multiple segements of closed polygon</title>
      <link>https://forums.autodesk.com/t5/net-forum/streatch-command-code-in-c-net-to-streatch-multiple-segements-of/m-p/12485566#M6010</link>
      <description>&lt;P&gt;I will check and let you know&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 11:14:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/streatch-command-code-in-c-net-to-streatch-multiple-segements-of/m-p/12485566#M6010</guid>
      <dc:creator>b_karunakar75</dc:creator>
      <dc:date>2024-01-09T11:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: Streatch Command code in C#.net to streatch multiple segements of closed polygon</title>
      <link>https://forums.autodesk.com/t5/net-forum/streatch-command-code-in-c-net-to-streatch-multiple-segements-of/m-p/12485569#M6011</link>
      <description>&lt;P&gt;Please condiser Jig while streatching the feature.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 11:15:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/streatch-command-code-in-c-net-to-streatch-multiple-segements-of/m-p/12485569#M6011</guid>
      <dc:creator>kbharathy9</dc:creator>
      <dc:date>2024-01-09T11:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: Streatch Command code in C#.net to streatch multiple segements of closed polygon</title>
      <link>https://forums.autodesk.com/t5/net-forum/streatch-command-code-in-c-net-to-streatch-multiple-segements-of/m-p/12485933#M6012</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a PolylineStretchJig example (the 'indexes' parameter contains the polyline indexes to stretch).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;class PolylineStretchJig : EntityJig
{
    Polyline _pline;
    Plane _plane;
    Dictionary&amp;lt;int, Point2d&amp;gt; _vertices;
    Point3d _basePoint, _dragPoint;

    public PolylineStretchJig(Polyline pline, Point3d basePoint, List&amp;lt;int&amp;gt; indexes) : base(pline)
    {
        _pline = pline;
        _plane = new Plane(Point3d.Origin, pline.Normal);
        _vertices = indexes.ToDictionary(i =&amp;gt; i, i =&amp;gt; pline.GetPoint2dAt(i));
        _basePoint = basePoint;
    }

    protected override SamplerStatus Sampler(JigPrompts prompts)
    {
        var jppo = new JigPromptPointOptions()
        {
            Message = "\nSpecify second point: ",
            BasePoint = _basePoint,
            UseBasePoint = true
        };
        var result = prompts.AcquirePoint(jppo);
        if (result.Value.IsEqualTo(_dragPoint))
            return SamplerStatus.NoChange;
        _dragPoint = result.Value;
        return SamplerStatus.OK;
    }

    protected override bool Update()
    {
        Vector2d vector = (_dragPoint - _basePoint).Convert2d(_plane);
        foreach (var vertex in _vertices)
        {
            _pline.SetPointAt(vertex.Key, vertex.Value + vector);
        }
        return true;
    }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A testing command (should work as expected when View == Top).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;public void Test()
{
    var doc = Application.DocumentManager.MdiActiveDocument;
    var db = doc.Database;
    var ed = doc.Editor;

    var promptEntityOptions = new PromptEntityOptions("\nSelect Polyline to strech: ");
    promptEntityOptions.SetRejectMessage("\nSelected object is not a polyline.");
    promptEntityOptions.AddAllowedClass(typeof(Polyline), true);
    var promptEntityResult = ed.GetEntity(promptEntityOptions);
    if (promptEntityResult.Status != PromptStatus.OK)
        return;

    var promptPointResult = ed.GetPoint("\nSelect vertices to stretch: ");
    if (promptPointResult.Status != PromptStatus.OK)
        return;

    var promptCornerResult = ed.GetCorner("\nSpecify the opposite corner", promptPointResult.Value);
    if (promptCornerResult.Status != PromptStatus.OK)
        return;

    using (var tr = db.TransactionManager.StartTransaction())
    {
        var ucs = ed.CurrentUserCoordinateSystem;
        var extents = new Extents3d();
        extents.AddPoint(promptPointResult.Value);
        extents.AddPoint(promptCornerResult.Value);
        extents.TransformBy(ucs);

        var pline = (Polyline)tr.GetObject(promptEntityResult.ObjectId, OpenMode.ForWrite);
        var indexes = new List&amp;lt;int&amp;gt;();

        bool IsPointInside(Point3d pt) =&amp;gt;
            extents.MinPoint.X &amp;lt;= pt.X &amp;amp;&amp;amp;
            extents.MinPoint.Y &amp;lt;= pt.Y &amp;amp;&amp;amp;
            extents.MinPoint.Z &amp;lt;= pt.Z &amp;amp;&amp;amp;
            pt.X &amp;lt;= extents.MaxPoint.X &amp;amp;&amp;amp;
            pt.Y &amp;lt;= extents.MaxPoint.Y &amp;amp;&amp;amp;
            pt.Z &amp;lt;= extents.MaxPoint.Z;
        for (int i = 0; i &amp;lt; pline.NumberOfVertices; i++)
        {
            if (IsPointInside(pline.GetPoint3dAt(i)))
                indexes.Add(i);
        }
        if (indexes.Count == 0)
            return;

        promptPointResult = ed.GetPoint("\nSpecify base point: ");
        if (promptPointResult.Status != PromptStatus.OK)
            return;
        var basePoint = promptPointResult.Value.TransformBy(ucs);

        var jig = new PolylineStretchJig(pline, basePoint, indexes);
        var promptResult = ed.Drag(jig);
        if (promptResult.Status != PromptStatus.OK)
            return;
        tr.Commit();
    }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 14:08:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/streatch-command-code-in-c-net-to-streatch-multiple-segements-of/m-p/12485933#M6012</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2024-01-09T14:08:42Z</dc:date>
    </item>
    <item>
      <title>Re: Streatch Command code in C#.net to streatch multiple segements of closed polygon</title>
      <link>https://forums.autodesk.com/t5/net-forum/streatch-command-code-in-c-net-to-streatch-multiple-segements-of/m-p/12487101#M6013</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;, aside from performance reasons with a large number of vertices, I can think of several other reasons why I would prefer using &lt;A href="https://help.autodesk.com/view/OARX/2023/ENU/?guid=OARX-ManagedRefGuide-Autodesk_AutoCAD_DatabaseServices_Entity_MoveStretchPointsAt_IntegerCollection_Vector3d" target="_blank" rel="noopener"&gt;Entity.MoveStretchPointsAt()&lt;/A&gt; verses manually moving each vertex as per your example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Those other reasons are related to hatching: associative dimensions; and more generally, involvement in any kind of associative network where other objects have a dependence on the polyline.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, with Entity.MoveStretchPointsAt(), the solution would stretch any Entity, rather than just polylines.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here is your example, hastily refactored to work with any Entity (untested):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using System;
using System.Linq;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;

/// &amp;lt;summary&amp;gt;
/// Gile's example, refactored to stretch
/// any type of Entity that can be stretched.
/// &amp;lt;/summary&amp;gt;

namespace Examples
{

   class EntityStretchJig : EntityJig
   {
      Entity entity;
      IntegerCollection indices;
      Point3d basePoint;
      Point3d lastPoint;
      Point3d samplePoint;

      public EntityStretchJig(Entity entity, Point3d basePoint, IntegerCollection indexes) 
         : base(entity)
      {
         if(entity == null)
            throw new ArgumentNullException(nameof(entity));
         if(!entity.IsWriteEnabled)
            throw new Autodesk.AutoCAD.Runtime.Exception(ErrorStatus.NotOpenForWrite);
         Point3dCollection stretchPoints = new Point3dCollection();
         entity.GetStretchPoints(stretchPoints);
         if(stretchPoints.Count == 0)
            throw new ArgumentException("Can't stretch the given entity");
         if(indices.Count &amp;gt; stretchPoints.Count)
            throw new ArgumentException("Invalid index array");
         if(indices.Cast&amp;lt;int&amp;gt;().Max() &amp;gt;= stretchPoints.Count)
            throw new IndexOutOfRangeException();
         this.entity = entity;
         this.indices = indexes;
         this.basePoint = basePoint;
         this.lastPoint = basePoint;
      }

      protected override SamplerStatus Sampler(JigPrompts prompts)
      {
         var jppo = new JigPromptPointOptions()
         {
            Message = "\nSpecify second point: ",
            BasePoint = basePoint,
            UseBasePoint = true
         };
         var result = prompts.AcquirePoint(jppo);
         if(result.Status != PromptStatus.OK)
            return SamplerStatus.Cancel;
         if(result.Value.IsEqualTo(lastPoint))
            return SamplerStatus.NoChange;
         samplePoint = result.Value;
         return SamplerStatus.OK;
      }

      protected override bool Update()
      {
         entity.MoveStretchPointsAt(indices, samplePoint - lastPoint);
         lastPoint = samplePoint;
         return true;
      }
   }


   public static class TestCase
   {
      [CommandMethod("MYSTRETCH")]
      public static void Test()
      {
         var doc = Application.DocumentManager.MdiActiveDocument;
         var db = doc.Database;
         var ed = doc.Editor;

         var peo = new PromptEntityOptions("\nSelect entity to strech: ");
         var per = ed.GetEntity(peo);
         if(per.Status != PromptStatus.OK)
            return;

         var ppr = ed.GetPoint("\nSelect vertices to stretch: ");
         if(ppr.Status != PromptStatus.OK)
            return;

         var pcr = ed.GetCorner("\nSpecify the opposite corner", ppr.Value);
         if(pcr.Status != PromptStatus.OK)
            return;

         var ucs = ed.CurrentUserCoordinateSystem;
         var extents = new Extents3d();
         extents.AddPoint(ppr.Value);
         extents.AddPoint(pcr.Value);
         extents.TransformBy(ucs);
         Point3dCollection stretchPoints = new Point3dCollection();
         using(var tr = db.TransactionManager.StartTransaction())
         {
            var entity = (Entity)tr.GetObject(per.ObjectId, OpenMode.ForRead);
            entity.GetStretchPoints(stretchPoints);
            tr.Commit();
         }

         /// Let's try to avoid user interatiion inside an
         /// active transaction, to avoid undesired side-
         /// effects of aborting the transaction (e.g.,
         /// undoing transparent pans/zooms, etc.).
        
         if(stretchPoints.Count == 0)
         {
            ed.WriteMessage("\nCan't stretch selected entity.");
            return;
         }
         IntegerCollection list = new IntegerCollection(stretchPoints.Count);
         for(int i = 0; i &amp;lt; stretchPoints.Count; i++)
         {
            if(extents.Contains(stretchPoints[i]))
               list.Add(i);
         }
         if(list.Count == 0)
            return;
         ppr = ed.GetPoint("\nSpecify base point: ");
         if(ppr.Status != PromptStatus.OK)
            return;
         var basePoint = ppr.Value.TransformBy(ucs);
         using(var tr = db.TransactionManager.StartTransaction())
         {
            var entity = (Entity)tr.GetObject(per.ObjectId, OpenMode.ForWrite);
            var jig = new EntityStretchJig(entity, basePoint, list);
            var promptResult = ed.Drag(jig);
            if(promptResult.Status != PromptStatus.OK)
               return;
            tr.Commit();
         }
      }
   }

   public static class NoCopyAndPasteExtensions
   {
      public static bool Contains(this Extents3d extents, Point3d pt)
      {
         Point3d min = extents.MinPoint;
         Point3d max = extents.MaxPoint;
         return min.X &amp;lt;= pt.X &amp;amp;&amp;amp; min.Y &amp;lt;= pt.Y &amp;amp;&amp;amp; min.Z &amp;lt;= pt.Z 
            &amp;amp;&amp;amp; pt.X &amp;lt;= max.X &amp;amp;&amp;amp; pt.Y &amp;lt;= max.Y &amp;amp;&amp;amp; pt.Z &amp;lt;= max.Z;
      }
   }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 03:43:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/streatch-command-code-in-c-net-to-streatch-multiple-segements-of/m-p/12487101#M6013</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2024-01-10T03:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: Streatch Command code in C#.net to streatch multiple segements of closed polygon</title>
      <link>https://forums.autodesk.com/t5/net-forum/streatch-command-code-in-c-net-to-streatch-multiple-segements-of/m-p/12487674#M6014</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4476837"&gt;@ActivistInvestor&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;I didn't know this method.&lt;/P&gt;
&lt;P&gt;Thanks for make me (us) discover it and for the code sample.&lt;/P&gt;
&lt;P&gt;There's a little mistake (typo?) in the EntityStretchJig constructor: 'indices' instead of 'indexes' lines 36 and 38.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 07:20:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/streatch-command-code-in-c-net-to-streatch-multiple-segements-of/m-p/12487674#M6014</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2024-01-10T07:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: Streatch Command code in C#.net to streatch multiple segements of closed polygon</title>
      <link>https://forums.autodesk.com/t5/net-forum/streatch-command-code-in-c-net-to-streatch-multiple-segements-of/m-p/12487727#M6015</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;, thanks for pointing out that bug. The last thing I did before copying it was to move all the assignments to the bottom of the constructor, not realizing that was a mistake.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;using System;
using System.Linq;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;

/// &amp;lt;summary&amp;gt;
/// Gile's example, refactored to stretch
/// any type of Entity that can be stretched.
/// &amp;lt;/summary&amp;gt;

namespace Examples
{

   class EntityStretchJig : EntityJig
   {
      Entity entity;
      IntegerCollection indices;
      Point3d basePoint;
      Point3d lastPoint;
      Point3d samplePoint;

      public EntityStretchJig(Entity entity, Point3d basePoint, IntegerCollection indexes) 
         : base(entity)
      {
         if(entity == null)
            throw new ArgumentNullException(nameof(entity));
         if(indexes == null)
            throw new ArgumentNullException(nameof(indexes));
         if(!entity.IsWriteEnabled)
            throw new Autodesk.AutoCAD.Runtime.Exception(ErrorStatus.NotOpenForWrite);
         Point3dCollection stretchPoints = new Point3dCollection();
         entity.GetStretchPoints(stretchPoints);
         if(stretchPoints.Count == 0)
            throw new ArgumentException("Can't stretch the given entity");
         if(indexes.Count &amp;gt; stretchPoints.Count)
            throw new ArgumentException("Invalid index array");
         if(indexes.Cast&amp;lt;int&amp;gt;().Max() &amp;gt;= stretchPoints.Count)
            throw new IndexOutOfRangeException();
         this.indices = indexes;
         this.entity = entity;
         this.basePoint = basePoint;
         this.lastPoint = basePoint;
      }

      protected override SamplerStatus Sampler(JigPrompts prompts)
      {
         var jppo = new JigPromptPointOptions()
         {
            Message = "\nSpecify second point: ",
            BasePoint = basePoint,
            UseBasePoint = true
         };
         var result = prompts.AcquirePoint(jppo);
         if(result.Status != PromptStatus.OK)
            return SamplerStatus.Cancel;
         if(result.Value.IsEqualTo(lastPoint))
            return SamplerStatus.NoChange;
         samplePoint = result.Value;
         return SamplerStatus.OK;
      }

      protected override bool Update()
      {
         entity.MoveStretchPointsAt(indices, samplePoint - lastPoint);
         lastPoint = samplePoint;
         return true;
      }
   }


   public static class TestCase
   {
      [CommandMethod("MYSTRETCH")]
      public static void Test()
      {
         var doc = Application.DocumentManager.MdiActiveDocument;
         var db = doc.Database;
         var ed = doc.Editor;

         var peo = new PromptEntityOptions("\nSelect entity to strech: ");
         var per = ed.GetEntity(peo);
         if(per.Status != PromptStatus.OK)
            return;

         var ppr = ed.GetPoint("\nSelect vertices to stretch: ");
         if(ppr.Status != PromptStatus.OK)
            return;

         var pcr = ed.GetCorner("\nSpecify the opposite corner", ppr.Value);
         if(pcr.Status != PromptStatus.OK)
            return;

         var ucs = ed.CurrentUserCoordinateSystem;
         var extents = new Extents3d();
         extents.AddPoint(ppr.Value);
         extents.AddPoint(pcr.Value);
         extents.TransformBy(ucs);
         Point3dCollection stretchPoints = new Point3dCollection();
         using(var tr = db.TransactionManager.StartTransaction())
         {
            var entity = (Entity)tr.GetObject(per.ObjectId, OpenMode.ForRead);
            entity.GetStretchPoints(stretchPoints);
            tr.Commit();
         }

         /// Try to avoid user interatiion inside an
         /// active transaction, to avoid undesired side-
         /// effects of aborting the transaction (e.g.,
         /// undoing transparent pans/zooms, etc.).
        
         if(stretchPoints.Count == 0)
         {
            ed.WriteMessage("\nCan't stretch selected entity.");
            return;
         }
         IntegerCollection list = new IntegerCollection(stretchPoints.Count);
         for(int i = 0; i &amp;lt; stretchPoints.Count; i++)
         {
            if(extents.Contains(stretchPoints[i]))
               list.Add(i);
         }
         if(list.Count == 0)
            return;
         ppr = ed.GetPoint("\nSpecify base point: ");
         if(ppr.Status != PromptStatus.OK)
            return;
         var basePoint = ppr.Value.TransformBy(ucs);
         using(var tr = db.TransactionManager.StartTransaction())
         {
            var entity = (Entity)tr.GetObject(per.ObjectId, OpenMode.ForWrite);
            var jig = new EntityStretchJig(entity, basePoint, list);
            var promptResult = ed.Drag(jig);
            if(promptResult.Status != PromptStatus.OK)
               return;
            tr.Commit();
         }
      }
   }

   public static class NoCopyAndPasteExtensions
   {
      public static bool Contains(this Extents3d extents, Point3d pt)
      {
         Point3d min = extents.MinPoint;
         Point3d max = extents.MaxPoint;
         return min.X &amp;lt;= pt.X &amp;amp;&amp;amp; min.Y &amp;lt;= pt.Y &amp;amp;&amp;amp; min.Z &amp;lt;= pt.Z 
            &amp;amp;&amp;amp; pt.X &amp;lt;= max.X &amp;amp;&amp;amp; pt.Y &amp;lt;= max.Y &amp;amp;&amp;amp; pt.Z &amp;lt;= max.Z;
      }
   }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 07:58:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/streatch-command-code-in-c-net-to-streatch-multiple-segements-of/m-p/12487727#M6015</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2024-01-10T07:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: Streatch Command code in C#.net to streatch multiple segements of closed polygon</title>
      <link>https://forums.autodesk.com/t5/net-forum/streatch-command-code-in-c-net-to-streatch-multiple-segements-of/m-p/12487882#M6016</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;. The code you shared is working fine for me.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 09:21:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/streatch-command-code-in-c-net-to-streatch-multiple-segements-of/m-p/12487882#M6016</guid>
      <dc:creator>kbharathy9</dc:creator>
      <dc:date>2024-01-10T09:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: Streatch Command code in C#.net to streatch multiple segements of closed polygon</title>
      <link>https://forums.autodesk.com/t5/net-forum/streatch-command-code-in-c-net-to-streatch-multiple-segements-of/m-p/12487902#M6017</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13739097"&gt;@kbharathy9&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;The code shared by &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4476837"&gt;@ActivistInvestor&lt;/a&gt; (message #7) is more robust. You should use it instead.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 09:37:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/streatch-command-code-in-c-net-to-streatch-multiple-segements-of/m-p/12487902#M6017</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2024-01-10T09:37:37Z</dc:date>
    </item>
  </channel>
</rss>

