<?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: Graphical user input in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/graphical-user-input/m-p/11669975#M10439</link>
    <description>Thank You</description>
    <pubDate>Tue, 10 Jan 2023 19:33:40 GMT</pubDate>
    <dc:creator>prahtYHGMJ</dc:creator>
    <dc:date>2023-01-10T19:33:40Z</dc:date>
    <item>
      <title>Graphical user input</title>
      <link>https://forums.autodesk.com/t5/net-forum/graphical-user-input/m-p/11664733#M10437</link>
      <description>&lt;P&gt;What technics needs to be used to get user input like in OFFSET command.&lt;/P&gt;&lt;P&gt;If cursor are in one side of line - first option,&lt;/P&gt;&lt;P&gt;cursor are in other side of line - second option.&lt;/P&gt;&lt;P&gt;So far I am using&amp;nbsp;PointMonitorEventHandler() and&amp;nbsp;TransientManager() to draw what user will get,&lt;/P&gt;&lt;P&gt;after he makes a choice, but I am stuck at distinguishing what side of line are cursor.&lt;/P&gt;&lt;P&gt;It's in 3d space and line can be at any random position. I have a Plane() on which line resides.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2023 19:31:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/graphical-user-input/m-p/11664733#M10437</guid>
      <dc:creator>prahtYHGMJ</dc:creator>
      <dc:date>2023-01-10T19:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: Graphical user input</title>
      <link>https://forums.autodesk.com/t5/net-forum/graphical-user-input/m-p/11666384#M10438</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Here's an example using a Jig (instead of PointMonitorEventHandler and&amp;nbsp;TransientManager).&lt;/P&gt;
&lt;P&gt;The jigged perpendicular line is red or green according to the side of the source line the cursor is. The reference vector is the current view direction.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;        [CommandMethod("TEST")]
        public void Test()
        {
            var doc = Application.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var ed = doc.Editor;

            var options = new PromptEntityOptions("\nSelect line: ");
            options.SetRejectMessage("\nSelected entity is not a line.");
            options.AddAllowedClass(typeof(Line), true);
            var result = ed.GetEntity(options);
            if (result.Status != PromptStatus.OK)
                return;

            using (var tr = db.TransactionManager.StartTransaction())
            {
                var axis = (Line)tr.GetObject(result.ObjectId, OpenMode.ForRead);
                using (var perp = new Line(Point3d.Origin, axis.GetClosestPointTo(Point3d.Origin, true)))
                {
                    var jig = new PerpendicularJig(perp, axis, ed);
                    var pr = ed.Drag(jig);
                    if (pr.Status == PromptStatus.OK)
                    {
                        var curSpace = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                        curSpace.AppendEntity(perp);
                        tr.AddNewlyCreatedDBObject(perp, true);
                    }
                }
                tr.Commit();
            }
        }
    }

    class PerpendicularJig : EntityJig
    {
        Point3d dragPoint;
        Line axis, perp;
        Vector3d axisDir;
        Editor ed;

        public PerpendicularJig(Line perp, Line axis, Editor ed) : base(perp)
        {
            this.axis = axis;
            this.perp = perp;
            axisDir = axis.StartPoint.GetVectorTo(axis.EndPoint);
            this.ed = ed;
        }

        protected override SamplerStatus Sampler(JigPrompts prompts)
        {
            var options = new JigPromptPointOptions("\nSpecify a point: ");
            options.UserInputControls = UserInputControls.Accept3dCoordinates;
            var result = prompts.AcquirePoint(options);
            if (result.Value.IsEqualTo(dragPoint))
                return SamplerStatus.NoChange;
            dragPoint = result.Value;
            return SamplerStatus.OK;
        }

        protected override bool Update()
        {
            using (var view = ed.GetCurrentView())
            {
                var viewDir = view.ViewDirection;
                perp.StartPoint = dragPoint;
                perp.EndPoint = axis.GetClosestPointTo(dragPoint, viewDir, true);
                var xform = Matrix3d.WorldToPlane(viewDir);
                var v1 = axisDir.ProjectTo(viewDir, viewDir);
                var v2 = perp.EndPoint.GetVectorTo(dragPoint).ProjectTo(viewDir, viewDir);
                perp.ColorIndex = v1.GetAngleTo(v2, viewDir) &amp;lt; Math.PI ? 1 : 3;
            }
            return true;
        }
    }&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 09 Jan 2023 13:40:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/graphical-user-input/m-p/11666384#M10438</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-01-09T13:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: Graphical user input</title>
      <link>https://forums.autodesk.com/t5/net-forum/graphical-user-input/m-p/11669975#M10439</link>
      <description>Thank You</description>
      <pubDate>Tue, 10 Jan 2023 19:33:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/graphical-user-input/m-p/11669975#M10439</guid>
      <dc:creator>prahtYHGMJ</dc:creator>
      <dc:date>2023-01-10T19:33:40Z</dc:date>
    </item>
  </channel>
</rss>

