<?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: Prompt point with ortho mode in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/prompt-point-with-ortho-mode/m-p/13614242#M119</link>
    <description>&lt;P&gt;Here's an example that was quickly adapted from a jig I've used to obtain a point that lies on any type of Curve. You can use a LineSegment3d as the curve argument to get a point on that line that's perpendicular to the current cursor location.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using System;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.GraphicsInterface;
using Autodesk.AutoCAD.Runtime;

namespace AcMgdLib.Geometry
{
   /// &amp;lt;summary&amp;gt;
   /// Acquires a point that is constrained to be
   /// on a curve, perpendicular/nearest to the 
   /// selected point.
   /// &amp;lt;/summary&amp;gt;
   
   public class PointOnCurveJig : DrawJig
   {
      Curve3d curve;
      bool flag = false;
      Point3d last = Point3d.Origin;
      Point3d basePoint;
      string message;

      public PointOnCurveJig(Curve3d curve, string message = null)
      {
         this.curve = curve;
         this.basePoint = curve.StartPoint;
         this.message = message ?? "\nPoint on curve: ";
      }

      /// &amp;lt;summary&amp;gt;
      /// The resulting point on the Curve3d that
      /// was passed to the constructor.
      /// &amp;lt;/summary&amp;gt;
      public Point3d PointOnCurve =&amp;gt; basePoint;

      /// &amp;lt;summary&amp;gt;
      /// The other endpoint of the perpendicular
      /// line, that was picked by the user.
      /// &amp;lt;/summary&amp;gt;
      public Point3d PickedPoint =&amp;gt; last;
      
      protected override SamplerStatus Sampler(JigPrompts prompts)
      {
         var options = new JigPromptPointOptions();
         options.Message = this.message;
         options.UserInputControls = UserInputControls.UseBasePointElevation;
         options.Cursor = CursorType.RubberBand;
         options.UseBasePoint = true;
         options.BasePoint = basePoint;
         PromptPointResult ppr;
         using(new SystemVariable("ORTHOMODE", 0))
         {
            ppr = prompts.AcquirePoint(options);
         }
         if(ppr.Status == PromptStatus.OK)
         {
            last = ppr.Value;
            basePoint = curve.GetClosestPointTo(last).Point;
            return SamplerStatus.OK;
         }
         return SamplerStatus.Cancel;
      }

      protected override bool WorldDraw(WorldDraw draw)
      {
         return true;
      }

      [CommandMethod("POINTONCURVEJIG")]
      public static void PointOnCurveJigExample()
      {
         var doc = Application.DocumentManager.MdiActiveDocument;
         var ed = doc.Editor;
         var peo = new PromptEntityOptions("\nSelect a curve: ");
         peo.SetRejectMessage("\nInvalid, requires a Curve");
         peo.AddAllowedClass(typeof(Curve), false);
         var per = ed.GetEntity(peo);
         if(per.Status != PromptStatus.OK)
            return;
         Curve3d curve3d;
         using(var tr = new OpenCloseTransaction())
         {
            var curve = (Curve)tr.GetObject(per.ObjectId, OpenMode.ForRead);
            curve3d = curve.GetGeCurve();
            tr.Commit();
         }
         var jig = new PointOnCurveJig(curve3d);
         var res = doc.Editor.Drag(jig);
         if(res.Status == PromptStatus.OK)
         {
            using(new SystemVariable("OSMODE", 0))
            {
               ed.Command("._LINE", jig.PointOnCurve, jig.PickedPoint, "");
            }
         }
      }
   }

   public class SystemVariable : IDisposable
   {
      string name;
      object value;
      public SystemVariable(string name, object value)
      {
         this.value = Application.GetSystemVariable(name);
         this.name = name;
         Application.SetSystemVariable(name, value);
      }
      public void Dispose()
      {
         if(value != null)
         {
            Application.SetSystemVariable(name, value);
            value = null;
         }
      }
   }

}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 05 May 2025 15:57:12 GMT</pubDate>
    <dc:creator>ActivistInvestor</dc:creator>
    <dc:date>2025-05-05T15:57:12Z</dc:date>
    <item>
      <title>Prompt point with ortho mode</title>
      <link>https://forums.autodesk.com/t5/net-forum/prompt-point-with-ortho-mode/m-p/13614057#M118</link>
      <description>&lt;P&gt;Is there a way to control the orthogonal mode at the prompt level?&lt;/P&gt;&lt;P&gt;For example, I retrieve two points (P1, P2), and then I want to retrieve a third point (P3). However, I want to impose a condition: the line formed by P3 and P2 must be perpendicular to the line (P1, P2). Otherwise, I need to enforce the orthogonal mode. Can this be achieved?&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 11:49:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/prompt-point-with-ortho-mode/m-p/13614057#M118</guid>
      <dc:creator>youssefGC</dc:creator>
      <dc:date>2025-05-05T11:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: Prompt point with ortho mode</title>
      <link>https://forums.autodesk.com/t5/net-forum/prompt-point-with-ortho-mode/m-p/13614242#M119</link>
      <description>&lt;P&gt;Here's an example that was quickly adapted from a jig I've used to obtain a point that lies on any type of Curve. You can use a LineSegment3d as the curve argument to get a point on that line that's perpendicular to the current cursor location.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using System;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.GraphicsInterface;
