The StatusBarText do not work

The StatusBarText do not work

18627796338
Enthusiast Enthusiast
558 Views
10 Replies
Message 1 of 11

The StatusBarText do not work

18627796338
Enthusiast
Enthusiast

When I use InteractionEvents.StatusBarText with InteractionEvents.SelectEvents, it works well. When I use InteractionEvents.StatusBarText with InteractionEvents.MouseEvents, it does not work.

20211202091719.png

How can I use StatusBarText with InteractionEvents.MouseEvents?

 

0 Likes
559 Views
10 Replies
Replies (10)
Message 2 of 11

moveworkforward
Contributor
Contributor

Hi @18627796338 

 

You may try to set ShowCommandPromtTooltip = true, like this: 

 

ThisApplication.GeneralOptions.ShowCommandPromptTooltips = True 
userInteractionEvents.StatusBarText = "select a point"

 

My AddIns: Place Fasteners | Quick Section View 

 

0 Likes
Message 3 of 11

18627796338
Enthusiast
Enthusiast
I added this code, but it still does not work.
0 Likes
Message 4 of 11

18627796338
Enthusiast
Enthusiast

I post my code below. I dont know why it does not work.

 

private Inventor.Application oApplication;
private InteractionEvents oInteractionEvents;
private MouseEvents oMouseEvents;
private InteractionGraphics oIntGraphics;
internal void GetCurPosition(Application m_inventorApplication)
{
    oApplication = m_inventorApplication;
    DrawingDocument drgDoc = m_inventorApplication.ActiveDocument as DrawingDocument;

    oInteractionEvents = m_inventorApplication.CommandManager.CreateInteractionEvents();
    oIntGraphics = oInteractionEvents.InteractionGraphics;
    oInteractionEvents.InteractionDisabled = false;
    oMouseEvents = oInteractionEvents.MouseEvents;
    oMouseEvents.MouseMoveEnabled = true;
    oMouseEvents.PointInferenceEnabled = true;

    oMouseEvents.OnMouseClick += new Inventor.MouseEventsSink_OnMouseClickEventHandler(this.oMouseEvents_OnMouseClick);
    oInteractionEvents.OnTerminate += new Inventor.InteractionEventsSink_OnTerminateEventHandler(this.oInteractionEvents_OnTerminate);

    m_inventorApplication.StatusBarText = "select a point (from app)";
    oInteractionEvents.StatusBarText = "select a point";
    oApplication.GeneralOptions.ShowCommandPromptTooltips = true;
    oInteractionEvents.Start();
}

private void oInteractionEvents_OnTerminate()
{
    oMouseEvents.OnMouseClick -= new Inventor.MouseEventsSink_OnMouseClickEventHandler(this.oMouseEvents_OnMouseClick);
    oInteractionEvents.OnTerminate -= new Inventor.InteractionEventsSink_OnTerminateEventHandler(this.oInteractionEvents_OnTerminate);
    oMouseEvents = null;
    oInteractionEvents = null;
}


private void oMouseEvents_OnMouseClick(MouseButtonEnum Button, ShiftStateEnum ShiftKeys, Point ModelPosition, Point2d ViewPosition, View View)
{
    System.Windows.Forms.MessageBox.Show("position:" + ModelPosition.X + "," + ModelPosition.Y);
}

 

0 Likes
Message 5 of 11

liminma8458
Collaborator
Collaborator

I have the same problem. Is it a bug for mouse event? Can someone escalate the issue?

Thanks

Thanks
Limin
Inventor pro 2023 64 bit update 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit

Download iCable in App Store to Create Cables Easily

0 Likes
Message 6 of 11

WCrihfield
Mentor
Mentor

Hi @liminma8458.  I just conducted a local test on my computer using the InteractionEvents and MouseEvents, and the InteractionEvents.StatusBarText property worked OK for me.  I am using Inventor Pro 2024.3.5 on a Windows 11 PC.  I attached the simple iLogic rule example code I used to test with, which was an older example code I already had on hand, just for reference.  I see in your post signature area that you are using 2023 on a Windows 10 computer, so maybe there have been some changes / updates / fixes to how that code works since then, I'm not sure.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 11

liminma8458
Collaborator
Collaborator

Hi, Wesley,

Thank you very much for your code.

