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:

Need Multipost VBscript advice


Recommended Posts

Good evening fellow forum members. I need some advice with a vbscript that post my operations to three different machines. Please see trodes_post.vbs on the ftp site in the vb_scripts folder. I altered this VBscript from Connormac's original. (Thank you Connormac!!! cheers.gif )

 

Currently, when I use the VBscript to post, it only posts in part of the Mastercam's filename. NOT the entire filename as I wish. For example, my current part is located in the following folder:

C:9999mfgetset3a

 

I want to post the programs in the following folder structure:

E:9999mfgetset3aBOSTOMATIC

E:9999mfgetset3aOKK

E:9999mfgetset3aMAZAK TRODE

 

But, as the VBscript is currently written, it posts to the following folders:

E:9999mfgBOSTOMATIC

E:9999mfgOKK

E:9999mfgMAZAK TRODE

 

I know absolutely NOTHING about VBscript and I've been messing with this on and off for the last couple weeks with no success. banghead.gif Any help will certainly appreciated. Thank you!!!

Link to comment
Share on other sites

The script will only use the first two folders in the drawings name to create the output path. For example:

 

C:9999mfgetset3aTEMP.MCX is the path to my test file, the script parses this path and assigns

9999 to the variable companyname and the mfg to the variable Program and uses those two variables to create an output path i.e C:9999mfg.

 

If you want to output two additional output folders you will need to edit the script.

 

[ 03-31-2009, 02:05 PM: Message edited by: Mick from CNC Software, Inc. ]

Link to comment
Share on other sites

Yep, the folders above are always in that format. The part will always have four folders and we post the .nc program to the exact folders, but into the E: drive instead of the C: drive. Therefore, if the part file = C:6112trdfinapltaplate.mcx, then the posted program should be directed to E:6112trdfinapltncfilename.nc

 

Thanks for your help Mick!!! cheers.gif

Link to comment
Share on other sites

Let me know if this works as expected.

 

code:

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

'//

'// Author: Connormac

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

'// File Name:

'//

'// Description: Posts drawing to 3 defined posts

'//

'// Comments: Edited by [email protected]

'// 04-06-2009

'// Added recursive create folder method using current drawing

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

 

 

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

Public Const DEF_FIRST_POST = "BOSTOMATIC.pst"

Public Const DEF_SECOND_POST = "OKK.PST"

Public Const DEF_THIRD_POST = "MAZAK TRODE.PST"

Dim FSO

' -- Start Script

Call Main()

 

 

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

' Sub Declaration

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

Sub Main()

 

'On Error Resume Next

 

' -- Check for drawing

If IsDrawing Then

 

Dim strName

Dim strFolder

 

' -- Get the current file name

strName = GetCurrentFileName

 

Set FSO = CreateObject("Scripting.FileSystemObject")

 

' -- Get the path

strFolder = FSO.GetParentFolderName(strName)

 

' -- Make the top level output folder

CreateFolder strFolder

 

Dim strCNC_1

Dim strCNC_2

Dim strCNC_3

 

' -- Assign paths to each machine

strCNC_1 = AddBackSlash(strFolder) & "BOSTOMATIC"

strCNC_2 = AddBackSlash(strFolder) & "OKK"

strCNC_3 = AddBackSlash(strFolder) & "MAZAK TRODE"

 

' -- Create the folders

MakeFolders strCNC_1

MakeFolders strCNC_2

MakeFolders strCNC_3

 

Dim strCurrentPost

 

' -- Store current post

strCurrentPost = GetPostName

 

' -- Set first post as current post

Call SetPostName(DEF_FIRST_POST)

 

' -- Post it

Call RunPostAll(strCNC_1, False)

 

' -- Set second post as current post

Call SetPostName(DEF_SECOND_POST)

 

' -- Post it

Call RunPostAll(strCNC_2, False)

 

' -- Set third post as current post

Call SetPostName(DEF_THIRD_POST)

 

' -- Post it

Call RunPostAll(strCNC_3, False)

 

' -- Set mc back to original post

Call SetPostName(strCurrentPost)

 

 

ShowString "Posting complete"

 

