<?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 : How to draw Perpendicular Lines in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6014199#M37307</link>
    <description>&lt;P&gt;IMO, If you want to draw in AutoCAD with code, you should learn at least the geometric operators and functions of the Point3d, Vector3d and Matrix3d types.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        public static void PerpendicularLines()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                PromptEntityOptions op = new PromptEntityOptions("\nSelect polyline :");
                op.SetRejectMessage("Must be Polyline");
                op.AddAllowedClass(typeof(Polyline), true);
                op.AllowNone = false;
                PromptEntityResult s = ed.GetEntity(op);
                if (s.Status == PromptStatus.OK)
                {
                    Polyline ent = (Polyline)tr.GetObject(s.ObjectId, OpenMode.ForRead);
                    Line drawLine = new Line();
                    double length = ent.Length;
                    double gap = length / 15.0;
                    double dis = gap;
                    //int run = ((int)gap); &amp;lt;- this is wrong and unusefull
                    var curSpace = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                    for (int i = 0; i &amp;lt; 14; i++)
                    {
                        Point3d p1 = ent.GetPointAtDist(dis);
                        Vector3d ang = ent.GetFirstDerivative(ent.GetParameterAtPoint(p1));
                        // scale the vector by 5.0 (so that it's 5 units length)
                        ang = ang.GetNormal() * 5.0;
                        // rotate the vector
                        ang = ang.TransformBy(Matrix3d.Rotation(Math.PI / 2.0, ent.Normal, Point3d.Origin));
                        // create a line by substracting and adding the vector to the point (displacing the point)
                        Line line = new Line(p1 - ang, p1 + ang);
                        curSpace.AppendEntity(line);
                        tr.AddNewlyCreatedDBObject(line, true);
                        dis = dis + gap;
                    }
                }
                tr.Commit();
            }
        }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 29 Jan 2016 16:48:47 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2016-01-29T16:48:47Z</dc:date>
    <item>
      <title>How to draw Perpendicular Lines</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6013431#M37304</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to learn how to draw perpendicular lines on Polyline with arc segments by dividing the polyline's length into 15 times in C#.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The length of each drawn Line is = 10.0 units.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in adnace.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/214637iE770133885C540E1/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Perpendicular lines.JPG" title="Perpendicular lines.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried coding it this way and I don't know how to draw the perpendicular lines.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        public static void PerpendicularLines()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                PromptEntityOptions op = new PromptEntityOptions("\nSelect polyline :");
                op.SetRejectMessage("Must be Polyline");
                op.AddAllowedClass(typeof(Polyline), true);
                op.AllowNone = false;
                PromptEntityResult s = ed.GetEntity(op);
                if (s.Status == PromptStatus.OK)
                {
                    Polyline ent = (Polyline)tr.GetObject(s.ObjectId, OpenMode.ForRead);
                    Line drawLine = new Line();
                    double length = ent.Length;
                    double gap = length / 15.0;
                    double dis = gap;
                    int run = ((int)gap);
                    for (int i = 0; i &amp;lt; run; i++)
                    {
                        Point3d p1 = ent.GetPointAtDist(dis);
                        Vector3d ang = ent.GetFirstDerivative(ent.GetParameterAtPoint(p1));
                        // I lost here and don't know how to create the lines ...
                        dis = dis + gap;
                    }
                }
                tr.Commit();
            }
        }&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Jan 2016 09:34:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6013431#M37304</guid>
      <dc:creator>J-Rocks</dc:creator>
      <dc:date>2016-01-29T09:34:46Z</dc:date>
    </item>
    <item>
      <title>Re : How to draw Perpendicular Lines</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6013782#M37305</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The GetfirstDerivative() function return a unit vector which direction is the tangent to the curve at specified point.&lt;/P&gt;
