<?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 Exception: eInvalidInput  Surface.CreateFrom(pl3d) in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/exception-einvalidinput-surface-createfrom-pl3d/m-p/12645638#M4994</link>
    <description>&lt;LI-CODE lang="csharp"&gt;            Point3d pt_left_down = new Point3d(432536.587782616, 2687388.25631493, 878.298840506535);
            Point3d pt_right_down = new Point3d(432550.741108191, 2687388.25631493, 870.545233657537);

            Point3d pt_left_up = new Point3d(432537.786447037, 2687391.85152945, 880.486865788067);

            Vector3d vec = pt_right_down - pt_left_down;

            Point3d pt_right_up = pt_left_up + vec;

            Point3dCollection pt3ds = new Point3dCollection();

            pt3ds.Add(pt_left_down);
            pt3ds.Add(pt_left_up);
            pt3ds.Add(pt_right_up);
            pt3ds.Add(pt_right_down);

            Polyline3d pl3d = new Polyline3d(Poly3dType.SimplePoly, pt3ds, true);

            //Error
            //Autodesk.AutoCAD.Runtime.Exception: eInvalidInput
            //Autodesk.AutoCAD.DatabaseServices.Surface.CreateFrom(Entity fromEntity)

            Autodesk.AutoCAD.DatabaseServices.Surface surface = Autodesk.AutoCAD.DatabaseServices.Surface.CreateFrom(pl3d);

            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;

            doc.AddToModelSpace(surface);&lt;/LI-CODE&gt;</description>
    <pubDate>Sun, 17 Mar 2024 04:23:29 GMT</pubDate>
    <dc:creator>wokeyiyognshenme</dc:creator>
    <dc:date>2024-03-17T04:23:29Z</dc:date>
    <item>
      <title>Exception: eInvalidInput  Surface.CreateFrom(pl3d)</title>
      <link>https://forums.autodesk.com/t5/net-forum/exception-einvalidinput-surface-createfrom-pl3d/m-p/12645638#M4994</link>
      <description>&lt;LI-CODE lang="csharp"&gt;            Point3d pt_left_down = new Point3d(432536.587782616, 2687388.25631493, 878.298840506535);
            Point3d pt_right_down = new Point3d(432550.741108191, 2687388.25631493, 870.545233657537);

            Point3d pt_left_up = new Point3d(432537.786447037, 2687391.85152945, 880.486865788067);

            Vector3d vec = pt_right_down - pt_left_down;

            Point3d pt_right_up = pt_left_up + vec;

            Point3dCollection pt3ds = new Point3dCollection();

            pt3ds.Add(pt_left_down);
            pt3ds.Add(pt_left_up);
            pt3ds.Add(pt_right_up);
            pt3ds.Add(pt_right_down);

            Polyline3d pl3d = new Polyline3d(Poly3dType.SimplePoly, pt3ds, true);

            //Error
            //Autodesk.AutoCAD.Runtime.Exception: eInvalidInput
            //Autodesk.AutoCAD.DatabaseServices.Surface.CreateFrom(Entity fromEntity)

            Autodesk.AutoCAD.DatabaseServices.Surface surface = Autodesk.AutoCAD.DatabaseServices.Surface.CreateFrom(pl3d);

            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;

            doc.AddToModelSpace(surface);&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 17 Mar 2024 04:23:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/exception-einvalidinput-surface-createfrom-pl3d/m-p/12645638#M4994</guid>
      <dc:creator>wokeyiyognshenme</dc:creator>
      <dc:date>2024-03-17T04:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: Exception: eInvalidInput  Surface.CreateFrom(pl3d)</title>
      <link>https://forums.autodesk.com/t5/net-forum/exception-einvalidinput-surface-createfrom-pl3d/m-p/12645768#M4995</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems there's an accuracy issue with the input points and the computed one (pt_right_up) which generate a Polyline 3d which is not exactly planar (e.g. it cannot be converted into a Region).&lt;/P&gt;
&lt;P&gt;A workaround should be using a Polyline instead.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;Point3d pt_left_down = new Point3d(432536.587782616, 2687388.25631493, 878.298840506535);
Point3d pt_right_down = new Point3d(432550.741108191, 2687388.25631493, 870.545233657537);
Point3d pt_left_up = new Point3d(432537.786447037, 2687391.85152945, 880.486865788067);

Vector3d normal = (pt_right_down - pt_left_down).CrossProduct(pt_left_up - pt_left_down).GetNormal();
Plane plane = new Plane(Point3d.Origin, normal);
double elevation = pt_left_down.TransformBy(Matrix3d.WorldToPlane(plane)).Z;
Point2d pt1 = pt_left_down.Convert2d(plane);
Point2d pt2 = pt_right_down.Convert2d(plane);
Point2d pt4 = pt_left_up.Convert2d(plane);
Point2d pt3 = pt2 + (pt4 - pt1);

using (var tr = db.TransactionManager.StartTransaction())
{
    var curSpace = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);

    using (var pline = new Polyline(4))
    {
        pline.AddVertexAt(0, pt1, 0.0, 0.0, 0.0);
        pline.AddVertexAt(1, pt2, 0.0, 0.0, 0.0);
        pline.AddVertexAt(2, pt3, 0.0, 0.0, 0.0);
        pline.AddVertexAt(3, pt4, 0.0, 0.0, 0.0);
        pline.Closed = true;
        pline.Normal = normal;
        pline.Elevation = elevation;

        var surface = Autodesk.AutoCAD.DatabaseServices.Surface.CreateFrom(pline);
        curSpace.AppendEntity(surface);
        tr.AddNewlyCreatedDBObject(surface, true);
    }
    tr.Commit();
}&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 17 Mar 2024 07:36:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/exception-einvalidinput-surface-createfrom-pl3d/m-p/12645768#M4995</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2024-03-17T07:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: Exception: eInvalidInput  Surface.CreateFrom(pl3d)</title>
      <link>https://forums.autodesk.com/t5/net-forum/exception-einvalidinput-surface-createfrom-pl3d/m-p/12645782#M4996</link>
      <description>&lt;P&gt;Or, simpler, use Surface.CreateExtrudedSurface.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;Point3d pt_left_down = new Point3d(432536.587782616, 2687388.25631493, 878.298840506535);
Point3d pt_right_down = new Point3d(432550.741108191, 2687388.25631493, 870.545233657537);
Point3d pt_left_up = new Point3d(432537.786447037, 2687391.85152945, 880.486865788067);

using (var tr = db.TransactionManager.StartTransaction())
{
    var curSpace = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
    using (var line = new Line(pt_left_down, pt_right_down))
    {
        var surface = Autodesk.AutoCAD.DatabaseServices.Surface.CreateExtrudedSurface(
            new Profile3d(line),
            pt_left_up - pt_left_down,
            new SweepOptions());
        curSpace.AppendEntity(surface);
        tr.AddNewlyCreatedDBObject(surface, true);
    }
        tr.Commit();
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Mar 2024 07:54:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/exception-einvalidinput-surface-createfrom-pl3d/m-p/12645782#M4996</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2024-03-17T07:54:42Z</dc:date>
    </item>
  </channel>
</rss>

