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:

Pending VBScript Update Information


Recommended Posts

Guys,

 

CNC Software appreciates all your suggestions, requests and support that you have given us since implementing VBscript in Mastercam.

 

Here is a listing of new functions, changes, fixes, etc to our VBScript functionality in Mastercam. We anticipate release of this update shortly, stay tuned.

 

code:

=============

NEW FUNCTIONS

=============

GetCPlaneNumber

SetCPlaneNumber

GetTPlaneNumber

SetTPlaneNumber

GetCPlaneEqualGView

SetCPlaneEqualGView

SetLevelVisibleByNumber

SetLevelVisibleByName

SetBackGroundColor

GetBackGroundColor

DoBitmapfile

GetNestedSheetCount

MakeNestedSheetBMP

GetOperationTypeFromName

GetGViewNumber

SetGViewNumber

DeleteAllEntities

DeleteEntity

GetToolLength

GetToolFluteLength

GetToolOffsetNumber

GetJobSetupMaterial

GetJobSetupStockSizeX

GetJobSetupStockSizeY

GetJobSetupStockSizeZ

GetJobSetupStockOriginX

GetJobSetupStockOriginY

GetJobSetupStockOriginZ

GetNciNameFromOperationID

SetNciNameFromOperationID

GetToolComment

GetToolNumberFromOperationID

GetToolName

MakeOperationFromID

GetOperationNameFromID

GetOperationTypeFromID

SetContourOperationSideFromName

GetContourOperationSideFromID

SetContourOperationSideFromID

GetNciMinZFromOperationID

GetNciMaxZFromOperationID

FormatValue

GetOperationIDFromSheet

RunMastercamChook

mc_appmodule

mc_applevel

mc_appversion

 

 

 

 

 

=============

NEW CONSTANTS

=============

mcVIEW_TOP

mcVIEW_FRONT

mcVIEW_BACK

mcVIEW_BOTTOM

mcVIEW_SIDE

mcVIEW_LSIDE

mcVIEW_ISO

mcCPLANE_3D

mcTPLANE_OFF

mcTITLE

mcBACKSLASH

mcPERIOD

mcOPERATION_CONTOUR

mcOPERATION_POCKET

mcOPERATION_DRILL

mcOPERATION_ROUTER_CNTR

mcOPERATION_ROUTER_POCK

mcOPERATION_ROUTER_CUTOFF

mcOPERATION_ROUTER_BLOCK_DRILL

mcOPERATION_SRF_RGH_PARALLEL

mcOPERATION_SRF_RGH_RADIAL

mcOPERATION_SRF_RGH_PROJECT

mcOPERATION_SRF_RGH_FLOWLINE

mcOPERATION_SRF_RGH_CONTOUR

mcOPERATION_SRF_RGH_POCKET

mcOPERATION_SRF_FIN_PARALLEL

mcOPERATION_SRF_FIN_RADIAL

mcOPERATION_SRF_FIN_PROJECT

mcOPERATION_SRF_FIN_FLOWLINE

mcOPERATION_SRF_FIN_CONTOUR

mcOPERATION_SRF_FIN_PENCIL

mcOPERATION_SRF_FIN_LEFTOVER

mcOPERATION_SRF_FIN_STEEP

mcOPERATION_SRF_FIN_SHALLOW

mcOPERATION_SRF_FIN_CONSCALOP

mcOPERATION_SRF_RGH_PLUNGE

mcOPERATION_SRF_FLOW5AX

mcOPERATION_SRF_4AX

mcOPERATION_MERGED_NCI

mcOPERATION_5AX_SWARF

mcOPERATION_5AX_ROLLDIE

mcOPERATION_FACE

mcOPERATION_5AX_MSURF

mcMILL_EXE

mcLATHE_EXE

mcWIRE_EXE

mcDESIGN_EXE

mcDRAFT_EXE

mcROUTER_EXE

mcAPPLEVEL_ENTRY

mcAPPLEVEL_1

mcAPPLEVEL_2

mcAPPLEVEL_3

 

=============

FIXES

=============

DoMetafile works as expected

RunPostAll works as expected

SaveMCAs saving thumbnail works as expected

Reading/Writing to CArc.VIEW works as expected

mcCHAIN_CCW/mcCHAIN_CW fixed, values were wrong

 

=============

CHANGES

=============

Many 'GetTool*' functions now take TOOL NUMBER in place of TOOL ID

Changed SaveMC() now a function that returns true/false

AskYesNo() now returns mcMSG_YES/mcMSG_NO

 

=============

OTHER

=============

Option Explicit automatically added to your scripts (internal to chook)

Can't execute a script while another is running.

Link to comment
Share on other sites

ayup. I've held off messing with my HTML setup sheet any further (still couldn't get the formatting right) until the new VBscript stuff comes out. Then of course, I'll have to follow through with learning VBscript. I >think< one can send the information to WORD, if I understood the book I was reading right. That would save us a step.

 

John

Link to comment
Share on other sites

John T,

 

Here's a quick example.

 

Tip: With any VBA enabled program, Word, Excel, AutoCAD, etc, open the program and then the VBA Editor and then press F2 to open the object browser, select the program from the drop down list to see all the methods and propeties available. I would recommend writing your code in the VBA editor for debuging purposes before porting over to VBS.

 

 

code:

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

'//