&lt;P&gt;Rotating this vector of 90° (PI / 2 radians) will return a unit vector perpendicular to the curve at specified point.&lt;/P&gt;
&lt;P&gt;Then, some very basic math/geomety should allow you to scale the vector and use it to get the displaced points.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2016 13:23:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6013782#M37305</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2016-01-29T13:23:46Z</dc:date>
    </item>
    <item>
      <title>Re : How to draw Perpendicular Lines</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6014151#M37306</link>
      <description>&lt;P&gt;Thank you gile,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sadly I couldn't solve it because these functions are completely new to me and I don't know how to play with them at the mean time.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2016 16:11:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6014151#M37306</guid>
      <dc:creator>J-Rocks</dc:creator>
      <dc:date>2016-01-29T16:11:05Z</dc:date>
    </item>
    <item>
      <title>Re : How to draw Perpendicular Lines</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6014199#M37307</link>
      <description>&lt;P&gt;IMO, If you want to draw in AutoCAD with code, you should learn at least the geometric operators and functions of the Point3d, Vector3d and Matrix3d types.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        public static void PerpendicularLines()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                PromptEntityOptions op = new PromptEntityOptions("\nSelect polyline :");
                op.SetRejectMessage("Must be Polyline");
                op.AddAllowedClass(typeof(Polyline), true);
                op.AllowNone = false;
                PromptEntityResult s = ed.GetEntity(op);
                if (s.Status == PromptStatus.OK)
                {
                    Polyline ent = (Polyline)tr.GetObject(s.ObjectId, OpenMode.ForRead);
                    Line drawLine = new Line();
                    double length = ent.Length;
                    double gap = length / 15.0;
                    double dis = gap;
                    //int run = ((int)gap); &amp;lt;- this is wrong and unusefull
                    var curSpace = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                    for (int i = 0; i &amp;lt; 14; i++)
                    {
                        Point3d p1 = ent.GetPointAtDist(dis);
                        Vector3d ang = ent.GetFirstDerivative(ent.GetParameterAtPoint(p1));
                        // scale the vector by 5.0 (so that it's 5 units length)
                        ang = ang.GetNormal() * 5.0;
                        // rotate the vector
                        ang = ang.TransformBy(Matrix3d.Rotation(Math.PI / 2.0, ent.Normal, Point3d.Origin));
                        // create a line by substracting and adding the vector to the point (displacing the point)
                        Line line = new Line(p1 - ang, p1 + ang);
                        curSpace.AppendEntity(line);
                        tr.AddNewlyCreatedDBObject(line, true);
                        dis = dis + gap;
                    }
                }
                tr.Commit();
            }
        }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2016 16:48:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6014199#M37307</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2016-01-29T16:48:47Z</dc:date>
    </item>
    <item>
      <title>Re : How to draw Perpendicular Lines</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6014271#M37308</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;IMO, If you want to draw in AutoCAD with code, you should learn at least the geometric operators and functions of the Point3d, Vector3d and Matrix3d types.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Thank you gile for your help and for writing the codes for me that was wonderful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes I should learn about the geometric operations and sadly the AutoCAD.net Help document does not have all funtions , for example the&amp;nbsp;GetParameterAtPoint and&amp;nbsp;GetPointAtDist .... etc are not or I couldn't find any reference for them in the .NET help document to read about them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have any good reference for AutoCAD.net C# ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mant thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2016 17:13:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6014271#M37308</guid>
      <dc:creator>J-Rocks</dc:creator>
      <dc:date>2016-01-29T17:13:12Z</dc:date>
    </item>
    <item>
      <title>Re : How to draw Perpendicular Lines</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6014336#M37309</link>
      <description>&lt;P&gt;By my side, I use the ObjectARX 20XX SDK which contains the required libraries (dll) for .NET developping and the documentation.&lt;/P&gt;
