Author Topic: Custom Cursor or DynInput?  (Read 2934 times)

0 Members and 1 Guest are viewing this topic.

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Custom Cursor or DynInput?
« on: April 25, 2011, 04:24:39 PM »
I'm trying to duplicate a visual helper (with Dynamic Input off), similar to DynamicInput and ObjectSnap text display. In the following images, the center image is a typical ObjectSnap display. The lower image is making use of the PointMonitorEventArgs.AddToolTipText, note how this is identical to the ObjectSnap tip. The top image is one taken from Civil3D when editing elevations and slopes of a custom object...it is this that I am trying to achieve, without success. This little textbox follows the crosshairs and updates the text based on where it is in relation to the custom object.

I've found a few references on the Autodesk.Net forum that mentions using an undocumented function via P\Invoke "acedSetDynInputDisplayMessage", but from what I can tell this actually uses command line output to fill the message. This won't work, I think, because my command line must also aways display something else (C3D does this as well). I've looked over all the other possible hidden functions in acad.exe and see nothing that would allow this type of a cursor addition.

Any ideas on where to look next? Or is this possibly another custom object in itself?

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Custom Cursor or DynInput?
« Reply #1 on: April 27, 2011, 01:44:50 AM »
A day and a half, no responses. Ok, how about this for an idea....I've never worked with Jigs, yet, but could this be done using a Jig with a 2dSolid and a Text object? I think I'll look into that tomorrow.

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2151
  • class keyThumper<T>:ILazy<T>
Re: Custom Cursor or DynInput?
« Reply #2 on: April 27, 2011, 05:31:50 AM »

Flying past ..
not ignoring you Jeff, just haven't played with this aspect of the API.


Be well

Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Custom Cursor or DynInput?
« Reply #3 on: April 27, 2011, 02:48:22 PM »
Thanks for checking in, Kerry. I wasn't complaining, just making note that no one had responded. I just figured I'd finally 'stumped the experts' :-)

In my quest to solve this, I tried to incorporate an EntityJig using an MText with a BackgroundFill. This may actually be what I need, but I have yet been able to get it to work as desired.

Since I'm already using PointMonitor and TransientGraphics, to locate which object is currently closest to the crosshair, I thought I should be able to use that same MText object in the TransientGraphics and locate it adjacent to the crosshair......while the code runs without error, the MText is never displayed. :-(

So now I'm back to trying to figure out the thinga-ma-Jig. In the currently working (using the AddToolTipText method), I employ the PointMonitor and a loop using GetPoint(). When the user sees the entity they want to edit, and move the crosshair towards the ends or middle, they are presented with options that will affect the object, either the endpoints or the the slope from one end to the other. Once the entry is made the object is updated and the user is returned to the GetPoint() prompt. All the while the PointMonitor is running. Try to duplicate this behavior with a Jig is seemingly out of my reach at this time, but I shall continue trying.

T.Willey

  • Needs a day job
  • Posts: 5251
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Jeff H

  • Needs a day job
  • Posts: 6151
Re: Custom Cursor or DynInput?
« Reply #5 on: April 27, 2011, 04:54:33 PM »
while the code runs without error, the MText is never displayed. :-(

You might have to call it fom another thread

Needs refining
http://www.theswamp.org/index.php?topic=35456.msg407110#msg407110

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Custom Cursor or DynInput?
« Reply #6 on: April 27, 2011, 05:11:32 PM »
Thanks, Tim. I've been using that in my quest for knowledge.

It turns out the MText wasn't displaying where it should be because I failed to change the Location properly  :ugly: However, now that it IS showing, and is working much better than the Tooltips option I was using before, there are other issues I've yet to solve.

1.) The text is too thick...it is using the same font as that of the text in the drawing, yet looks vastly different.

2.) The BackgroundFill is not using the specified color (I specified color #51, an off-yellow). Fixed - Had to turn of the UseBackgroundColor ... but now the text stays White, no matter what color I set the MText entity to be.

3.) In the lower image below, the highlighted object bleeds through to be above the Transient Text. All other objects get hidden by the Transient Text.

