<?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 Drawing polyine in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/drawing-polyine/m-p/5403479#M42190</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Hi everyone&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to write something that gets the user to draw a closed polyline after a button is pressed on a form.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried using the CommandAsync method to send the PLINE command to autocad but using that didn't allow me to execute code after the polyline was drawn so I am currently using the method of creating a polyline object and adding vertices to it based on where the user clicks, however the problem with this method is that it does not show the line as I'm drawing it which would make it difficult for users to know where exactly they've drawn. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My question is, can I get autocad to show the lines of the polyline in the drawing as I add vertices?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Joel&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Nov 2014 09:18:49 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2014-11-14T09:18:49Z</dc:date>
    <item>
      <title>Drawing polyine</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawing-polyine/m-p/5403479#M42190</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi everyone&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to write something that gets the user to draw a closed polyline after a button is pressed on a form.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried using the CommandAsync method to send the PLINE command to autocad but using that didn't allow me to execute code after the polyline was drawn so I am currently using the method of creating a polyline object and adding vertices to it based on where the user clicks, however the problem with this method is that it does not show the line as I'm drawing it which would make it difficult for users to know where exactly they've drawn. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My question is, can I get autocad to show the lines of the polyline in the drawing as I add vertices?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Joel&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Nov 2014 09:18:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawing-polyine/m-p/5403479#M42190</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-11-14T09:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing polyine</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawing-polyine/m-p/5403931#M42191</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try this article from Kean's blog: &lt;A target="_self" href="http://through-the-interface.typepad.com/through_the_interface/2010/12/jigging-an-autocad-polyline-with-arc-segments-using-net.html"&gt;Polyline Jig&lt;/A&gt;&amp;nbsp; also this article from Norman Yuang's excelent blog it's very insightful: &lt;A target="_self" href="http://drive-cad-with-code.blogspot.com/2014/09/moving-mouse-cursor-to-trace-polyline.html"&gt;Tracing over a Polyline&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gaston Nunez&lt;/P&gt;</description>
      <pubDate>Fri, 14 Nov 2014 13:12:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawing-polyine/m-p/5403931#M42191</guid>
      <dc:creator>hgasty1001</dc:creator>
      <dc:date>2014-11-14T13:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing polyine</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawing-polyine/m-p/5404343#M42192</link>
      <description>&lt;P&gt;Thanks Gaston. I think this is exactly what I was looking for!&lt;/P&gt;</description>
      <pubDate>Fri, 14 Nov 2014 15:24:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawing-polyine/m-p/5404343#M42192</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-11-14T15:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing polyine</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawing-polyine/m-p/5406517#M42193</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a simpler exampe just using a base point in a GetPoint loop (works with straight segments on the current UCS plane).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using AcAp = Autodesk.AutoCAD.ApplicationServices.Application;

namespace DrawPline
{
    public class Commands
    {
        [CommandMethod("TEST")]
        public void Test()
        {
            Document doc = AcAp.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            PromptPointOptions opts = new PromptPointOptions("\nSpecify the first point: ");
            PromptPointResult result = ed.GetPoint(opts);
            if (result.Status != PromptStatus.OK)
                return;

            opts.Message = "\nSpecify next point: ";
            opts.AllowNone = true;
            opts.UseBasePoint = true;

            Matrix3d ucsMat = ed.CurrentUserCoordinateSystem;
            CoordinateSystem3d ucs = ucsMat.CoordinateSystem3d;
            Plane plane = new Plane(Point3d.Origin, ucs.Zaxis);

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                BlockTableRecord space =
                    (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                using (Polyline pline = new Polyline())
                {
                    pline.Normal = ucs.Zaxis;
                    pline.Elevation = ucs.Origin.Z;
                    pline.AddVertexAt(0, result.Value.TransformBy(ucsMat).Convert2d(plane), 0.0, 0.0, 0.0);
                    space.AppendEntity(pline);
                    tr.AddNewlyCreatedDBObject(pline, true);
                    int i = 1;
                    while (true)
                    {
                        opts.BasePoint = result.Value;
                        result = ed.GetPoint(opts);
                        if (result.Status == PromptStatus.Cancel)
                        {
                            return;
                        }
                        if (result.Status == PromptStatus.Keyword)
                        {
                            pline.Closed = true;
                            break;
                        }
                        if (result.Status != PromptStatus.OK)
                        {
                            break;
                        }
                        if (i == 2)
                        {
                            opts.SetMessageAndKeywords("\nSpecify next point [Close]: ", "Close");
                        }
                        pline.AddVertexAt(i++, result.Value.TransformBy(ucsMat).Convert2d(plane), 0.0, 0.0, 0.0);
                        db.TransactionManager.QueueForGraphicsFlush();
                        opts.BasePoint = result.Value;
                    }
                }
                tr.Commit();
            }
        }
    }
}
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Nov 2014 22:13:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawing-polyine/m-p/5406517#M42193</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2014-11-15T22:13:09Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing polyine</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawing-polyine/m-p/5407101#M42194</link>
      <description>&lt;P&gt;The same with an Undo option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;using System;