End If

 

End Sub

 

 

 

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

' Function Declaration

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

 

Function IsDrawing()

 

Dim Ret

 

Ret = StartDBSearch(mc_alive, -1)

 

IsDrawing = Ret

 

End Function

 

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

' Function Declaration

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

Public Sub MakeFolders(path)

 

On Error Resume Next

'

' -- NOTE: If you use an invalid character for a part number you'll have a problem!

'

Call FSO.CreateFolder(path)

 

End Sub

 

 

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

' Sub Declaration

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

Sub CreateFolder(strPath)

On Error Resume Next

' -- Recursive folder create, will create directories and Sub

 

' -- Fixes endless recursion in some instances when at lowest directory

If strPath <> "" Then

If Not FSO.FolderExists(FSO.GetParentFolderName(strPath)) Then Call CreateFolder(FSO.GetParentFolderName(strPath))

Call FSO.CreateFolder (strPath)

End If

 

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

Good morning Mick. Very close, but not quite there. The folder structure is perfect, but the data path is not correct. The .nc programs are now posting to the same hard drive as the part. See the pic below.

 

mulltipost.jpg

 

[ 04-09-2009, 08:51 AM: Message edited by: peon ]

Link to comment
Share on other sites

Give this a try.

 

code:

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

'//

'// Author: Connormac

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

'// File Name:

'//

'// Description: Posts drawing to 3 defined posts

'//

'// Comments: Edited by [email protected]

'// 04-06-2009

'// Added recursive create folder method using current drawing

'// 04-13-2009

'// Added drive prompt to output

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

 

 

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

Public Const DEF_FIRST_POST = "BOSTOMATIC.pst"

Public Const DEF_SECOND_POST = "OKK.PST"

Public Const DEF_THIRD_POST = "MAZAK TRODE.PST"

Dim FSO

' -- Start Script

Call Main()

 

 

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

' Sub Declaration

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

Sub Main()

 

On Error Resume Next

 

' -- Check for drawing

If IsDrawing Then

 

Dim strName

Dim strFolder

Dim sCurrentDrive

Dim sDrive

Dim strCurrentPost

 

 

' -- Get the current file name

strName = GetCurrentFileName

 

Set FSO = CreateObject("Scripting.FileSystemObject")

 

' -- Get the path

strFolder = FSO.GetParentFolderName(strName)

 

' -- Prompt for Drive change

sDrive = AskString("Input drive letter for output folder, e.g. E", "E")

 

' -- Get the current drive letter

sCurrentDrive = Left(strFolder, 1)

 

' -- replace it

strFolder = Replace(strFolder, sCurrentDrive, sDrive, 1, 1)

 

' -- Make the top level output folder

CreateFolder strFolder

 

Dim strCNC_1

Dim strCNC_2

Dim strCNC_3

 

' -- Assign paths to each machine

strCNC_1 = AddBackSlash(strFolder) & "BOSTOMATIC"

strCNC_2 = AddBackSlash(strFolder) & "OKK"

strCNC_3 = AddBackSlash(strFolder) & "MAZAK TRODE"

 

' -- Create the folders

MakeFolders strCNC_1

MakeFolders strCNC_2

MakeFolders strCNC_3

 

 

 

If Err Then

ShowString "Error, " & Err.Description

Else

 

' -- Store current post

strCurrentPost = GetPostName

 

' -- Set first post as current post

Call SetPostName(DEF_FIRST_POST)

 

' -- Post it

Call RunPostAll(strCNC_1, False)

 

' -- Set second post as current post

Call SetPostName(DEF_SECOND_POST)

 

' -- Post it

Call RunPostAll(strCNC_2, False)

 

' -- Set third post as current post

Call SetPostName(DEF_THIRD_POST)

 

' -- Post it

Call RunPostAll(strCNC_3, False)

 

' -- Set mc back to original post

Call SetPostName(strCurrentPost)

 

ShowString "Posting complete"

End If

 

End If

 

End Sub

 

 

 

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

' Function Declaration

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

 

Function IsDrawing()

 

Dim Ret

 

Ret = StartDBSearch(mc_alive, -1)

 

