<?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 : eInvalidInput when change SectionSettings' values in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/einvalidinput-when-change-sectionsettings-values/m-p/6347459#M35952</link>
    <description>Thank u so much.&lt;BR /&gt;</description>
    <pubDate>Wed, 25 May 2016 01:31:12 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-05-25T01:31:12Z</dc:date>
    <item>
      <title>eInvalidInput when change SectionSettings' values</title>
      <link>https://forums.autodesk.com/t5/net-forum/einvalidinput-when-change-sectionsettings-values/m-p/6345936#M35947</link>
      <description>&lt;P&gt;I use the&amp;nbsp;GetClosestPointTo method to make sure the point on the curve&lt;/P&gt;&lt;P&gt;then I get a&amp;nbsp;eInvalidInput error when using GetParameterAtPoint for a LWPolyline。&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is my code&lt;/P&gt;&lt;PRE&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Geometry;
[assembly: CommandClass(typeof(test.Class1))]
namespace test
{
    public class Class1
    {
        [CommandMethod("eg1")]
        public static void eg1()
        {
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            PromptEntityOptions peop = new PromptEntityOptions("\nchoose a polylne:");
            peop.SetRejectMessage("\n polyline only!");
            peop.AddAllowedClass(typeof(Polyline), true);
            PromptEntityResult res = ed.GetEntity(peop);
            if (res.Status != PromptStatus.OK)
                return;
            PromptPointOptions ppt = new PromptPointOptions("\nchoose a point:");
            PromptPointResult pptRes = ed.GetPoint(ppt);
            if (pptRes.Status != PromptStatus.OK)
                return;
            Polyline txt0 = null;
            using (Transaction trans = doc.Database.TransactionManager.StartTransaction())
            {
                txt0 = trans.GetObject(res.ObjectId, OpenMode.ForWrite) as Polyline;
                trans.Commit();
            }
            Point3d pt = txt0.GetClosestPointTo(pptRes.Value, true);
            double param1 = txt0.GetParameterAtPoint(pt);
            ed.WriteMessage("\nparam1=" + param1.ToString());
            double dis = txt0.GetDistAtPoint(pt);
            ed.WriteMessage("\ndis=" + dis.ToString());

        }
    }
}&lt;/PRE&gt;&lt;P&gt;and here is my drawing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 12:30:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/einvalidinput-when-change-sectionsettings-values/m-p/6345936#M35947</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-05-24T12:30:26Z</dc:date>
    </item>
    <item>
      <title>Re : eInvalidInput when change SectionSettings' values</title>
      <link>https://forums.autodesk.com/t5/net-forum/einvalidinput-when-change-sectionsettings-values/m-p/6345974#M35948</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should call GetClosestPointTo(), GetParameterAtPoint() and GetDistAtPoint() within the transaction scope because when the transaction is disposed (at the end of the using code block), the polyline (which was opened by the transaction) will also be disposed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To insure the point is on the curve, you should not call GetClosestPointTo() with the extend param set to true.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;using (Transaction trans = doc.Database.TransactionManager.StartTransaction())
{
    Polyline txt0 = (Polyline)trans.GetObject(res.ObjectId, OpenMode.ForWrite);
    Point3d pt = txt0.GetClosestPointTo(pptRes.Value, false);
    double param1 = txt0.GetParameterAtPoint(pt);
    double dis = txt0.GetDistAtPoint(pt);
    ed.WriteMessage("\ndis=" + dis.ToString());
    trans.Commit();
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 12:50:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/einvalidinput-when-change-sectionsettings-values/m-p/6345974#M35948</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2016-05-24T12:50:09Z</dc:date>
    </item>
    <item>
      <title>Re : eInvalidInput when change SectionSettings' values</title>
      <link>https://forums.autodesk.com/t5/net-forum/einvalidinput-when-change-sectionsettings-values/m-p/6346058#M35949</link>
      <description>&lt;P&gt;thank u so much.&lt;/P&gt;&lt;P&gt;but came with the same mistake after a few&amp;nbsp;&lt;SPAN&gt;‎Amendments&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Geometry;
[assembly: CommandClass(typeof(test.Class1))]
namespace test
{
    public class Class1
    {
        [CommandMethod("eg1")]
        public static void eg1()
        {
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            PromptEntityOptions peop = new PromptEntityOptions("\nchoose a polylne:");
            peop.SetRejectMessage("\n polyline only!");
            peop.AddAllowedClass(typeof(Polyline), true);
            PromptEntityResult res = ed.GetEntity(peop);
            if (res.Status != PromptStatus.OK)
                return;
            PromptPointOptions ppt = new PromptPointOptions("\nchoose a point:");
            PromptPointResult pptRes = ed.GetPoint(ppt);
            if (pptRes.Status != PromptStatus.OK)
                return;             
           &lt;FONT color="#FF6600"&gt; using (Transaction trans = doc.Database.TransactionManager.StartTransaction())
            {&lt;/FONT&gt;
                Polyline txt0 = trans.GetObject(res.ObjectId, OpenMode.ForWrite) as Polyline;
                Point3d pt = txt0.GetClosestPointTo(pptRes.Value, &lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;false&lt;/STRONG&gt;&lt;/FONT&gt;);
                double param1 = txt0.GetParameterAtPoint(pt);
                ed.WriteMessage("\nparam1=" + param1.ToString());
                double dis = txt0.GetDistAtPoint(pt);
                ed.WriteMessage("\ndis=" + dis.ToString());
            &lt;FONT color="#FF6600"&gt;    trans.Commit();
            }&lt;/FONT&gt;
        }
    }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 13:15:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/einvalidinput-when-change-sectionsettings-values/m-p/6346058#M35949</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-05-24T13:15:40Z</dc:date>
    </item>
    <item>
      <title>Re : eInvalidInput when change SectionSettings' values</title>
      <link>https://forums.autodesk.com/t5/net-forum/einvalidinput-when-change-sectionsettings-values/m-p/6346367#M35950</link>
      <description>&lt;P&gt;I think this is due to this drawing.&lt;/P&gt;
&lt;P&gt;AutoCAD looses its accuracy when entities are drawn far from the origin.&lt;/P&gt;
&lt;P&gt;The coordinates of the block reference are around (35639000000, 2897900000).&lt;/P&gt;
&lt;P&gt;If there's no imperative reason to draw so far from the origin, just move all entities nearer to (0,0).&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 15:10:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/einvalidinput-when-change-sectionsettings-values/m-p/6346367#M35950</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2016-05-24T15:10:05Z</dc:date>
    </item>
    <item>
      <title>Re : eInvalidInput when change SectionSettings' values</title>
      <link>https://forums.autodesk.com/t5/net-forum/einvalidinput-when-change-sectionsettings-values/m-p/6346413#M35951</link>
      <description>&lt;P&gt;If there any reason you can't move the entities closer to the origin, you can just move the polyline, do the computation and move it back when done. You can use the picked point as displacement vector.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        [CommandMethod("eg1")]
        public static void eg1()
        {
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            PromptEntityOptions peop = new PromptEntityOptions("\nchoose a polylne:");
            peop.SetRejectMessage("\n polyline only!");
            peop.AddAllowedClass(typeof(Polyline), true);
            PromptEntityResult res = ed.GetEntity(peop);
            if (res.Status != PromptStatus.OK)
                return;
            PromptPointOptions ppt = new PromptPointOptions("\nchoose a point:");
            PromptPointResult pptRes = ed.GetPoint(ppt);
            if (pptRes.Status != PromptStatus.OK)
                return;
            using (Transaction trans = doc.Database.TransactionManager.StartTransaction())
            {
                Polyline txt0 = trans.GetObject(res.ObjectId, OpenMode.ForWrite) as Polyline;
                Vector3d displacement = pptRes.Value.GetAsVector();
                txt0.TransformBy(Matrix3d.Displacement(displacement.Negate()));
                Point3d pt = txt0.GetClosestPointTo(Point3d.Origin, false);
                double param1 = txt0.GetParameterAtPoint(pt);
                ed.WriteMessage("\nparam1=" + param1.ToString());
                double dis = txt0.GetDistAtPoint(pt);
                ed.WriteMessage("\ndis=" + dis.ToString());
                txt0.TransformBy(Matrix3d.Displacement(displacement));
                trans.Commit();
            }
        }&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 May 2016 15:22:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/einvalidinput-when-change-sectionsettings-values/m-p/6346413#M35951</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2016-05-24T15:22:52Z</dc:date>
    </item>
    <item>
      <title>Re : eInvalidInput when change SectionSettings' values</title>
      <link>https://forums.autodesk.com/t5/net-forum/einvalidinput-when-change-sectionsettings-values/m-p/6347459#M35952</link>
      <description>Thank u so much.&lt;BR /&gt;</description>
      <pubDate>Wed, 25 May 2016 01:31:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/einvalidinput-when-change-sectionsettings-values/m-p/6347459#M35952</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-05-25T01:31:12Z</dc:date>
    </item>
  </channel>
</rss>

