<?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: Highlight part of polyline in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/highlight-part-of-polyline/m-p/3561684#M54220</link>
    <description>&lt;P&gt;Hi, ty for the response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I try your code, &amp;nbsp;get an error at the following line:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;pline.Highlight(ips[0], true);&lt;/PRE&gt;&lt;P&gt;Error:&lt;/P&gt;&lt;P&gt;eNotApplicable&amp;nbsp;at Autodesk.AutoCAD.DatabaseServices.Entity.Highlight(FullSubentityPath subId, Boolean highlightAll)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Trying to find out what it might be but no luck so far.&lt;/P&gt;</description>
    <pubDate>Wed, 01 Aug 2012 18:32:31 GMT</pubDate>
    <dc:creator>Ertqwa</dc:creator>
    <dc:date>2012-08-01T18:32:31Z</dc:date>
    <item>
      <title>Highlight part of polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/highlight-part-of-polyline/m-p/3558228#M54218</link>
      <description>&lt;P&gt;Hello Forum,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is it possible to highlight a part of a polyline in someway?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jul 2012 18:01:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/highlight-part-of-polyline/m-p/3558228#M54218</guid>
      <dc:creator>Ertqwa</dc:creator>
      <dc:date>2012-07-30T18:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: Highlight part of polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/highlight-part-of-polyline/m-p/3558372#M54219</link>
      <description>&lt;P&gt;Try thsi code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        [CommandMethod("Segh")]
        public void SegmentHighLight()
        {
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;

            Editor ed = doc.Editor;

            Database db = doc.Database;

            PromptEntityOptions peo = new PromptEntityOptions("\nSelect the segment to copy: ");

            peo.SetRejectMessage("\nYou have to select polyline only!");

            peo.AllowNone = false;

            peo.AllowObjectOnLockedLayer = false;

            peo.AddAllowedClass(typeof(Polyline), true);

            PromptEntityResult per = ed.GetEntity(peo);

            if (per.Status != PromptStatus.OK) return;

            ObjectId objId = per.ObjectId;

            if (!objId.ObjectClass.IsDerivedFrom( RXClass.GetClass(typeof(Polyline))))
            {

                ed.WriteMessage(

                    "\nYou didn't select a lwpline, please try again...\n");

                return;

            }

            try
            {
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    Polyline pline = tr.GetObject(objId, OpenMode.ForRead, false) as Polyline;

                    if (pline != null)
                    {
                        BlockTableRecord btr = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite, false) as BlockTableRecord;

                        Point3d pickPt = pline.GetClosestPointTo((Point3d)per.PickedPoint, false);

                        double param = pline.GetParameterAtPoint(pickPt);

                        int num = (int)param + 1;

                        ObjectId[] subentIds = { };

                        FullSubentityPath[] ips = pline.GetSubentityPathsAtGraphicsMarker(SubentityType.Edge, num, pickPt, Matrix3d.Identity, 1, subentIds);

                        pline.Highlight(ips[0], true);

                    }
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage(ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
                ed.WriteMessage("Pokey");
            }
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008080" face="arial,helvetica,sans-serif"&gt;~'J'~&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jul 2012 19:58:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/highlight-part-of-polyline/m-p/3558372#M54219</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-07-30T19:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: Highlight part of polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/highlight-part-of-polyline/m-p/3561684#M54220</link>
      <description>&lt;P&gt;Hi, ty for the response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I try your code, &amp;nbsp;get an error at the following line:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;pline.Highlight(ips[0], true);&lt;/PRE&gt;&lt;P&gt;Error:&lt;/P&gt;&lt;P&gt;eNotApplicable&amp;nbsp;at Autodesk.AutoCAD.DatabaseServices.Entity.Highlight(FullSubentityPath subId, Boolean highlightAll)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Trying to find out what it might be but no luck so far.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Aug 2012 18:32:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/highlight-part-of-polyline/m-p/3561684#M54220</guid>
      <dc:creator>Ertqwa</dc:creator>
      <dc:date>2012-08-01T18:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: Highlight part of polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/highlight-part-of-polyline/m-p/3561734#M54221</link>
      <description>&lt;P&gt;I tested code on A2010, it's&amp;nbsp; a reason maybe&lt;/P&gt;</description>
      <pubDate>Wed, 01 Aug 2012 18:57:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/highlight-part-of-polyline/m-p/3561734#M54221</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-08-01T18:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Highlight part of polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/highlight-part-of-polyline/m-p/3561946#M54222</link>
      <description>&lt;P&gt;Ah I see, I use AutoCAD2009. I'll do some more checking. Ty.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Aug 2012 20:27:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/highlight-part-of-polyline/m-p/3561946#M54222</guid>
      <dc:creator>Ertqwa</dc:creator>
      <dc:date>2012-08-01T20:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: Highlight part of polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/highlight-part-of-polyline/m-p/3562800#M54223</link>
      <description>&lt;P&gt;Here is another way, see maybe it will working on your release&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.Runtime;
	using Autodesk.AutoCAD.Geometry;
	using Autodesk.AutoCAD.GraphicsInterface;
	using Autodesk.AutoCAD.Colors;
	//_____________________________________//

        [CommandMethod("colseg")]
        public void ColoredSegment()
        {

            Document doc = Application.DocumentManager.MdiActiveDocument;

            Database db = doc.Database;

            Editor ed = doc.Editor;

            PromptEntityOptions peo = new PromptEntityOptions("\nSelect Segment of Polyline:");

            peo.SetRejectMessage("\nMust be a Polyline!");

            peo.AddAllowedClass(typeof(Autodesk.AutoCAD.DatabaseServices.Polyline), false);

            PromptEntityResult per = ed.GetEntity(peo);

            if (per.Status != PromptStatus.OK)

                return;

            Transaction tr = db.TransactionManager.StartTransaction();

            Autodesk.AutoCAD.DatabaseServices.Polyline pl = new Autodesk.AutoCAD.DatabaseServices.Polyline();

            IntegerCollection ic = new IntegerCollection();

            using (tr)
            {
                Autodesk.AutoCAD.DatabaseServices.Polyline pline = tr.GetObject(per.ObjectId, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Polyline;

                if (pline != null)
                {
                    BlockTableRecord btr = (BlockTableRecord)tr.GetObject(pline.OwnerId, OpenMode.ForWrite);

                    double bulg = 0;

                    Point3d picked = pline.GetClosestPointTo((Point3d)per.PickedPoint, false);

                    double par = pline.GetParameterAtPoint(picked);

                    int m = (int)par;

                    Point2dCollection verts = new Point2dCollection(2);

                    SegmentType stype = pline.GetSegmentType(m);

                    if (stype == SegmentType.Arc)
                    {
                        CircularArc2d arc = pline.GetArcSegment2dAt(m);

                        bulg = pline.GetBulgeAt(m);

                        verts.Add(arc.StartPoint);

                        verts.Add(arc.EndPoint);
                    }
                    else if (stype == SegmentType.Line)
                    {
                        LineSegment2d ln = pline.GetLineSegment2dAt(m);

                        verts.Add(ln.StartPoint);

                        verts.Add(ln.EndPoint);

                        bulg = 0;
                    }

                    pl.AddVertexAt(0, verts[0], bulg, 0, 0);

                    pl.AddVertexAt(1, verts[1], 0, 0, 0);

                    pl.ColorIndex = 121;

                    ObjectIdCollection ids = new ObjectIdCollection();

                    btr.AppendEntity(pl);

                    tr.AddNewlyCreatedDBObject(pl, true);

                    verts = new Point2dCollection();

                    if (pl != null)
                    {
                        TransientManager tm = TransientManager.CurrentTransientManager;
                        tm.AddTransient(pl, TransientDrawingMode.Highlight, 128, ic);

                    }
                }

                if (pl != null)
                {
                    pl.Erase();

                    pl.Dispose();// optional, might be removed
                }

                tr.Commit();
                // pause for user input only
                string key = ed.GetString("\nPress any key: ").StringResult;

                TransientManager.CurrentTransientManager.EraseTransient(pline, ic);

            }

        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800000" face="arial,helvetica,sans-serif"&gt;~'J'~&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2012 12:15:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/highlight-part-of-polyline/m-p/3562800#M54223</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-08-02T12:15:39Z</dc:date>
    </item>
    <item>
      <title>Re: Highlight part of polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/highlight-part-of-polyline/m-p/3563752#M54224</link>
      <description>&lt;P&gt;Hi, that works, thanks a lot!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One question tho, if I leave out the "EraseTransient" line at the end, it still disapears after I regenerate. Why should I call it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll try and see if I can get the other one to work.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2012 19:41:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/highlight-part-of-polyline/m-p/3563752#M54224</guid>
      <dc:creator>Ertqwa</dc:creator>
      <dc:date>2012-08-02T19:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: Highlight part of polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/highlight-part-of-polyline/m-p/3563764#M54225</link>
      <description>&lt;P&gt;I did it machinally, though it is no problem&lt;/P&gt;&lt;P&gt;to keep&amp;nbsp;them &amp;nbsp;inside, but who knows?&lt;/P&gt;&lt;P&gt;Of course, if you need to display a segment&lt;/P&gt;&lt;P&gt;in the work time, then don't remove,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See you,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800000" face="arial,helvetica,sans-serif"&gt;~'J'~&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2012 19:50:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/highlight-part-of-polyline/m-p/3563764#M54225</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-08-02T19:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: Highlight part of polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/highlight-part-of-polyline/m-p/8700041#M54226</link>
      <description>&lt;P&gt;Was wondering if anyone has a VB.net version of this code.&amp;nbsp; I am having some difficulty modifying&amp;nbsp;it from C#.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please let me know if you can.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 01:26:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/highlight-part-of-polyline/m-p/8700041#M54226</guid>
      <dc:creator>conveyor1</dc:creator>
      <dc:date>2019-04-02T01:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: Highlight part of polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/highlight-part-of-polyline/m-p/8700386#M54227</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you simply tried a &lt;A href="http://converter.telerik.com/" target="_blank" rel="noopener"&gt;code converter&lt;/A&gt;?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 07:21:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/highlight-part-of-polyline/m-p/8700386#M54227</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2019-04-02T07:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: Highlight part of polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/highlight-part-of-polyline/m-p/8701364#M54228</link>
      <description>&lt;P&gt;I have recently posted an article on this similar topic, showing a similar solution (using Transient Graphics to highlight part/segment of a polyline). But in my case, it is to highlight a segment when mouse cursor hover a polyline. I thought it may also be helpful/useful for your need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://drive-cad-with-code.blogspot.com/2019/02/visually-select-segment-of-polyline.html" target="_blank" rel="noopener"&gt;https://drive-cad-with-code.blogspot.com/2019/02/visually-select-segment-of-polyline.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately, the code is also in C#. As&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;suggested, you can find one of the online .NET code converter to easily convert the code to VB.NET.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 13:43:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/highlight-part-of-polyline/m-p/8701364#M54228</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2019-04-02T13:43:03Z</dc:date>
    </item>
  </channel>
</rss>

