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:

Keymap vb script execution


Recommended Posts

Perhaps when you do a switch 'n' snap (patent pending biggrin.gif ), you should use the Nap() function to give Mastercam a chance to catch up:

 

code:

' this should probably go in a function or sub of its own

 

' start

SetGViewNumber(mcVIEW_FRONT)

Call RepaintScreen(True)

Call Nap(5)

Call RunMastercamCommand("ToClipboard")

Call Nap(8)

strCnvtImage = strPathToConv + " /clippaste /resample=(1000,800) /convert=" + strimage2 + ".png"

objWSHShell.Run strCnvtImage, 0, True

Call Nap(8)

 

' next

SetGViewNumber(mcVIEW_FRONT)

' ...

Also, though it may not be a big issue, is that your Nap() function (which might as well be a Sub since it doesn't return anything) will not behave as expected should an Internet connection not exist. In the case of no connection, Nap() will at most stop for 4 "seconds" when PING fails to reach a host. A better implementation would be:

 

code:

' Purpose: Alternative to WSH Shell Sleep() for Mastercam VBScript that

' pings the localhost a given number of times (read: seconds).

' I: number of "seconds" to nap

' O (none)

Sub Nap(iSeconds)

Const DEF_HOST = "127.0.0.1" ' localhost

Dim objShell ' WSH Shell object

 

 

Set objShell = CreateObject("WScript.Shell")

 

' need to add 1 to get it approx. correct

iSeconds = iSeconds + 1

objShell.Run "ping -n " & iSeconds & " " & DEF_HOST , 0, True

 

Set objShell = Nothing

End Sub

HTH

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...