The code did work with a mouseevents alone in iLogic. I converted it to Vb.NET and it works too. However, I have a project which call a selectionevents and then a mouseevents, the StatusBarText shows for selectionevents, but it does not show for the mouseevents, although I am still able to click and get the point information.

Can you have a look at the below code? do you have any cure for it?

Thanks
Limin
Inventor pro 2023 64 bit update 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit

Download iCable in App Store to Create Cables Easily

0 Likes
Message 8 of 11

WCrihfield
Mentor
Mentor

Hi @liminma8458.  I did test the code you posted, and did not see the prompt to click somewhere (same as you), and do not initially understand why.  But, I have never seen code put together that way while attempting to do what I suspect you were trying to do...which is OK, and expected when experimenting / testing.  I am a little confused about the purpose of your code example, so I was not immediately sure how to suggest correcting it in a simple way.  It looks like your intention may have been to first ask the user to select a circular part edge, then ask them to click somewhere in model space, then do something with those two pieces of data.  But the Pick method is a Sub routine, instead of a Function, so it will not 'Return' anything to the 'calling routine'.  Similarly, there is no secondary custom Function within the Class (besides the Pick method) like 'GetMouseClickLocation' which the user can call from the calling routine to get that data.  Instead, you are trying to initiate additional, manual user interactions from the user from within the event handler, with no way of returning that data to the calling routine.  I understand that this may simply be an 'exploratory' piece of code, so not really ready for direct use in a production related role, so you are likely just attempting to 'log' data.  However, it is generally not a good idea to include MessageBox.Show() or MsgBox() codes directly within event handlers, and it is generally best to 'log' data using something like the iLogic 'Logger', or other call to a method defined outside of that event handler which invisibly records the data, then retrieve that data another way after the event.  And yes, I do realize that is contradictory to the previous code example I posted.  😋  So, I would recommend a complete restructuring of the code.  Convert the Pick method into a Function that returns something to a routine outside of that Class, which calls it to run.  Then create another custom Function within that Class which can be called directly by a routine outside of that Class, and returns something to it.  Then, create some additional Private variables within the Class (but not within any routine) to hold onto the values which you are interested in, that the event handlers provide.  Within the event handlers, set the values of those Private variables.  The custom Functions will then get the values of those private variables, and return them to the calling routine (outside of the Class).  Then the calling routine (outside of the Class) can use the returned data however it wants, such as logging that data to the iLogic Log window, or showing it in a message, or using it as inputs for further purposes.  Just some suggestions, but I think doing things that way will clarify it, help eliminate the issue you are seeing, and make it most dynamic / useful.

I will attach another example external iLogic rule I have, which may be helpful, but it also does not use a Class, so not the best match either.  I do have several external rules containing Classes and Modules that I reference from other rules, but the 'related' ones are generally more elaborate, and primarily for selection purposes, instead of specifically for returning mouse click location/points.  Some may include that data though Public Properties of the Class though, as a side bonus, because some selection events also return mouse position related data.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 9 of 11

liminma8458
Collaborator
Collaborator

Hi, Wesley,

Calling the selectionevents then mouseevents (such OnMouseMove) is one of our code process that works well in our automation program in VB.NET. Only drawback is that mouseevents misses the mouse tip (StatusBarText) for user's convenience. I am puzzled why the code does not work in VB.NET, because the same code in iLogic format did work well. Both files will attach below. I wonder why they behave differently. I would welcome any suggestion. Can Mike Deck @MjDeck help on this? Thank you so much.

Thanks
Limin
Inventor pro 2023 64 bit update 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit

Download iCable in App Store to Create Cables Easily

0 Likes
Message 10 of 11

MjDeck
Autodesk
Autodesk

Hi Limin - can you post the source code of a test project that uses the code in pick_SelectEv_MouseEv?
It should be easy to create this test project based on your existing project. You can copy the project and delete the business logic. Keep the connection to Inventor and the selection and mouse event class. This project should be able to work on its own. The only thing missing should be the status text.
Is this an add-in, or a standalone EXE that connects to Inventor?


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 11 of 11

liminma8458
Collaborator
Collaborator

I have it work as below. Thank all of you for giving me the clues.

Thanks
Limin
Inventor pro 2023 64 bit update 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit

Download iCable in App Store to Create Cables Easily

0 Likes