-
Posts
1,012 -
Joined
-
Last visited
Content Type
Profiles
Forums
Downloads
Store
eMastercam Wiki
Blogs
Gallery
Events
Everything posted by Mick from CNC Software Inc.
-
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.
-
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?
-
mastercam.ftt
Mick from CNC Software Inc. replied to R.Roberts's topic in Mastercam C-Hook, NET-Hook and VBScript Development
Are you looking to use the RunMastercamCommand function? -
finding empty tool in VBS
Mick from CNC Software Inc. replied to John T.'s topic in Industrial Forum
John, Can you rename your script to .txt and e-mail it to me and I'll look into it. -
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
-
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
-
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
-
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
-
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.
-
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
-
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.