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

So...

 

Just, how much is this worth to you ? biggrin.gif

 

ScriptLinker:

This utility creates a “Run Wrapper” NET Hook that allows you to “link” a VB Script to a toolbar and/or keystroke in Mastercam X.

See the ScripLinker.DOC for details.

 

Looks like somehow this got lost off the Mastercam web site downloads area in the transition over to the new web site. I've requested that it get added back into the Support-Download section.

 

For those of you that just cannot wait, you can retrieve ScriptLinker.ZIP on the forum FTP in the folder -> /Mastercam_forum/C-hooks/

Link to comment
Share on other sites
  • 1 month later...

I also get this error. Is ScripLinker.dll a C-Hook or a Nethook (I'm guessing Nethook)? I've found that with Nethooks, supporting DLLs must accompany the Nethook binary. The ol' dynamic linking thing. I found that out the hard when when trying to run one of my Nethooks (that used code from Interop.Excel.dll and Interop.Microsoft.Office.Core.dll) on a computer that wasn't my own. Is this the case?

Link to comment
Share on other sites

OK, now I have another problem.

 

I wrote a script that creates 3 images of the model on the screen. On the rough it works like this:

- change background color to White

- set Gview to ISO

- refresh the screen

- call function "To clipboard"

- call Irfan executable to process the image from clipboard and save it as .PNG image

- change Gview to TOP

- do it all over again

- Change Gview to side

- do it all over again

 

Why did I take function "To clipboard"? Because I could not get good results with "Metafile" (not shaded) and "BMP" (only 256x256 pixels).

 

Is there any better solution to create an image of the screen?

 

And I have another problem:

When the script is changing view (for instance from ISO to TOP) the screen doesn't get refreshed . As you can see from the script I use "Call RepaintScreen(True)" function. The refreshment is done only if I move the mouse cursor during the running of the script. You can imagine that every tume I run the script I move a mouse like mad all over the table.

 

I also noticed that this problem occurs with bigger models (>500 sufs) - with smaller models it works OK. Have you seen and/or solved any problem like this?

 

Here is the code:

 

 

code:

Public Function CreateImage(strGetpath1, FolderIrfan, strimage, strimage1, strimage2)

Dim strPathToConv

Dim strCnvtImage

Dim objFSO ' FSO object

Dim objWSHShell ' WSH Shell object

Dim objShell

Dim krneki

Dim iSeconds

iSeconds = 15

Set objShell = CreateObject("WScript.Shell")

Set objFSO = CreateObject("Scripting.FileSystemObject")

 

strPathToConv = FolderIrfan & "i_view32.exe "

' objShell.SendKeys "{F9}"

'Call RunMastercamCommand("OnHideToolpath")

 

Call SetBackGroundColor(mcCOLOR_WHITE)

SetGViewNumber(mcVIEW_ISO) ' Isometric view

Call RepaintScreen(True) ' Repaint screen

Call RunMastercamCommand("OnScreenFit")

Call Nap(iSeconds) ' Slow down processing a bit - it works better

' I use a method of pinging?!

Call RepaintScreen(True) ' Another repaint

ClearMenuAndPrompts

Call RunMastercamCommand("ToClipboard") ' Save screen to clipboard

objShell.SendKeys "{ESC}" ' Hit the Escape button

Call Nap(iSeconds)

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

Set objWSHShell = CreateObject("WScript.Shell")

objWSHShell.Run strCnvtImage, 0, True ' runing Irfan executable for converting the image

' Call ShellAndWait (strCnvtImage, False) ' runing Irfan executable

 

SetGViewNumber(mcVIEW_TOP) ' Top View...

RepaintScreen(True)

Call RunMastercamCommand("OnScreenFit")

RepaintScreen(True)

ClearMenuAndPrompts

Call Nap(iSeconds)

Call RepaintScreen(True)

Call RunMastercamCommand("ToClipboard")

objShell.SendKeys "{ESC}"

Call Nap(iSeconds)

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

Set objWSHShell = CreateObject("WScript.Shell")

objWSHShell.Run strCnvtImage, 0, True

' Call ShellAndWait (strCnvtImage, False)' runing Irfan executable

 

SetGViewNumber(mcVIEW_FRONT)

 

Call RepaintScreen(True)

Call RunMastercamCommand("OnScreenFit")

Call Nap(iSeconds)

Call RepaintScreen(True)

ClearMenuAndPrompts

Call RunMastercamCommand("ToClipboard")

objShell.SendKeys "{ESC}"

Call Nap(iSeconds)

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

Set objWSHShell = CreateObject("WScript.Shell")

objWSHShell.Run strCnvtImage, 0, True

'Call ShellAndWait (strCnvtImage, False)' runing Irfan executable

 

Call SetBackGroundColor(mcCOLOR_BLACK)

SetGViewNumber(mcVIEW_ISO)

Call RepaintScreen(True)

 

Set objShell = Nothing

Set objFSO = Nothing

Set objWSHShell = Nothing

End Function

 

 

'///////////////////////

'// FUNCTION

'///////////////////////

 

function Nap(iSeconds)

Const DEF_LOCALHOST_IP = "www.microsoft.com"

Dim objShell, pingstring

' Create a Shell object

Set objShell = CreateObject("Wscript.Shell")

pingstring = "ping -n 1 -w " & iSeconds & " " & DEF_LOCALHOST_IP

objShell.Run pingstring, 0, True

Set objShell = Nothing

End function


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