If anyone has any ideas on how to address any of these items, I'm all ears!

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Custom Cursor or DynInput?
« Reply #7 on: April 27, 2011, 05:19:23 PM »
Here's the code that sets the MText props:

Code: [Select]
                dragtext = new MText();
                dragtext.BackgroundFill = true;
                dragtext.UseBackgroundColor = false;
                dragtext.BackgroundScaleFactor = 1.15;
                dragtext.BackgroundFillColor = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByAci, 51);
                dragtext.Color = Autodesk.AutoCAD.Colors.Color.FromRgb(0, 0, 0);
                dragtext.Attachment = AttachmentPoint.TopLeft;

And here is the result:

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Custom Cursor or DynInput?
« Reply #8 on: April 27, 2011, 06:01:59 PM »
I have no experience with Jig's for TransientGraphics, and not time to really play.  Sorry Jeff.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Custom Cursor or DynInput?
« Reply #9 on: April 28, 2011, 05:36:40 PM »
For those wanting to know where I was going with this, attached is a short Shockwave video demonstrating what I've ended up with. It's not what I envisioned it to look like, but until I can figure out something else it will have to do.

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Custom Cursor or DynInput?
« Reply #10 on: April 28, 2011, 05:38:38 PM »
Not sure why SMF shows it that way...but download the link and drag it into your web browser to view it.

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Custom Cursor or DynInput?
« Reply #11 on: April 28, 2011, 06:25:23 PM »
Found the solution to the highlighted entities being shown on top of the TransientGraphics. Every example I've seen for TG's uses this format, so that's what I've always used:

aGi.TransientManager.CurrentTransientManager.AddTransient(dragtext, aGi.TransientDrawingMode.DirectShortTerm, 128, intColl);

by changing it to use this, it now keeps the highlighted objects 'below' the TG's:

aGi.TransientManager.CurrentTransientManager.AddTransient(dragtext, aGi.TransientDrawingMode.DirectTopmost, 128, intColl);

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Custom Cursor or DynInput?
« Reply #12 on: April 29, 2011, 12:39:13 PM »
Well after a quick note to ADN, they confirmed that the TransientGraphics MText color cannot be changed...that is, as long as your view style is 2dWireframe. Between this and overall ugliness of the TG MText vs the crisp look of the Civil3D command shown in my first post, I decided to try a different approach. It took a while, and I'm still not 100% positive it will work on other computers, but this is what I came up with which is almost exactly what I was trying to achieve.

Thanks to all who looked and offered suggestions.


Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Custom Cursor or DynInput?
« Reply #13 on: April 29, 2011, 12:46:41 PM »
Oh, the solution?

I used a small form with autoresize enabled and a label. Then I displayed as a Modeless dialog and used the Editor.PointToScreen method in the PointMonitor event handler to locate it. For those wanting to play:

Code: [Select]
      private testdisplay frm;

        [CommandMethod("FormTest")]
        public void formtestcommand()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            frm = new testdisplay();
            using (Application.DocumentManager.MdiActiveDocument.LockDocument())
            {
                Application.ShowModelessDialog(frm);
                Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView();
                ed.PointMonitor += new PointMonitorEventHandler(ed_PointMonitor);
                PromptPointOptions pOpts = new PromptPointOptions("\nPick a point");
                pOpts.AllowNone = true;
                while (true)
                {
                    PromptPointResult pRes = ed.GetPoint(pOpts);
                    if (pRes.Status != PromptStatus.OK)
                        break;
                }
                ed.PointMonitor -= new PointMonitorEventHandler(ed_PointMonitor);
                frm.Close();
            }
        }

       void ed_PointMonitor(object sender, PointMonitorEventArgs e)
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            Point3d curPt = e.Context.RawPoint;
            System.Drawing.Point curScrnPt = ed.PointToScreen(curPt, Convert.ToInt16(Application.GetSystemVariable("CVPORT")));
            curScrnPt.Offset(Application.DocumentManager.MdiActiveDocument.Window.Location);//this gets us close to the cursor
            System.Drawing.Point xOff = new System.Drawing.Point(15, 38);//this fine tunes the location
            curScrnPt.Offset(xOff);
            frm.Location = curScrnPt;
       }