I have a macro for different materials that starts with a main menu with 4 different material type buttons. When you click on one of the buttons the menu disappears and the macro then waits for the user to click somewhere within the model view to get the x, y, & z coordinates of the mouse pointer and then inserts a part in that location. It works great but if the user isn't familiar with the macro and doesn't realize that the macro is waiting for them to click to place the part they may think that the macro is loading or just isn't doing anything.
I would like to add a message somewhere or some kind of tooltip attached to the mouse pointer that says "Click in model view to place part".
Is this possible and if so what would be the best way to go about doing this?
Thanks
SolidworksApi/macros
I could only find references in the API to allow mouse cursor notifications when over a command button, for example when you float over a button in the command manager or toolbar.
Typically when I have seen this done with a macro, there is either an output message box to prompt the user or a string placed in the status bar of the macro. You can also show a message/tooltip when I user tries to click on anything within the macro window to show what input it is waiting for.
... Just a hint how it's done !
Now you're just showing off...
Believe the OP already figured out !
To have the interface working nicely, you can overlay a picture box over your form (make sure the picture box is locked with the form) and set it in certain size. From there you know exactly where the x,y for the mouser move
and in initial form, you can use the ratio from what you find at certain size form
It'd work nicely when the user resize the from at running time - I did it in my nViews tool and it works nicely when user clicks any point on the form at any size
I modified it a bit to strip it down so there is no image with it anymore and it's just a message.
#If VBA7 Then
Declare PtrSafe Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
#Else
Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
#End If
' Create custom variable that holds two integers
Type POINTAPI
Xcoord As Long
Ycoord As Long
End Type
Public llCoord As POINTAPI
Then I have this portion in a subroutine.
GetCursorPos llCoord
' Show Bubble ToolTip
swAppCoordinates.ShowBubbleTooltipAt2 llCoord.Xcoord, llCoord.Ycoord, swArrowLeftTop, "Click anywhere in model view to place part", "", swBitMapUserDefined, "", "", 0, swLinkStringNone, "", ""
Can you post that code snippet, in case anyone else comes along and sees this thread?
This is a good idea and I was able to find some code to get the cursor location so I made it so that it pulls the coordinates of where the mouse is located when the button on the menu is pressed. This seems to work really good. Thanks everyone!
Perhaps the window location and size could help? I haven't used these myself but they seem like they'd give what OP needs.
swApp.FrameLeft
swApp.FrameTop
swApp.FrameWidth
swApp.FrameHeight
Not a programmer, but is there a way to get the location of the cursor and feed that to those coordinates? I think there should be a way to do that. Though, the search I made only turns up placing things at the cursor location, not retrieving that information:
2017 api Search - English
I got that to work and its exactly what I want except that it is locked to one location. When working on dual monitors I don't know which screen the user has their Solidworks on so if I use the included coordinates the tooltip always pops up in the same location which could potentially be the opposite screen that Solidworks is actually on. Is there any way to detect which screen Solidworks is on or somehow attach the tooltip to the mouse cursor?
Try this: 2017 SOLIDWORKS API Help - ShowBubbleTooltipAt2 Method (ISldWorks)
I want to try and avoid a pop up that they actually have to click through. Once you have used the macro once you should know that you need to click to place it in the model view so I don't want to add an extra step. I'll maybe look for some code to change the mouse cursor to a custom cursor or something like that.
Will it work if after clicking the button menu on your macro:
A new window pop up (by loading a new UserForm) and ask the user to select something and click [NEXT] ?
This will require an extra click but should be able to be implemented more easily (while including some error handling) in my opinion...
Alternatively, you could also make a window pop up with message and use a while loop while waiting for user input