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:

Bullines

Verified Members
  • Posts

    3,094
  • Joined

  • Last visited

Recent Profile Visitors

2,594 profile views

Bullines's Achievements

Newbie

Newbie (1/14)

2

Reputation

  1. Hi Roger, I wasn't sure if only certain Fx versions were supported, as I didn't notice it in the Nethook documentation (and I'm sorely out of the Mastercam loop). If I'm able to target 3.5, then I'm good to go And yup, it's me.
  2. Any issues in using VS2010 and .NET 3.5 or 4.0 for Nethook development?
  3. quote: can it move the entities to the correct level? ie. wireframe is level 100 puts all wireframe on level 100, surfaces level 200 puts all surfaces on leve 200....... is that easy to do? Easy to do with the C-Hook and Nethook APIs. Not possible with the VBScript API as it only has access to basic wireframe entities (points, lines and arcs), and not other entities like surfaces and solids.
  4. quote: also is the new c-hook colrsurf.dll working o.k. Works fine for me in X MR1-SP2. If there's a problem, let me know. I know the developer really well
  5. Does this portion in the script on your computer look exactly like this (excluding the debug messages)? code: Set objFSO = CreateObject("Scripting.FileSystemObject") ' Make sure the file is actually there and bail if it isn't. If Not (objFSO.FileExists(DEF_CSV_FILE)) Then objFSO = Nothing ShowString("File not found!" & vbLf & vbLf & DEF_CSV_FILE) Exit Sub End If
  6. Do you get the "File Not Found" error before you get the runtime error?
  7. Unprompted debug version it is, then: code: Const DEF_CSV_FILE = "C:pathtoyourfile.csv" Const DEF_FSO_FORREADING = 1 Const DEF_UNNAMED_LVL = """"""".""""""" ' Kick off our script Call Main() ' Purpose: The main subroutine Sub Main() Dim objFSO Dim objTS Dim strInLine Dim arrTokLine ShowString "Debug 1" Set objFSO = CreateObject("Scripting.FileSystemObject") ShowString "Debug 2" ' Make sure the file is actually there and bail if it isn't. If Not (objFSO.FileExists(DEF_CSV_FILE)) Then objFSO = Nothing ShowString("File not found!" & vbLf & vbLf & DEF_CSV_FILE) Exit Sub End If ShowString "Debug 3" Set objTS = objFSO.OpenTextFile(DEF_CSV_FILE, DEF_FSO_FORREADING, False) ShowString "Debug 4" ' Read the CSV file line by line. For each line, make sure that it ' contains a comma. If it does, tokenize on the comma into an array. ' The first element is the level number and the second element is ' the level name. Set the named levels based on what's in the array. Do While(objTS.AtEndOfStream <> True) strInLine = Trim(objTS.ReadLine) If (InStr(1, strInLine, ",")) Then arrTokLine = Split(strInLine, ",") If Not (arrTokLine(1) = DEF_UNNAMED_LVL) Then Call SetLevelName(arrTokLine(0), Trim(arrTokLine(1))) End If End If Loop ShowString "Debug 5" ' Close the CSV file. We're done with it. objTS.Close ShowString "Debug 6" ' Cleanup Set objFSO = Nothing Set objTS = Nothing ShowString "Debug 7" ' All done! ShowString ("All done!") End Sub Of course you'll have to update the contents of DEF_CSV_FILE so that it matches the path to your CSV file on your computer.
  8. Ah, the joys of debugging Mastercam VBScript. Line numbers would be nice, wouldn't they? Anywho, I have a hunch what it might be in your case, Pip, but give this a try: code: Const DEF_FSO_FORREADING = 1 Const DEF_UNNAMED_LVL = """"""".""""""" ' Kick off our script Call Main() ' Purpose: The main subroutine Sub Main() Dim objFSO Dim objTS Dim strCSVPath Dim strInLine Dim arrTokLine ShowString("Debug 1") ' Prompt the user for a CSV file. Bail if the user cancels ' the dialog. If Not (AskForFileName("*.CSV", "r", strCSVPath)) Then ShowString("No file selected. Aborting.") Exit Sub End If ShowString("Debug 2") Set objFSO = CreateObject("Scripting.FileSystemObject") ShowString("Debug 3") ' Make sure the file is actually there and bail if it isn't. If Not (objFSO.FileExists(strCSVPath)) Then objFSO = Nothing ShowString("File not found!" & vbLf & vbLf & strCSVPath) Exit Sub End If ShowString("Debug 4") Set objTS = objFSO.OpenTextFile(strCSVPath, DEF_FSO_FORREADING, False) ShowString("Debug 5") ' Read the CSV file line by line. For each line, make sure that it ' contains a comma. If it does, tokenize on the comma into an array. ' The first element is the level number and the second element is ' the level name. Set the named levels based on what's in the array. Do While(objTS.AtEndOfStream <> True) strInLine = Trim(objTS.ReadLine) If (InStr(1, strInLine, ",")) Then arrTokLine = Split(strInLine, ",") If Not (arrTokLine(1) = DEF_UNNAMED_LVL) Then Call SetLevelName(arrTokLine(0), Trim(arrTokLine(1))) End If End If Loop ShowString("Debug 6") ' Close the CSV file. We're done with it. objTS.Close ShowString("Debug 7") ' Cleanup Set objFSO = Nothing Set objTS = Nothing ShowString("Debug 8") ' All done! ShowString ("All done!") End Sub Run this "debug" version of the script and let me know what the last debug number you see before you get that runtime error dialog.
  9. quote: One thing that would make it AWESOME would be if it did not prompt at all. Piece o' cake: code: Const DEF_CSV_FILE = "C:pathtoyourfile.csv" Const DEF_FSO_FORREADING = 1 Const DEF_UNNAMED_LVL = """"""".""""""" ' Kick off our script Call Main() ' Purpose: The main subroutine Sub Main() Dim objFSO Dim objTS Dim strInLine Dim arrTokLine Set objFSO = CreateObject("Scripting.FileSystemObject") ' Make sure the file is actually there and bail if it isn't. If Not (objFSO.FileExists(DEF_CSV_FILE)) Then objFSO = Nothing ShowString("File not found!" & vbLf & vbLf & DEF_CSV_FILE) Exit Sub End If Set objTS = objFSO.OpenTextFile(DEF_CSV_FILE, DEF_FSO_FORREADING, False) ' Read the CSV file line by line. For each line, make sure that it ' contains a comma. If it does, tokenize on the comma into an array. ' The first element is the level number and the second element is ' the level name. Set the named levels based on what's in the array. Do While(objTS.AtEndOfStream <> True) strInLine = Trim(objTS.ReadLine) If (InStr(1, strInLine, ",")) Then arrTokLine = Split(strInLine, ",") If Not (arrTokLine(1) = DEF_UNNAMED_LVL) Then Call SetLevelName(arrTokLine(0), Trim(arrTokLine(1))) End If End If Loop ' Close the CSV file. We're done with it. objTS.Close ' Cleanup Set objFSO = Nothing Set objTS = Nothing ' All done! ShowString ("All done!") End Sub Change the value of DEF_CSV_FILE, whcih stores the path to your CSV file, as needed. HTH
  10. I remembered another one. I don't know if he frequents the forum much anymore, but he later went by the name "DOSman". However, his original publicly displayed name was "C:" and that wrecked the forum. Looking back on it now, it was kinda funny how something as simple as that could dummy the forum software. I can just picture a bunch of references in the forum engine's code looking for stuff in the root of everyone's C drive and not finding it
  11. There's no book available on VBS for Mastercam, per se, other than the API documentation that ships with Mastercam. However, there are plenty of good books available for VBS as it relates to Windows scripting. You could then easily apply that knowledge to writing scripts for Mastercam. A possible good one for those not experienced in computer programming: Microsoft WSH and VBScript Programming for the Absolute Beginner O'Reilly publishes good "nutshell" books and here's an applicable one: VBScript in a Nutshell And online, MSDN is always great for reference: http://msdn.microsoft.com/scripting/ Hope that's a start.
  12. ...in your Mastercam scripts. Create a sub such as: code: Sub MakeArc() End Sub And you'll see Mastercam get mad. Call it MakeTheArc() instead and all is well. Just something that popped up today.
  13. With some clever scripting (and assuming you don't post in a weird way and you're NOT using X), then you could easily write a Mastercam VBS script to: [*]post your file [*]grab the location of your G-Code file [*]generate a cmdfile.txt file to that contains login and upload commands [*]execute the command-line FTP client that's included with Windows and pass it the cmdfile.txt that the script generated A cmdfile.txt generated by your script might look like this: open 192.168.1.10 your_username your_password cd programs put 1234.nc And when you have the script run the FTP client, you'd shell it out with a command-line string like this: code: Dim strFTP strFTP = "ftp -s: C:pathtoyourcmdfile.txt" Call ShellAndWait(strFTP, True) Otherwise, this can be done via a custom C-Hook or Nethook without needing the command-line FTP client.
  14. Now that I think about it, there already is a script for that. If you still have V9 installed, take a peek in the VB subdirectory and look for a script called SETCOLOURSFROMLEVELS.vbs. It does exactly what you're asking.

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