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:

VB Script to do some NCI stuff


Recommended Posts

This script might be "Rekd specific", but mayhaps some others do things the way I do, so I thought I'd share..

 

Here's what it does.. (read script comments as for "why" it does this..

 

Read all the NCI destinations on a file and store them in an array. Change the NCI's to match the MC9 name. Post that file to a specified post. Restore all the original NCI's, and restore the post.

 

code:

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

'//

'// Author: Matt Finley [email protected]

'// Date: 06/05/2004 09:16 AM

'// File Name: SavedNCI.vbs

'//

'// Description: Changes all NCI destinations to match file name, posts that

'// file with the specified post, then changes the NCI and post

'// back to originals.

'//

'// Why?: I program parts to run complete, multiple operations on a

'// single load. With up to 6 different operations on complex 4 axis

'// parts, it's often easier to do the setup using just one view/op

'// at a time. Then when the whole part is done, combine the programs

'// and run it as a single program. (PITA) I like to keep the integrety of

'// the seperated programs, with the seperate NCI destinations.

'// This script will do that, allowing me to structure my ops

'// effeciently for setup AND production runs. The script will also

'// change the post to the one specified, then revert back to the

'// original post.

'//

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

 

 

Const DEF_POST1 = "HAAS VF3 POST 4AXIS PRE-STAGE.PST" ' Post to use

Dim MC9Path, NCIPath

Dim aryDest() ' holds NCI Paths until finished posting

Dim i ' counter

Call WriteString("Storing original NCI destinations..")

NCIPath = GetCurrentFileName() ' Set NCI to current MC9 file name

 

' -- Grab all the NCI destinations and store them

ReDim aryDest(GetOperationCount("")) ' Set array's size to number of ops

For i = 1 To GetOperationCount("") ' Cycle thru ops

arydest(i) = GetNciNameFromOperationID("", i) ' Store orignial NCI path

Call SetNciNameFromOperationID(i, NCIPath) ' Set new NCI path

Next

 

Call WriteString(" Done.")

 

Call Main() ' Post it!

 

' --Return NCI destinations to the originals

Call WriteString("Restoring original NCI Destinations...")

For i = 1 To GetOperationCount("") ' Cycle thru ops

Call SetNciNameFromOperationID(i, arydest(i)) ' Retrieve original NCI path from array and apply

Next

 

Sub Main()

Dim strPath

Dim strCurrentPost

MC9Path = GetPathFromExtension("MC9")

If Not IsDrawing Then

ShowString "Umm.. how about you open up a file first? " & vbCrLf & vbCrLf & "Duh."

Exit Sub

End If

' -- Store current post

strCurrentPost = GetPostName

' -- Post to MC9's path

strPath = mc9path

If strPath = Null Then Exit Sub

Call SetPostName(DEF_POST1)

Call RunPostAll(strPath, False)

' -- Revert back to original post

Call SetPostName(strCurrentPost)

End Sub

 

Function IsDrawing()

Dim Ret

Ret = StartDBSearch(mc_alive, -1)

IsDrawing = Ret

End Function

'Rekd

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