Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Operation Manager Hotkeys


VBJB
 Share

Recommended Posts

Hi Thad,

 

Here is how to map a VB script to a toolbar button. You could then set the hot key to launch the button.

code:

 Imports System.Windows.Forms

Imports Mastercam

 

 

 

Public Class VBFromButton

Inherits CMCNETApp

Public VBS_Running As Boolean = False

Public Overrides Function Run(ByVal param As Integer) As MC_RETURN

If VBS_Running Then Return MC_RETURN.MC_NOERROR

VBS_Running = True

MessageBox.Show("Please launch this function with the toolbar button only")

VBS_Running = False

End Function

Public Function VBFrmBtn(ByVal pram As Integer) As MC_RETURN

If VBS_Running Then Return MC_RETURN.MC_NOERROR

VBS_Running = True

Mastercam.GUI.RunVBScript("T:Mastercam_X_LibraryroutervbNC31doc.vbs")

VBS_Running = False

End Function

End Class


The file path for my nethook would need to be changed to point to the VB script that you want to run. In addition to the NetHook dll that you would need to compile, you need a File Table to display the icons for the button you are creating. The File Table should reside in the chooks folder with the dll for the Nethook. I would get a copy of VB express, it is free from Microsoft and I used it to compile this bit of code. Here is a sample FT file for my Nethook. It is important to note that you will need to create two different bitmap images for your buttons. The small bitmap must be 16 pixels square and the large icon must be 24 pixels square. In your solution properties you will need to import the Mastercam namespace and link your bitmap images as resources.

 

code:

 

APPLICATION "VBFromButton"

FUNC_DLL "CHOOKSVBFromButton.dll"

RES_DLL "SAME"

dnRES_NAME "VBFromBotton.VBFromButton"

CATEGORY "NETHook"

 

FUNCTION NET "VBFrmBtn"

dnSBMP("NC31S")

dnLBMP("NC31L")

dnTIP("NC31_STR")

END_FUNCTION()


I think this will get you started Thad, good luck.

 

Colin

Link to comment
Share on other sites

Colin,

 

Now you're way over my head. I was looking for something like a statement from MC Help that I overlooked. You know, something like "Go to Keymapping and it's under the ??? section. wink.gif

 

I'm not interested in making a big project out of this since there are already icons in the toolpath manager that will perform both of these tasks. It took me all of 5 minutes to write the script. If you'd like, I can send you the scripts and you can finish this, but I personally don't see the practicality of it (and I don't have the time). smile.gif

 

Thad

Link to comment
Share on other sites

If you want to create a keyboard shortcut, you should go to keymapping, its under the Settings category. You could map a keyboard shortcut to launch a VB script. The only problem is that you would have to use the elipsis button to select the script that you want to run each time. The elipsis button is the button with the three dots on it (for those who might be wondering). In our case we have about 10 different VB scripts that we run all of the time, sometimes using them multiple times a day. So for us it was a pretty easy solution to create 10 new buttons and our own custom toolbar. Now when we want to run a specific script we can click on one button instead of having to click on the Run VB button and then having to browse and select the file you want. It was a bit of work considering how long it took me to do, but it was my first Hook for Mastercam so I was pretty happy when I finally got it to work (Thanks Ed!!!).

 

-Colin

Link to comment
Share on other sites

Hi Lou,

 

We have written all of our scripts in house to accomplish specific tasks. We have several scripts that prompt the user with questions and then create setup documents in Microsoft Word for us. We also have another script that takes all of our entites and moves the level that they are on for file merge purposes. We have a couple scripts for creating geometry automatically, one for dovetails and one for creating arcs normal to a line. Basically you can create VB scripts to automate many of the common tasks that you do in Mastercam.

Link to comment
Share on other sites

quote:

You could map a keyboard shortcut to launch a VB script. The only problem is that you would have to use the elipsis button to select the script that you want to run each time.

That's what I was looking for...a way to execute a script, not launch the utility that will run the script.

 

Thad

Link to comment
Share on other sites
  • 3 weeks later...

OK, it's complete. I put a file on the FTP in the VB Scripts folder called Thad's Scripts (MCX MR2).zip. There's a readme file with instructions. The 3 things that can be keymapped are Select all dirty operations, Regen all dirty operations, and Regen selected operations.

 

Special thanks to Roger Martin and ScriptLinker! cheers.gif

 

Enjoy! smile.gif

 

Thad

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...