'// Author: Mick George [email protected]

'// Date: 07/12/2003 04:16 PM

'// File Name: Word.vbs

'//

'// Description: Open Word

'//

'// Comments:

'//

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

 

 

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

Const wdWindowStateMaximize = 1

Const wdAlertsNone = 0

 

'///////////////// My Global Variables //////////

 

 

 

' -- Start Script

Call Main()

 

 

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

' Sub Declaration

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

Sub Main()

 

Dim Word

 

On Error Resume Next

 

' -- Open word

Set Word = CreateObject("Word.Application")

 

' -- Ok?

If Err Then

ShowString "Could not get an instance of Word"

Else

' -- Got word so do something with it...

With Word

.Visible = True

.WindowState = wdWindowStateMaximize

.DisplayAlerts = wdAlertsNone

 

' -- Do something ....

 

End With

 

If askYesNo("Close Word?") =mcMSG_YES Then Word.Quit

 

End If

 

 

If IsObject(Word) Then

Set Word = Nothing

End If

 

 

End Sub

 

[ 12-08-2003, 07:17 PM: Message edited by: Mick from CNC Software, Inc. ]

Link to comment
Share on other sites

Just wanna share this after I looked at Mick's code.

 

code:

  

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

'//

'// Author: CAM Desciple w/script borrow from Mick
:)

'// Date: 12/08/2003 09:50 PM

'// File Name: Export Op to Word

'//

'// Description: Export a list of operation id and name to Word Document

'//

'// Comments: Just try to have some fun here. Fun's over when it work!

'//

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

 

'///////////////// My Global Variables //////////

Dim wordDoc

 

 

' -- Start Script

Call Main

 

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

' Sub Declaration

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

Sub Main()

Dim maxOpNum,numTool

Dim strOperName(), strOpID()

Dim i

 

On Error Resume Next

'create an instance of Word Application

Set wordDoc = CreateObject("Word.Application")

 

'check to see any problem

If Err Then

ShowString "Could not get an instance of Word"

'Show error description

ShowString "Error # " & CStr(Err.Number) & " " & Err.Description

Else

'create new document

wordDoc.Documents.Add

With wordDoc

.Visible = True

.WindowState = wdWindowStateMaximize

.DisplayAlerts = wdAlertsNone

.ActiveDocument.Words(1).Font.Size = 14

.ActiveDocument.Words(1).Bold = True

.ActiveDocument.Words(1).Text = "Your Company Name" & vbNewLine & "Op_ID" & vbTab & "Op Name" & vbNewLine

End With

'get operation number count

maxOpNum = GetOperationCount("")

' declare array size

If maxOpNum > 1 Then

ReDim strOperName(maxOpNum)

ReDim strOpId(maxOpNum)

End If

 

'get operation name

strOperName(0) = GetFirstOperationName("")

For i = 1 To maxOpNum

strOperName(i) = GetNextOperationName()

Next

 

'get op id

strOpId(0) = GetFirstOperationID("")

For i = 1 To maxOpNum

strOpId(i) = GetNextOperationID()

Next

 

'write to Word Document

For i=0 To maxOpNum-1

WriteToWord(" " & strOpId(i) & vbTab & vbTab &strOperName(i) & vbNewLine)

Next

 

If askYesNo("Close Word?") = mcMSG_YES Then Word.Quit

End If

 

'clean up, set word object to none

If IsObject(Word) Then

Set Word = Nothing

End If

End Sub

 

 

 

 

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

' Sub Declaration

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

Public Sub WriteToWord(strOutText)

Dim wordCounts

With wordDoc

wordCounts = .ActiveDocument.Words.Count

.ActiveDocument.Words(wordCounts).Bold = False

.ActiveDocument.Words(wordCounts).Font.Size = 12

.ActiveDocument.Words(wordCounts).Text = strOutText

End With

End Sub

If I can get hold of all the new API function, man, I can output a lot of information from MasterCAM...

 

The GetNextOperationID() and GetNextOperationName() seems to increment a global count and cannot call subsequently... can you veify this, Mick?

 

Please let me know if you have anything interesting to add to this script. I would like to learn more from you guys. Thanks

Link to comment
Share on other sites

quote:

The GetNextOperationID() and GetNextOperationName() seems to increment a global count and cannot call subsequently... can you veify this, Mick?

Correct. They go with GetFirstOper... blah blah and have to be done incrementally. This won't be a problem for long, though... wink.gif

 

'Rekd

Link to comment
Share on other sites

quote:

Yup, it's easy to automate Word, Excel or anyother Office program
(maybe not Visio)
using VBS.

I don't about about earlier versions of Visio, but with Visio 2003 ->

 

You can write programs to control Microsoft Visio in Microsoft Visual Basic for Applications (VBA), Microsoft Visual Basic, C++, or any programming language that supports Automation.

Link to comment
Share on other sites

quote:

Yeppers, looks like the .set files and html setup sheets may go the way of the dodo bird

Remember folks the information in the operations is not necessarily equal to what is output in a .set file. The values in an operation are just parameters used to generate the nci file. So there's a level or two of separation between the operation and the nc/doc/html file. You can and will get differences.

 

That being said, outputting all the data to a sheet is a great way to look at all the parameters in a operation. ie A great way to check that all the clearance planes are set correct without going through each and every operation in the op manager.

 

Bryan smile.gif

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