getpoint, OSMODE and F3

getpoint, OSMODE and F3

fieldguy
Advisor Advisor
1,808 Views
3 Replies
Message 1 of 4

getpoint, OSMODE and F3

fieldguy
Advisor
Advisor

If OSMODE is 0 (no object snaps set) and I use:

PromptPointOptions ppo = new PromptPointOptions("\nClick point: ");

ppo.AllowArbitraryInput = false;
ppo.AllowNone = false;
PromptPointResult ppr = ed.GetPoint(ppo);

and the user hits "F3" the prompt status is OK and the result is a point3d somewhere  

If OSMODE is anything > 0 getpoint waits and F3 produces <Osnapoff> or <Osnapon>.

I'd like to catch the "F3" when OSMODE is 0.  Do I have to use PreTranslateMessage or AppMessageFilter?  I can set OSMODE to 1 (Endpoint) and reset it to 0 when my picks are finished, but I'd rather handle the F3.    

 

0 Likes
Accepted solutions (1)
1,809 Views
3 Replies
Replies (3)
Message 2 of 4

ActivistInvestor
Mentor
Mentor

I can't reproduce what you describe below.

 

When I'm being prompted for a point via a call to GetPoint(), pressing F3 toggles osnap mode and the call to GetPoint() is still waiting for a response.

 


@fieldguywrote:

If OSMODE is 0 (no object snaps set) and I use:

PromptPointOptions ppo = new PromptPointOptions("\nClick point: ");

ppo.AllowArbitraryInput = false;
ppo.AllowNone = false;
PromptPointResult ppr = ed.GetPoint(ppo);

and the user hits "F3" the prompt status is OK and the result is a point3d somewhere  

If OSMODE is anything > 0 getpoint waits and F3 produces <Osnapoff> or <Osnapon>.

I'd like to catch the "F3" when OSMODE is 0.  Do I have to use PreTranslateMessage or AppMessageFilter?  I can set OSMODE to 1 (Endpoint) and reset it to 0 when my picks are finished, but I'd rather handle the F3.    

 


 

0 Likes
Message 3 of 4

BKSpurgeon
Collaborator
Collaborator

Hi there

 

Why not try the following code example which captures the f3 keystroke while you are also asking for the prompt point options. You'll have to register the filter before and unregister it after. You should be able to capture the f3 key and then you can do whatever you have in mind - in your case you'll have to check the OSMODE = 0 and then proceed etc etc. Hope this helps.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Geometry;

namespace PracticePlugins
{
    public class CaptureF3Example : System.Windows.Forms.IMessageFilter
    {
        public const int WM_KEYDOWN = 0x0100;        
        private Document doc;
        private Editor ed;

        public CaptureF3Example()
        {
            System.Windows.Forms.Application.AddMessageFilter(this);

            this.doc = Application.DocumentManager.MdiActiveDocument;
            this.ed = doc.Editor;
            PromptPointOptions ppo = new PromptPointOptions("\nClick point: ");
            ppo.AllowArbitraryInput = false;
            ppo.AllowNone = false;
            PromptPointResult ppr = ed.GetPoint(ppo);
            if (ppr.Status == PromptStatus.OK)
            {
                ed.WriteMessage("Looks good to me!");
            }

            System.Windows.Forms.Application.RemoveMessageFilter(this);
        }

        public bool PreFilterMessage(ref System.Windows.Forms.Message m)
        {
            System.Windows.Forms.Keys mods = System.Windows.Forms.Control.ModifierKeys;

            System.Windows.Forms.Keys latestKey = (System.Windows.Forms.Keys)m.WParam.ToInt32();
            if ((m.Msg == WM_KEYDOWN))
            {
                if (latestKey == System.Windows.Forms.Keys.F3)
                {
                    System.Windows.Forms.MessageBox.Show("F3 pressed!");
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }         
        }
    }
}

 

(and a quick plug: If you like autodesk new styling format for the forums, why not leave them some positive feedback at this location )

 

0 Likes
Message 4 of 4

fieldguy
Advisor
Advisor
Accepted solution

Thanks @ActivistInvestor and @BKSpurgeon.  I should have added I am using C3D 2016, and using a "while" loop for multiple picks.  I ended up setting osmode to 1 and reset to 0 when finished.  There is a prompt result string "'_+dsettings" - the command that brings up the Object Snap dialog.  That's what should happen but I couldn't figure out how to reset the prompt result.  It would skip over PromptEntityResult per = ed.GetEntity(peo) in my loop.     

I am accepting this band-aid as the solution and will revisit this when we move to C3D 2018.

BK - I liked NNTP.  I am not a fan of the new format but will give it some time to evolve. I do not have any positive feedback and I know from past experience autodesk does not appreciate (or listen to) my feedback. YMMV

0 Likes