using System.Collections.Generic;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using AcAp = Autodesk.AutoCAD.ApplicationServices.Application;

namespace DrawPline
{
    public class Commands
    {
        [CommandMethod("TEST")]
        public void Test()
        {
            Document doc = AcAp.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            PromptPointOptions opts = new PromptPointOptions("\nSpecify the first point: ");
            PromptPointResult result = ed.GetPoint(opts);

            if (result.Status != PromptStatus.OK)return;

            Stack&amp;lt;Point3d&amp;gt; points = new Stack&amp;lt;Point3d&amp;gt;();
            points.Push(result.Value);

            Matrix3d ucsMat = ed.CurrentUserCoordinateSystem;
            CoordinateSystem3d ucs = ucsMat.CoordinateSystem3d;
            Plane plane = new Plane(Point3d.Origin, ucs.Zaxis);
            Func&amp;lt;Point3d, Point2d&amp;gt; conv2d = p =&amp;gt; p.TransformBy(ucsMat).Convert2d(plane);

            Autodesk.AutoCAD.DatabaseServices.TransactionManager transMgr = db.TransactionManager;
            using (Transaction tr = transMgr.StartTransaction())
            {
                BlockTableRecord space =
                    (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                using (Polyline pline = new Polyline())
                {
                    pline.Normal = ucs.Zaxis;
                    pline.Elevation = ucs.Origin.Z;
                    pline.AddVertexAt(0, conv2d(points.Peek()), 0.0, 0.0, 0.0);
                    space.AppendEntity(pline);
                    tr.AddNewlyCreatedDBObject(pline, true);

                    while (true)
                    {
                        switch (points.Count)
                        {
                            case 1:
                                opts = new PromptPointOptions("\nSpecify next point: ");
                                opts.AllowNone = true;
                                opts.UseBasePoint = true;
                                break;
                            case 2:
                                opts.SetMessageAndKeywords("\nSpecify next point [Undo]: ", "Undo");
                                break;
                            default:
                                opts.SetMessageAndKeywords("\nSpecify next point [Undo/Close]: ", "Undo Close");
                                break;
                        }
                        opts.BasePoint = points.Peek();
                        result = ed.GetPoint(opts);

                        if (result.Status == PromptStatus.Cancel) return;

                        if (result.Status == PromptStatus.Keyword)
                        {
                            if (result.StringResult.ToUpper() == "CLOSE")
                            {
                                pline.Closed = true;
                                break;
                            }
                            else
                            {
                                points.Pop();
                                pline.RemoveVertexAt(points.Count);
                                db.TransactionManager.QueueForGraphicsFlush();
                                continue;
                            }
                        }

                        if (result.Status != PromptStatus.OK)
                        {
                            if (points.Count &amp;gt; 1) break;
                            else return;
                        }

                        points.Push(result.Value);
                        pline.AddVertexAt(points.Count - 1, conv2d(points.Peek()), 0.0, 0.0, 0.0);
                        db.TransactionManager.QueueForGraphicsFlush();
                    }
                }
                tr.Commit();
            }
        }
    }
}
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Nov 2014 18:29:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawing-polyine/m-p/5407101#M42194</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2014-11-16T18:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing polyine</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawing-polyine/m-p/5407917#M42195</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;SPAN&gt;Gilles. That's really helpful too.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Nov 2014 10:24:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawing-polyine/m-p/5407917#M42195</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-11-17T10:24:56Z</dc:date>
    </item>
  </channel>
</rss>

