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:

Mastercam VB Script Function Question


Recommended Posts

I am new to mastercam and looking for ways to create setup sheets and tool lists.

 

I tried the sample VB Script "GETJOBINFORMATION.VBS" but it did not report all values.

 

I need the GetToolDiameterOffsetNumber(ToolNumber) function but it returns only zero.

 

The GetToolName(ToolNumber) function returns "TOOL N/A".

 

I think these values are in my .MCX file because they output in my post.

 

I have included sample code below, what am I doing wrong?

 

My reseller says they do no support VB and to try posting here.

 

Thanks

 

Call Main()

 

Sub Main()

'Dim intOperations, intOpCount,

Dim nOpID

Dim ToolNumber

Dim tdon

Dim tnam

 

 

' get the id of the first operation

nOpID = GetFirstOperationID("")

 

Do

' get the tool number using the current operation

ToolNumber = GetToolNumberFromOperationID("", nOpID)

ShowString(nOpID & " ToolNumber: " & ToolNumber)

 

tdon = GetToolDiameterOffsetNumber(ToolNumber) 'Get the tool diameter offset number of a tool

ShowString(nOpID & " Tool Diameter Offset Number: " & tdon)

 

tnam = GetToolName(ToolNumber)'Get the tool file name of a tool

ShowString(nOpID & " Tool Name: " & tnam)

 

nOpID = GetNextOperationID() ' get the next operation's id

Loop While(nOpID <> -1)

 

End Sub

Link to comment
Share on other sites

Our dealer contacted Mastercam. Their response is below.

 

_______

I did a quick look at this and it appears that this is a bug in the VBScript API in Mastercam.

If you run this script on a part file with multiple operations it will report the correct information on all of the operations, except for one.

(I get the same result with X4-MU3 as I do with X5)

 

For your reference, this issue has been logged as #00088663

_____________

 

Thanks

Link to comment
Share on other sites

FYI...

 

The issue in the script code you posted is really within these (2) functions ->

GetFirstOperationID

GetNextOperationID

 

 

The GETJOBINFORMATION.VBS does not use these functions, as it iterates thru the operations using a different method -

which works, except there is a minor bug in that vbs! :angry:

 

To correct GETJOBINFORMATION.VBS, change this "For" statement to read ->

 

' -- Iterate all operations

For intOperations = 0 To intOpCount-1

 

You should be able to use the same logic for looping thru the operations used in GETJOBINFORMATION.VBS in your Script. ->

 

' -- Get operation count

intOpCount = GetOperationCount(vbNullString)

' -- Iterate all operations

For intOperations = 0 To intOpCount-1

'Do whatever...

Next

Link to comment
Share on other sites

Thank you for replying...

 

I adjusted the loop counter to start at zero as you mentioned.

I changed the operation number display to start at 1.

 

I loaded a mill .MCX file and GetJobInformation.vbs worked with the corrections you mentioned.

 

I do get the problem with my lathe .MCX files.

 

When using a lathe .MCX file the tool numbers and operation comments display correctly.

 

The remaining values however do not display correctly for a lathe.

 

I was able to add case statements to catch the lathe operation types.

 

I would appreciate you pointing me in the right direction.

 

Thanks again

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

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