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:

Feedback wanted - Mastercam VBScript


Recommended Posts

quote:

So my question to you guys, would you be interested in a Mastercam VBScript class? What would you like to see covered in a class? What areas of Mastercam VBScript interest you?


Very inerested . Can't really answer the other questions because of not knowing VBScript, but to be able to create bases like you said earlier from scratch is very interesting to me. Maybe ejector pins with clearances in them to our standards. SHCS clearances and locations? What are the possibilities? Anything to be more efficient would be great.

 

Rob

Link to comment
Share on other sites
  • Replies 67
  • Created
  • Last Reply

Top Posters In This Topic

pimij

 

The list of functions in the vbscript help file is what is currently available. Having said that you can always call the RunMastercamCommand() function within a script if a menu function is not available via vbscript, the downside is that user interaction is required.

 

We do listen to user requests for increased functionality for vbscript so I encourage you guys to e-mail your function requests to [email protected].

 

[ 10-30-2003, 05:25 PM: Message edited by: Mick from CNC Software, Inc. ]

Link to comment
Share on other sites
Guest CNC Apps Guy 1

How about this???

I want to create a VB Script to delete all non tool path referenced entities? This is one that I REALLY want the ability to do. I've been casually perusing the functions and so far I'm coming up empty handed.

 

Any ideas???

Link to comment
Share on other sites

James !

 

It is IMHO not simple and dangerous idea .

 

You will have many problems even with surfaces ,

and there are solids .

Too many checkings if this geometry basic for this solid ,or this trimmed surface built using ...

 

Better and safer to blank them !

 

Sorry for the possible offence

Link to comment
Share on other sites
Guest CNC Apps Guy 1

No offense taken.

 

I don't mind deleting that stuff. Some of the parts I have to mirror are so complex that they bomb out Mastercam when I mirror them and Toolpaths Transform Mirror does not work EXACTLY the way I need it to.

Link to comment
Share on other sites

We're still mainly a v8 shop and only a few of us have v9 right now. I'm waiting for the final push the get the last of our seats over to 9. That being said, I already have requests for the 'Save with backup" vbs from our designers. Also I plan on using the mulitpost vbs. I already have it tweaked in and running for out setup. Again just waiting to get to 9.

 

I'd like to have/create a standard parts library that our designers could run. The scripts would ask for variables like length, size, number of holes, etc depending on the part and then draw it for them. I believe somebody else is doing something similar with doors? One of our designers in teaching himself vbscript and I think I could create a few script to start him off and he could take the creation and maintenance over from there.

 

Haven't though much beyond that. I'm still more comfortable with chooks. And with 30+ years behind the C language I find if I have a problem usually somebody has already wrote a library/program for it, or wrote something close enough I can adapt it, or some phd student had written a paper (with algorithm) about it, and so on... (god bless open source). I find I usually have more problems with the limitation of the Mastercam SDK than with the language itself. frown.gif

 

Bryan smile.gif

Link to comment
Share on other sites

Mick,

 

In the old days when I was teaching SmartCAM and Mastercam, I liked the functionality of the macro programming language in SmartCAM. It was easy to create a dialog box for data input and manipulate the execution of the macro on it's own or through the post.

 

Being a Mastercam reseller, we continually get requests for some sort of customization or optimized functionality for customers and the knowledge of VbScript would be tremendous.

 

My question would be the following: I've done my share of Basic, Fortran, Turbo-Pascal and SmartCAM macro programming but nothing compared with the VBS examples I've looked at.

 

In your opinion, how long does it take to be able to write a basic VB script with a customized dialog box for user input of variables?

 

I would also be interested in a class!

 

Luc

Link to comment
Share on other sites

Luc,

 

With your background you should be able to hit the ground running with vbscript, however, where it gets a little more complicated is designing dialogs to use with your scripts. I create my dialogs with either VB6 ActiveX DLL's or VB.NET .EXE's and call them from my scripts. With this approach you can design very rich dialogs to display, format and accept user data that can be passed back to your scripts. If you use a DLL you can expose properties that can pass data directly back to your scripts otherwise an intermediate file can be used, e.g., text, access database, excel, etc., that the script can query once the dialog exits. It sounds more complicated than it is, honestly biggrin.gif

 