&lt;P&gt;The docs folder contains an arxmgd 20XX.chm file for managed code (.NET) only and also all the ObjectARX docs.&lt;/P&gt;
&lt;P&gt;You can download them from &lt;A href="http://usa.autodesk.com/adsk/servlet/index?siteID=123112&amp;amp;id=1911627" target="_blank"&gt;this page&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2016 17:39:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6014336#M37309</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2016-01-29T17:39:56Z</dc:date>
    </item>
    <item>
      <title>Re : How to draw Perpendicular Lines</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6014361#M37310</link>
      <description>Perfect gile , Many thanks</description>
      <pubDate>Fri, 29 Jan 2016 17:50:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6014361#M37310</guid>
      <dc:creator>J-Rocks</dc:creator>
      <dc:date>2016-01-29T17:50:24Z</dc:date>
    </item>
    <item>
      <title>Re : How to draw Perpendicular Lines</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6014564#M37311</link>
      <description>&lt;P&gt;Boning up on vector math and trig&amp;nbsp;is also recommended, IMO.&amp;nbsp; Matrix algebra might be useful in some places, but only so far as to grasp some of the transformation methods.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2016 19:10:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6014564#M37311</guid>
      <dc:creator>dgorsman</dc:creator>
      <dc:date>2016-01-29T19:10:34Z</dc:date>
    </item>
    <item>
      <title>Re : How to draw Perpendicular Lines</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6014637#M37312</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/253793"&gt;@dgorsman&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;Boning up on vector math and trig&amp;nbsp;is also recommended, IMO.&amp;nbsp; Matrix algebra might be useful in some places, but only so far as to grasp some of the transformation methods.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Thank you for your input dgorsman.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you post an example please?&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2016 19:41:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6014637#M37312</guid>
      <dc:creator>J-Rocks</dc:creator>
      <dc:date>2016-01-29T19:41:28Z</dc:date>
    </item>
    <item>
      <title>Re : How to draw Perpendicular Lines</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6014687#M37313</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;dgorsman a écrit&amp;nbsp;:&lt;BR /&gt;
&lt;P&gt;Boning up on vector math and trig&amp;nbsp;is also recommended, IMO.&amp;nbsp; Matrix algebra might be useful in some places, but only so far as to grasp some of the transformation methods.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I agree, matrix algebra knowledge isn't really required with .NET as the API provides built-in methods for the main operations (linear transformations, inversion, combinations, ...) which is not the case with LISP.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2016 20:01:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6014687#M37313</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2016-01-29T20:01:11Z</dc:date>
    </item>
    <item>
      <title>Re : How to draw Perpendicular Lines</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6014996#M37314</link>
      <description>&lt;P&gt;That, and lot of the legwork you've posted over the years.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now where's that beer smiley...&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2016 22:41:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6014996#M37314</guid>
      <dc:creator>dgorsman</dc:creator>
      <dc:date>2016-01-29T22:41:55Z</dc:date>
    </item>
    <item>
      <title>Re : How to draw Perpendicular Lines</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6015022#M37315</link>
      <description>&lt;P&gt;For example, vector cross products: &lt;A href="https://en.wikipedia.org/wiki/Cross_product" target="_blank"&gt;https://en.wikipedia.org/wiki/Cross_product&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just about everything in AutoCAD&amp;nbsp;3D space boils down into vector math.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From your original problem you have a&amp;nbsp;vector at any given point (direction of line), and a normal vector pointing straight up&amp;nbsp;(0,0,1); the cross product of the&amp;nbsp;two is mutually perpendicular and only needs to be scaled for length.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Highly useful when dealing with planes.&amp;nbsp; I can define an arbitrary&amp;nbsp;plane using a point in space and a normal vector (e.g. a viewing direction); using that, I can determine if a second point is on the plane by creating a vector from the point on the plane to the second point.&amp;nbsp; If the cross product of the two vectors is 0 they are mutually perpendicular and they are on the same plane.&amp;nbsp; A variation of the technique is used to project points onto a&amp;nbsp;plane such as a viewport.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2016 23:00:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6015022#M37315</guid>
      <dc:creator>dgorsman</dc:creator>
      <dc:date>2016-01-29T23:00:45Z</dc:date>
    </item>
    <item>
      <title>Re : How to draw Perpendicular Lines</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6015127#M37316</link>
      <description>&lt;P&gt;Hi can you post a picture of the final result for completeness of the solution. folks (including me) will be interested to see it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;rgds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BK&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Jan 2016 00:52:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-draw-perpendicular-lines/m-p/6015127#M37316</guid>
      <dc:creator>BKSpurgeon</dc:creator>
      <dc:date>2016-01-30T00:52:09Z</dc:date>
    </item>
  </channel>
</rss>