IsDrawing = Ret

 

End Function

 

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

' Function Declaration

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

Public Sub MakeFolders(path)

 

On Error Resume Next

'

' -- NOTE: If you use an invalid character for a part number you'll have a problem!

'

Call FSO.CreateFolder(path)

 

End Sub

 

 

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

' Sub Declaration

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

Sub CreateFolder(strPath)

On Error Resume Next

' -- Recursive folder create, will create directories and Sub

 

' -- Fixes endless recursion in some instances when at lowest directory

If strPath <> "" Then

If Not FSO.FolderExists(FSO.GetParentFolderName(strPath)) Then Call CreateFolder(FSO.GetParentFolderName(strPath))

Call FSO.CreateFolder (strPath)

End If

 

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
  • 3 months later...

Hello all,

 

Another of the "issues" I have experienced is that the "nc" file comes up in the editor even though I do not wish it to.

 

I have set the post dialogs NOT to edit the file,and also set the RUNPOST parameter to FALSE as in the above code.

 

Is there anything else that I can do?

 

regards,

Steven

Link to comment
Share on other sites

Mick,

 

I did as you suggested and gained some ground. The editors no longer start up after posting.

 

I did have some other "challenges" that were quite interesting. For example, the nc file type ( ie.. ".eia" or ".ncf") seems to be ignored when the posts are run from script. The posts always seem to default to ".nc".

 

We differ from PEON in that we keep all nc files in the same folder. The names or extensions differ to identify the machine they are posted for.

 

I have found that a post will work fine if I post manually, but fails if I post using script. Also, a post may work fine with script but will fail if posted manually. This has driven me to create two "SETS" of posts. One set to post each manually, and the other to be posted by VB.

 

Thank you for your assistance,

Steven

Link to comment
Share on other sites

Anyone?

 

I regard this as a VB question primarily, but it is also a post processor question.

 

I updated some version 9 post processors into X4 and worked the bugs out. The results are what I expect.

 

Now the VB part....

 

When I use a VB script to call the posts, the results all end up with spaces between the coordinates. I removed them from the .PST file and do not want them in the code. Why would calling the post from VB cause diffferent results?

 

Regards,

Steven

Link to comment
Share on other sites

Roger,

 

That is one of the first things I checked.

 

I checked again just now, and found that the pst file had "0" spaces, and also the NC OUTPUT setting was set to "0" spaces.

 

On the machine group properties tab, I select the post to run, and then post manually. The resulting file is 46k long. I execute the SAME post from VB, and the file is 101k long. The VB executed file contains spaces although the pst and the NC OUTPUT settings are "0".

 

I have asked my tech support group for a post processor guide similar to those in version 8 and 9. Do such guides exist for X4?

 

best regards,

Steven

Link to comment
Share on other sites

quote:

The VB executed file contains spaces although the pst and the NC OUTPUT settings are "0".

A Post Guide isn't going to be of much help in this case!

 

How about this?

Create a Zip2Go package of what you're running/posting and also add the VB Script to that package (A Z2G is really just a ZIP) and be sure that the PST in question is in the Z2G.

Then send if off to -> [email protected]

 

Include a note in the message that I told you to send it.

I would assume that we'll be able to run down these mysterious spaces quicker than - try this and now try this...

Link to comment
Share on other sites

Me again,

 

I can now post for several machines and generate my setup sheet through VB.

 

I have created my setup sheet as a text file.

 

I can open my setup sheet file and read all the lines in the file. Using Script, how do I send each line to the printer after it is read?

 

all help is VERY much appreciated.

 

Regards,

Steven

Link to comment
Share on other sites

My last qestion on the Topic:

 

While I am waiting for tech support to return solutions to my X4 issues, I am attempting to implement muli-posting on the version 9.1 that we are currently using.

 

I find that only one toolpath segment seems to be posted when called from VB. Can someone tell me if this is correct, and how to post all toolpaths if it is correct?

 

I know 9.1 is not the current version of choice, but until I can get X4 fully configured and tested, I will not be able to release it to all the programmers.

 

Any and all help is MOST APPRECIATED.

 

regards,

Steven

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