If you are only looking to prompt a user for a couple of values, say a part width and height, you can prompt the user from Mastercam's status area using the AskString() function.

 

There is a VB6 project example installed under your mcam9VB folder and I uploaded a VB.NET exe solution to the ftp site here. If anyone has written a Delphi, C++ or some other project that they are using for their dialogs I'd love to see them.

Link to comment
Share on other sites

So let me ask this.....Machine tubesheets here and at this time we are drilling them on two Okuma mills and with their IMAP programming it makes it pretty simple to program the pattern. Although if I want to do these on lets say our Integrex it gets a little more complicated. We do some tubesheets that have in excess of 600 holes and that would be alot of sequences in Mazatrol and would take me forever in Mastercam. Could I write a VB script that would create a variable grid that I could snap to? The holes are usually on a .500 or a .625 triangular pitch and do not always start at the same distance from 0,0.

Link to comment
Share on other sites

Mick, I browsed through this thread. I have created a few ultra basic (ranging 10 to 50 lines) scripts to do a few things. definately need more practice. I have had a lot of interest in using vbscripts to create setup sheets, more infot needs to be available for that to work. Something I personally would like is an easy way to do dialogues. Will the next version of Mastercam's vb support dialogue boxes? A serious place for this for me is to have a dialogue box pop up when I post out code, the timing or place that it pops up would need to be in the post. This could be used for many things but for me I have setup several posts to do probing. It sure would be nice to have a dialogue box instead of 20 prompt questions. Another place a dialogue box would be useful is after the tooltable has been created. Many people want to have a "generic" Mastercam file. When you post this code out they would like to be able to establish feeds and speeds based on which machine it will be running on. Currently it is done at each toolchange with a prompt question. If I had a dialogue the possibilities are endless. So far it is a great feature and I'm sure will only get more powerful.

 

 

Thanks for asking

Link to comment
Share on other sites

Mick !

You guys are great ,especially cause you want to

know the customers input . cheers.gifcheers.gif

I am using VBscript for autobackup but not writing them myself ,

may be in future .

Please ,be so kind to read this thread and can you tell your personal relation to it ????!!????

 

Iskander teh GIVE ME A POSSIBILITY TO USE EVEN ONE ONLY VARIABLE INSIDE OPERATION MANAGER!!!

 

Link to comment
Share on other sites

plasttav, bryan314

 

There is a way to do a little of what you asking using operations are stored in your OP9 libraries.

 

Let’s say you have created a pocket operation for an inside contour, it contains all the relevant settings, depth, speed, feed and so on, you give it a operation comment of "INSIDE CONTOUR" and save it to your MYOPS.OP9 library. Now this pocket operation is used for a number of different parts where the only difference is the final depth and perhaps the speeds and feeds but other than that it’s the same. What you can do with the script function MakeOperationFromName() is apply that pocket operation to your chains, the function also allows you to over-ride the final depth and set a percentage of the operations original speed and feed and apply that operation exactly as you would do if manually creating the operation. A typical script to do this might look something like the following;

 

code:

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

'//

'// Author: Mick George [email protected]

'// Date: 28/10/2003 03:28 PM

'// File Name: Toolpath Door CHook.vbs*

'//

'// Description: Run Door CHook, create <style> door, set level 1 INSIDE and level 2 OUTSIDE

'// then create one door, exit chook. Create your operations and save them to

'// DOOR.OP9 And run this script

'//

'// Comments: You don't need to create a door, this script can apply to any drawing that has

'// two inside pocket operation and an outside contour.

'//

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

 

 

'///////////////// My Constants /////////////////

'

' -- Operations library

Const DEF_OPERATIONS_LIB = "DOOR.OP9"

'

' -- Operation comments for each operation saved

Const DEF_OP_INSIDE_ROUGH_POCKET = "INSIDE ROUGH POCKET"

