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:

Mick from CNC Software Inc.

CNC Software
  • Posts

    1,012
  • Joined

  • Last visited

Everything posted by Mick from CNC Software Inc.

  1. The drawings that contain the various machine defs, are they all contained in all drawings? If so I would be easy to display a list of them in the drawing to the user and have the user select one and then apply to all machine groups. Can you send me a sample(s) drawing via e-mail and I'll whip something up for you.
  2. After looking through the VBScript API it appears as though this is not possible, however, I believe we can do something using our .NET API. Below is a code snippet that will iterate all mill operations in the current drawing and update each with a new machine definition which is what you are after. code: //Get all mill machine groups in current drawing Group[] existingMillGroups = SearchManager.GetGroups(ProductType.Mill); // Iterate through the list foreach (Group grp in existingMillGroups) { //We only want machine groups if (grp.IsMachineGroup()) { //Set this machine group as current grp.SetAsCurrent(); //Assign new MMD to this group Mastercam.Operations.OperationsManager.ActiveMachine = "C:mcamx4cnc_machinesMILL 3 - AXIS VMC.MMD"; } } I guess the next question is how are you to specify what machine def you want to set for all machine groups? Do you want the user to select from the machine defs contained in the drawing or from another location?
  3. Kevin, I copied and pasted your example code into a new script and it completed as expected, I can't see anything wrong? I was also able to post good code.
  4. Search for a post variable called bug0 (if I recall) and make sure the value is set to not show the editor, 0 I think as I don't have a post in-front of me with that variable.
  5. Randy, I used your code and it works OK for me. Did you run any other types of scripts or NETHooks prior to this? If so restart X and just run the script, failing that restart your PC and try the script again to see if there was anything weird going on.
  6. John, Can you rename your script to .txt and e-mail it to me and I'll look into it.
  7. Steven, Search for this line in your post code: bug1$ : 2 #0=No display, 1=Generic list box, 2=Editor Change the value to 0
  8. Randy, Feel free to zip up and mail me both the VB.NET project and script and I'll take a look at it.
  9. The hard drive on my development machine had to be replaced so it will be a couple of days before I can get back to taking a look at this, I apologize for the inconvenience.
  10. This code will iterate all operations, let me know if thats what you are looking for. I'll take a look at groups next. code: Imports Mastercam.App Imports Mastercam.App.Types Imports Mastercam.BasicGeometry Imports Mastercam.Database.Types Imports Mastercam.Database Imports Mastercam.IO Imports Mastercam.IO.Types Imports Mastercam.Math Imports Mastercam.Support For Each op As Mastercam.Database.Operation In SearchManager.GetOperations() Select Case op.Type Case OperationType.BlockDrill DialogManager.OK("BlockDrill:GroupNumber = " & _ op.GroupNumber.ToString() + " OperationID = " + _ op.GetOperationID().ToString(), "") Case OperationType.CircleMill DialogManager.OK("CircleMill:GroupNumber = " & _ op.GroupNumber.ToString() + " OperationID = " + _ op.GetOperationID().ToString(), "") Case OperationType.Contour DialogManager.OK("Contour:GroupNumber = " & _ op.GroupNumber.ToString() + " OperationID = " + _ op.GetOperationID().ToString(), "") Case OperationType.Drill DialogManager.OK("Drill:GroupNumber = " & _ op.GroupNumber.ToString() + " OperationID = " + _ op.GetOperationID().ToString(), "") Case OperationType.Engrave DialogManager.OK("Engrave:GroupNumber = " & _ op.GroupNumber.ToString() + " OperationID = " + _ op.GetOperationID().ToString(), "") Case OperationType.HelixBore DialogManager.OK("HelixBore:GroupNumber = " & _ op.GroupNumber.ToString() + " OperationID = " + _ op.GetOperationID().ToString(), "") Case OperationType.Nesting DialogManager.OK("Nesting:GroupNumber = " & _ op.GroupNumber.ToString() + " OperationID = " + _ op.GetOperationID().ToString(), "") Case OperationType.OnionSkinning DialogManager.OK("OnionSkinning:GroupNumber = " & _ op.GroupNumber.ToString() + " OperationID = " + _ op.GetOperationID().ToString(), "") Case OperationType.Pocket DialogManager.OK("Pocket:GroupNumber = " & _ op.GroupNumber.ToString() + " OperationID = " + _ op.GetOperationID().ToString(), "") Case OperationType.Undefined DialogManager.OK("Undefined:GroupNumber = " & _ op.GroupNumber.ToString() + " OperationID = " + _ op.GetOperationID().ToString(), "") End Select Next
  11. This is a bit long winded but works and might give you some ideas code: ' -- Start Script Const DEF_PATH = "C:Documents and SettingsmgMy DocumentsCabinet Software DXF filesKCDwACME - SMALL" Call Main() ' //////////////////// ' Sub Declaration ' //////////////////// Sub Main() ' -- Add code here... Dim ret ReadDXF DEF_PATH & "ACME_1_Back_001F.dxf" SaveMC False NewMC False ReadDXF DEF_PATH & "ACME_1_Bottom_001F.dxf" SaveMC False NewMC False ReadDXF DEF_PATH & "ACME_2_Spanner_Top_Back_001F.dxf" SaveMC False NewMC False ' -- re-open and merge OpenMC DEF_PATH & "ACME_1_Back_001F.mcx" MergeMC DEF_PATH & "ACME_1_Bottom_001F.mcx" MergeMC DEF_PATH & "ACME_2_Spanner_Top_Back_001F.mcx" RepaintScreen True End Sub
  12. A quick look at the Word 2007 API object browser I found the code below, I think this is what you are after. code: Selection.ParagraphFormat.LineSpacingRule = wdLineSpace1pt5
  13. 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
  14. We can't get the selected items data path from the control definition via VBScript therefore we have a couple of options. We can hard code the drive or prompt the user for it, is the drive always the same i.e. E or will it change?
  15. If you are not comfortable writing a macro in Excel to do this feel free to e-mail me a zipped excel file and I'll write a quick little app that will convert it for you.
  16. You can use a regular expression to remove the excess spaces using the function below: code: Function RemoveWhiteSpace(strText) Dim RegEx Set RegEx = New RegExp RegEx.Pattern = "s+" RegEx.MultiLine = True RegEx.Global = True strText = RegEx.Replace(strText, " ") RemoveWhiteSpace = strText End Function In your VBA code you would iterate each line of text and pass in the current line to the function and write it out to a new file for example. code: Dim clean as string clean = RemoveWhiteSpace(mylineoftext) From Excel, press ALT+F11 to open up the VBA editor, from the Tools References menu select Microsoft VBScript Regular Expressions 5.5 or whatever version is on the machine and you should be good to go.
  17. 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
  18. Give me a couple of days and I'll see if I can edit the script for you. In the meantime, the path to your files, i.e C:9999mfgetset3a does this ever change in anyway?
  19. 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. ]

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