using Autodesk.AutoCAD.Runtime;

namespace AcMgdLib.Geometry
{
   /// &amp;lt;summary&amp;gt;
   /// Acquires a point that is constrained to be
   /// on a curve, perpendicular/nearest to the 
   /// selected point.
   /// &amp;lt;/summary&amp;gt;
   
   public class PointOnCurveJig : DrawJig
   {
      Curve3d curve;
      bool flag = false;
      Point3d last = Point3d.Origin;
      Point3d basePoint;
      string message;

      public PointOnCurveJig(Curve3d curve, string message = null)
      {
         this.curve = curve;
         this.basePoint = curve.StartPoint;
         this.message = message ?? "\nPoint on curve: ";
      }

      /// &amp;lt;summary&amp;gt;
      /// The resulting point on the Curve3d that
      /// was passed to the constructor.
      /// &amp;lt;/summary&amp;gt;
      public Point3d PointOnCurve =&amp;gt; basePoint;

      /// &amp;lt;summary&amp;gt;
      /// The other endpoint of the perpendicular
      /// line, that was picked by the user.
      /// &amp;lt;/summary&amp;gt;
      public Point3d PickedPoint =&amp;gt; last;
      
      protected override SamplerStatus Sampler(JigPrompts prompts)
      {
         var options = new JigPromptPointOptions();
         options.Message = this.message;
         options.UserInputControls = UserInputControls.UseBasePointElevation;
         options.Cursor = CursorType.RubberBand;
         options.UseBasePoint = true;
         options.BasePoint = basePoint;
         PromptPointResult ppr;
         using(new SystemVariable("ORTHOMODE", 0))
         {
            ppr = prompts.AcquirePoint(options);
         }
         if(ppr.Status == PromptStatus.OK)
         {
            last = ppr.Value;
            basePoint = curve.GetClosestPointTo(last).Point;
            return SamplerStatus.OK;
         }
         return SamplerStatus.Cancel;
      }

      protected override bool WorldDraw(WorldDraw draw)
      {
         return true;
      }

      [CommandMethod("POINTONCURVEJIG")]
      public static void PointOnCurveJigExample()
      {
         var doc = Application.DocumentManager.MdiActiveDocument;
         var ed = doc.Editor;
         var peo = new PromptEntityOptions("\nSelect a curve: ");
         peo.SetRejectMessage("\nInvalid, requires a Curve");
         peo.AddAllowedClass(typeof(Curve), false);
         var per = ed.GetEntity(peo);
         if(per.Status != PromptStatus.OK)
            return;
         Curve3d curve3d;
         using(var tr = new OpenCloseTransaction())
         {
            var curve = (Curve)tr.GetObject(per.ObjectId, OpenMode.ForRead);
            curve3d = curve.GetGeCurve();
            tr.Commit();
         }
         var jig = new PointOnCurveJig(curve3d);
         var res = doc.Editor.Drag(jig);
         if(res.Status == PromptStatus.OK)
         {
            using(new SystemVariable("OSMODE", 0))
            {
               ed.Command("._LINE", jig.PointOnCurve, jig.PickedPoint, "");
            }
         }
      }
   }

   public class SystemVariable : IDisposable
   {
      string name;
      object value;
      public SystemVariable(string name, object value)
      {
         this.value = Application.GetSystemVariable(name);
         this.name = name;
         Application.SetSystemVariable(name, value);
      }
      public void Dispose()
      {
         if(value != null)
         {
            Application.SetSystemVariable(name, value);
            value = null;
         }
      }
   }

}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 15:57:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/prompt-point-with-ortho-mode/m-p/13614242#M119</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2025-05-05T15:57:12Z</dc:date>
    </item>
  </channel>
</rss>