Const DEF_OP_INSIDE_FINISH_CONTOUR = "INSIDE FINISH CONTOUR"

Const DEF_OP_OUTSIDE_CONTOUR = "OUTSIDE CONTOUR"

'

' -- Level numbers

Const DEF_INSIDE_LEVEL = 2

Const DEF_OUTSIDE_LEVEL = 1

 

 

' -- Start Script

Call Main()

 

 

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

' Sub Declaration

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

Sub Main()

 

Dim strPathToOP9, ovOverRides

 

If Not IsDrawing Then ShowString "We need a drawing!": Exit Sub

 

strPathToOP9 = GetPathFromExtension("OP9")

 

strPathToOP9 = AddBackSlash(strPathToOP9) & DEF_OPERATIONS_LIB

 

' -- If you want to over-ride the operations depth now is the time...

Set ovOverRides = New McOverride

 

With ovOverRides

 

.DepthOn = True ' -- Override operation depth?

.Depth = -.125 ' -- New depth If DepthOn = True

.FeedRatePercentOn = True ' -- New feed rate Is a percentage?

.FeedRate = 80

.SpindleSpeedPercentOn = True ' -- New spindle speed Is a percentage?

.SpindleSpeed= 80 ' -- New spindle speed If SpindleSpeedOn = True

 

 

End With

 

Call GetReady

 

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

' * Chain all entities on our inside level

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

If ChainAll(True, False, DEF_INSIDE_LEVEL, vbNullString ) Then

' -- Apply our rough pocketing routine

If MakeOperationFromName(strPathToOP9,DEF_OP_INSIDE_ROUGH_POCKET,DEF_OP_INSIDE_ROUGH_POCKET, ovOverRides) <> mcOPERATION_INVALID Then

' -- Apply our finish pass

If MakeOperationFromName(strPathToOP9,DEF_OP_INSIDE_FINISH_CONTOUR,DEF_OP_INSIDE_FINISH_CONTOUR, ovOverRides) <> mcOPERATION_INVALID Then

' -- Ok to go

Call GetReady

Else

ShowString "Could not apply " & DEF_OP_INSIDE_FINISH_CONTOUR & " operation"

Call GetReady

End If

Else

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

Call GetReady

Exit Sub

End If

 

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

' * Chain all entities on our outside level

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

If ChainAll(True, False, DEF_OUTSIDE_LEVEL, vbNullString) Then

' -- Apply our outside contour routine

If MakeOperationFromName(strPathToOP9,DEF_OP_OUTSIDE_CONTOUR,DEF_OP_OUTSIDE_CONTOUR, ovOverRides) <> mcOPERATION_INVALID Then

' -- Clear all

Call GetReady

Else

ShowString "Could not apply " & DEF_OP_OUTSIDE_CONTOUR & " operation"

Call GetReady

Exit Sub

End If

Else

ShowString "Could not chain outside level"

End If

 

 

Else

ShowString "Could not chain inside level"

End If

 

 

 

End Sub

 

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

' Function Declaration

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

 

Function IsDrawing()

 

Dim Ret

 

Ret = StartDBSearch(mc_alive, -1)

 

IsDrawing = Ret

 

End Function

 

 

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

' Sub Declaration

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

Public Sub GetReady

 

Call FreeChains

Call UnselectAll

Call RepaintScreen(True)

 

End Sub

 

 

 

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

' Function Declaration

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

 

Function AddBackSlash(sPath)

 

If Right(sPath, 1) <> "" Then sPath = sPath & ""

AddBackSlash = sPath

 

End Function

Link to comment
Share on other sites

Mick:

Thanks for starting this thread. I hope it gets us all riled up. I too would like to make use of this feature, as many others have stated, but just have not jumped into it yet. I'm so new to learning Mastercam itself that it may be a while yet before I can devote much time to learning scripting. Maybe some others are in the same boat.

The fact that I used to write all sorts of programs in plain old BASIC....is that gonna hurt me or help me?. I could whip you up most anything right now in BASIC but don't have a clue as to how to do anything in Visual Basic. Are there similarities or do I need to totally rethink?

PBpaul

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