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:

VBS Script for Multi Posts


Recommended Posts

Mick probably has something for you, but taking what you have so far, you may want to read each company name and number into arrays like this:

 

code:

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

'//

'// Author: Mick George [email protected]

'// Date: 16/09/2003 12:58 PM

'// File Name: MULTIPOST.VBS

'//

'// Description: Posts drawing to two (edit: 7) defined posts

'//

'// Comments: cvb (23/07/2004): modified for connormac
;)

'//

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

 

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

Public Const DEF_CNAME_PROMPT = "Company Name?"

Public Const DEF_PI_PROMPT = "PI Number?"

 

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

Dim arrPosts(7)

Dim arrCNCs(7)

 

 

' -- Start Script

Call Main()

 

 

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

' Sub Declaration

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

Sub Main()

Dim strCurrentPost ' the current post

Dim arrCompanyName(7) ' array of Company Names

Dim arrPI(7) ' array of PIs

Dim iCount ' index counter

Dim strCurrCNC ' the path of the current NC code

 

 

' init

Call InitArrays()

iCount = 0

 

Do 'ask 7 times

' prompt for company name

arrCompanyName(iCount) = AskString(DEF_CNAME_PROMPT)

 

' prompt for PI number

arrPI(iCount) = AskString(DEF_PI_PROMPT)

 

' increment the index counter

iCount = iCount + 1

Loop While (iCount < UBound(arrCompanyName))

 

 

If IsDrawing Then ' this is a valid file

' -- Store current post

strCurrentPost = GetPostName

 

For iCount = 0 to UBound(arrCompanyName) - 1

' get the post

Call SetPostName(arrPosts(iCount))

 

' assemble the NC path

strCurrCNC = "C:" & arrCompanyName(iCount) & "" & _

arrPI(iCount) & "" & arrCNCs(iCount)

' post it

Call RunPostAll(strCurrCNC, False)

Next

 

' -- Set mc back to original post

Call SetPostName(strCurrentPost)

End If

End Sub

 

 

' Purpose: initialize the global post and CNC arrays

Sub InitArrays()

' posts

arrPosts(0) = "OP_KH.pst"

arrPosts(1) = "550_KH.PST"

arrPosts(2) = "1000_KH.PST"

arrPosts(3) = "Okuma_KH.PST"

arrPosts(4) = "V30_KH.PST"

arrPosts(5) = "V40_KH.PST"

arrPosts(6) = "760_KH.PST"

 

' CNCs

arrCNCs(0) = "OP"

arrCNCs(1) = "550"

arrCNCs(2) = "1000"

arrCNCs(3) = "Okuma"

arrCNCs(4) = "V30"

arrCNCs(5) = "V40"

arrCNCs(6) = "760"

End Sub

 

 

Function IsDrawing()

Dim Ret

 

 

Ret = StartDBSearch(mc_alive, -1)

 

IsDrawing = Ret

End Function

Whipped this up quick, but this will prompt for company and PI seven times. Depending on what you need, this can be optimized so that it uses dynamic arrays (via ReDim) that doesn't lock you into 7 iterations. But if you always do 7, this would do the trick.

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