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:

Vbscript mastercam


Recommended Posts

Start by looking in C:\Program Files\mcamX_\help. There is a file called 'SCRIPT56.chm' that is a compiled help file for VBScript. It gives you information about the language, available functions, and so forth. (replace 'mcamX_' with your version, example; mcamX8)

 

Then look in "Shared mcamx8" (or your current version, for the 'vb' folder. There are about 30 default VBScript files that mastercam ships with, to do all sorts of different things. They mostly exist as examples and "starting points" for you to develop the script into something that is useful for you.

 

You mention creating "macros". Do you mean that you want to automate various tasks inside Mastercam, or are you trying to code Macro B statements into your NC code? These are both important, but very different requests. You might also be referring to "Subprograms" which are sequences of NC code blocks that get repeatedly called, in order to reduce the size of a NC program...

Link to comment
Share on other sites

Thank you all!!!

i had try this :

 

call Main()
 
Sub Main()
Dim strInputFile : strInputFile = "c:\Temp\prova.operations-8"
Dim intOpNumber : intOpNumber = 1
Dim strComment : strComment="Test"
Dim objOverRide
Set objOverRide= New McOverride
objOverRide.DepthOn = False
objOverRide.FeedRateOn = False
objOverRide.FeedRatePercentOn = False
objOverRide.SpindleSpeedOn = False
objOverRide.SpindleSpeedPercentOn = False
 
Dim blSuccess
blSuccess=AskForChain("Select a chain")
Dim intOpID
intOpID = MakeOperationFromID(strInputFile, intOpNumber, strComment,objOverRide)
 
End Sub
 
but i want to remove the "AskForChain("Select a chain")" and import the operation without input a geometry:how do this?
I try to look Visual Basic .NET NET-Hooks, but on the mastercam.com i have not found the documentation.
Thank you for help
Link to comment
Share on other sites

Hi ,there is any way to import with vbs script , a group of operation automatically (drill and mill operation)?

For example ,i save n.3 operations in a file .operation-8 and with a vb script i import automatically this n.3 operations.

Is it possible?how to?

Thank you

Link to comment
Share on other sites

I found an old VBScript that I modified to import a pocket operation, two contour operations and a drilling operation. The attached zip file contains Mastercam X8 files, one drawing with operations and one without, a VBScript and a router operations library.

 

  • Place the operations library in \Users\Public\Documents\shared mcamx8\router\OPS
  • Place the ToolpathDoor.vbs script in \Users\Public\Documents\shared mcamx8\vb
  • Place the drawings anywhere
  • Open the drawing door_clean.mcx-8
  • Run the script, Settings->VBScript and select the ToolpathDoor.vbs

 

Once the VBScript has completed the drawing will have a rough pocket and a finish contour operation applied to the inside contour, a counter operation around the outside contour and 4 holes drilled. this should be enough to get you going in the right direction.

VBScript_ImportOperations.zip

Link to comment
Share on other sites
hello, I have a request about the example "door" that you sent me.

I tried to want to realize two drill operations .Il problem is that if I have two holes for the first operation and five for the second operation, the second realizes seven.Come can I do for resetting the number of points in the drilling for the operation next?Even if I change the active layer and visible, it seems to keep in mind all the points previously recognized.

thanks for your help and see you soon

Link to comment
Share on other sites
Good morning, I solved the selection of the drill holes, including introducing a sub and the other, the function zeropts (), which effectively resets the points list for drilling active.however, i have another problem I can not solve: you know tell meIt is structured as a thread milling operation?

Thanks for your help

see you soon

Link to comment
Share on other sites

Thank you , i wait your news.

Best regards

 

The VBScript API was released with Mastercam Version 9 more than 10 years ago and unfortunately the Thread Mill operation support was never implemented. If you absolutely need the Thread Mill operation functionality then I would recommend you create Visual Basic.NET NET-Hook as Thread Mill operations are supported. There is a getting started document and example projects at Mastercam.com, you will also need to use the free Visual Studio Community Edition if you do not have Visual Studio installed.

Link to comment
Share on other sites
Good morning, I tried to connect to the site, registering a new account, but the site will not let me access the samples relative to N-Hook.

Come I can find documentation and examples to try to get started?

You have the opportunity to pass me the material or authorize me to access that area?

Thank you and have a nice day

Link to comment
Share on other sites

 

Good morning, I tried to connect to the site, registering a new account, but the site will not let me access the samples relative to N-Hook.
Come I can find documentation and examples to try to get started?
You have the opportunity to pass me the material or authorize me to access that area?
Thank you and have a nice day

 

 

You should be able to login once registered, please post on our official forums at mastercam.com so that the webmaster can record it and address it for you, thanks.

Link to comment
Share on other sites
Good morning, I was able to access the contenuti.I not found examples on how to build a program.I would be able to create macros that can import existing sequence, in a new program, automatically selecting the existant geometry .Where I can find examples that could explain the syntax and methodology of NET-Hook? I understand that vbscript is limited in features.

Thanks and best regards

Link to comment
Share on other sites

 

Good morning, I was able to access the contenuti.I not found examples on how to build a program.I would be able to create macros that can import existing sequence, in a new program, automatically selecting the existant geometry .Where I can find examples that could explain the syntax and methodology of NET-Hook? I understand that vbscript is limited in features.
Thanks and best regards

 

 

To get started go here and download the Introduction to VB.NET NET-Hooks document as this will explain step by step how to start developing NET-Hooks with Visual  Studio Community Edition 2015. Once you have set that up and working I recommend you open all the project examples and step through them to become familiar with the NET-Hook API and from there you should be able to get started. If you require additional help please post questions here

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

I recently stumbled onto the vbscript possibility, I have down loaded and read through the documentation and examples I could find, I need to know if it is possible to call all of the menu items to allow a complex series of comands to be scripted to allow semi automated creation of geometry for a surface of rotation generated from a segment of an elips. if it is possible to do this, where might I find examples of calls to functions such as CREATE-ELIPS  and CREAT-SURFACE-REVOLVED

Link to comment
Share on other sites

I recently stumbled onto the vbscript possibility, I have down loaded and read through the documentation and examples I could find, I need to know if it is possible to call all of the menu items to allow a complex series of comands to be scripted to allow semi automated creation of geometry for a surface of rotation generated from a segment of an elips. if it is possible to do this, where might I find examples of calls to functions such as CREATE-ELIPS  and CREAT-SURFACE-REVOLVED

 

// Run almost any Mastercam command - this gives access to every function

// that is  in the mastercam.ft file. The input character ‘codes’ are listed in the Mastercam.tt file following the function cpp command.

Void RunMastercamCommand(String)    (Input: character ‘code’ for each function)

 

A list of commands are located in your Mastercam.FT file (Mastercam root directory), have a scan through the list to see if what you need it available.

 

For example:  Call RunMastercamCommand("create_ellipse")

 

FUNCTION CPP "create_ellipse"
SPNG 10425
LPNG 10426
TIP 5854
INTERRUPT_INLINE
FCAT  "Geometry"
FNAME "Ellipse"
END_FUNCTION
Link to comment
Share on other sites
  • 11 months later...

Mick,

 

  I would like to run a script that executes an .exe then resumes the script of importing an operation into the current  MC9 file and applying the imported toolpath to preselected points.  I tried following your ToolpathDoor example and do not understand the MakeOperationFromName logic....particularly after the Then keyword. Documentation says function returns operation ID# or  mcOPERATION_INVALID . When I run your sample script, everything works.

 

If MakeOperationFromName(operationsLibrary,DEF_OP_INSIDE_ROUGH_POCKET,DEF_OP_INSIDE_ROUGH_POCKET, overrides) <> mcOPERATION_INVALID Then

       ' *******************************************************

       ' * Import Operation and apply our finish contour routine

       ' *******************************************************

Else

      ShowString "Could not apply " &  DEF_OP_INSIDE_ROUGH_POCKET & " operation"

      Call Init

      Exit Sub

End If

 

 

 

    When I run the script below, notepad pops up and execution pauses until I close notepad as intended but then I get the "could not apply toolpath". If I understand the inputs, the 1st arg is the .operation-9 filename that I exported out to a library directory, then the operation name, then the comment. What am I missing? The script below is informal and was meant to just test out concepts and logic.

 

Thanks, JCDFCM

 

 

'//   Description:   Test calling up an executable then import an operation

'//                  and modify it's feed, speed, and op comment.

'//      Comments:   Using version X9 

 

' Constants

Public Const DEF_NOTEPAD = "C:\test\notepad.exe"

 

Const OP_FILE = "C:\test\Threadmill_Jc.operations-9"

Const OP_NAME = "Thread Mill"

Const OP_COMMENT = "Threadmill 1/4-20 3x"

 

' Start Script

Call Main()

 

Sub Main()

 

Dim FSO, strShell, overrides

  

Set FSO = CreateObject("Scripting.FileSystemObject")

strShell = DEF_NOTEPAD

 

Call ShellAndWait (strShell, True

 

Set overrides = New McOverride

 

With overrides

       .FeedRatePercentOn = False

       .FeedRate = 80

       .SpindleSpeedPercentOn = False

       .SpindleSpeed = 80

End With

  

If MakeOperationFromName(OP_FILE,OP_NAME,OP_COMMENT, overrides) <> mcOPERATION_INVALID Then

      '???

Else

   ShowString("Could not apply Threadmilling toolpath")

End If

 

    

' -- Clean up

Set FSO = Nothing

 

End Sub 

Link to comment
Share on other sites

Mick,

 

  I selected a point and ran the script with no luck...double checked the op filename and operation name inputs as well...still no luck. The VBScript help says it imports an operation by name and applies it to the currently selected points or chains. Any suggestions to try would be greatly appreciated.

 

Thanks, JCDFCM

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