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:

Rekd™

Member
  • Posts

    4,477
  • Joined

  • Last visited

  • Days Won

    11

Posts posted by Rekd™

  1. I'm trying to get Operation IDs from a post which includes operations not set to post as well as operations with different NCI destinations.

     

    Reason being is that on parts with multiple setups I put the operations in the order that they run best when all setups are completed and I'm running a 'combined' program but can still post the single setups individually.

     

    For example; My Ops Manager will contain ops in this order...

     

    [*]1-[WCS: Op 1]- Mill Top

    [*]2-[WCS: Op 1]- Rough Contour

    [*]3-[WCS: Op 1]- Rough Contour

    [*]4-[WCS: Op 2]- Rough Pocket

    [*]5-[WCS: Op 4]- Rough Contour

    [*]6-[WCS: Op 1]- Finish Contour

    [*]7-[WCS: Op 2]- Finish Pocket

    ...

    ...

    Each "WCS: OP x" has it's own nci destination which gets 'combined', posted then restored when i do a 'combined' NC file.

     

    It works fine when posting the 'combined' program, but when I post single programs, each one starts with Op 1 and is sequential.

     

    So where "4-[WCS: Op 2]- Rough Pocket" is really Op ID 4, it gets posted as Op ID 1 in the single programs.

     

    (I use these Op ID numbers so the operators know which operation in Mastercam does that. The NC files and Setup Sheets have the Op ID numbers to help with the 100+ operation files wink.gif )

     

    According to the post pdf...

     

    quote:

    op_id

     

    Notes:

    op_id will be a unique value for each operation,
    but do not assume that op_id from one operation to the next operation will be in numeric order.

    Is there any other way to get an 'ordered' operation list which includes all operations in the MC9 file?

  2. code:

    // get the current construction plane view number

     

    Integer GetCPlaneNumber(void)

     

     

     

    // set the current construction plane view to a new number

     

    Void SetCPlaneNumber(

     

    Integer (Input: new view number)

     

    )

     

    // set the current construction plane view to be perpendicular to a certain vector

     

    Integer SetCPlaneNormal(

     

    Real, (Input: X-Coordinate of vector perpendicular to new view)

     

    Real, (Input: Y-Coordinate of vector perpendicular to new view)

     

    Real, (Input: Z-Coordinate of vector perpendicular to new view)

     

    )

     

     

     

    // get the current tool plane view number

     

    Integer GetTPlaneNumber(void)

     

     

     

    // set the current tool plane view to a new number

     

    Void SetTPlaneNumber(

     

    Integer (Input: new view number)

     

    )

     

     

     

    // set the current tool plane view to be perpendicular to a certain vector

     

    Integer SetTPlaneNormal(

     

    Real, (Input: X-Coordinate of vector perpendicular to new view)

     

    Real, (Input: Y-Coordinate of vector perpendicular to new view)

     

    Real, (Input: Z-Coordinate of vector perpendicular to new view)

     

    )

     

     

     

    // get the current construction plane & tool plane to the graphics view flag

     

    Bool GetCPlaneEqualGView (void)

     

     

     

     

     

    // set the current construction plane & tool plane to the graphics view flag

     

    Void SetCPlaneEqualGView (

     

    Bool (Input: true to set construction & tool plane equal to graphics view flag)

     

    )

    HTH cheers.gif

  3. Bill, I would stongly suggest some sort of backup routine. I've had some really bad crashes and lost dozens of hours of work on a few occasions..

     

    This VB Script creates a .zip file using the MC file name, then adds the current MC9 file with a date/time stamp added to the end. It's sort of an incremental backup, keeping all dated mc9 files in the same zipped file.

     

    code:

    '//   Description:   Makes a time/date stamped backup of the current MC file to the folder specified.

    '// Use 7Zip 4.32 Command Line (7Za.exe) to compress the backup file. Once the file

    '// has been backed up, the dated MC9 file is deleted.

    '// You can get the command line interface at: www.7-zip.org

    '//

    '// Comments: Ensure the correct path and arguments for the compression

    '// you wish to use are entered below. You need to use the truncated name for

    '// long path names that contain spaces when calling 7za.exe.

    '// View the 7zip help file for command line options.

     

     

    ' -----------------

    ' | Constants |

    ' ------------------------------------------------------------------------

    Public Const DEF_CENTERED = " "

    Public Const DEF_ERRLOG = "C:CustomersZip Backup Error.log" ' Path and file for error log

    'Public Const strZipPath = "C:Progra~1WinZipwzzip.exe -m -ex" ' Optional path and options for compression with Winzip.

     

    Public Const strZipPath = "C:PROGRA~17-Zip7za.exe a -tzip" 'Path and options for compression

    Public Const DEF_BACKUP_DIR = "C:Roling CustomersZipped Backups" ' Backup folder

     

    Dim strBackupPath ' compiled path and file name with time stamp

    Dim strOriginalPath ' original path of current file name

    Dim strFilePath '

    Dim FSO

    Dim strYear

    Dim strMonth

    Dim strDay

    Dim strHour

    Dim strMin

    Dim C

    Dim strName

     

    C = Chr(34) ' holder for " (double quote)

     

    Call Main()

     

    Sub Main()

    Call RepaintScreen (True)

    On Error Resume Next

    ' -- Check to make sure backup folder is valid

    Set FSO = CreateObject("Scripting.FileSystemObject")

    If FSO.FolderExists(DEF_BACKUP_DIR) Then

    ' -- Make sure we have a drawing to save

    If Not IsDrawing Then

    ShowString "No current drawing" & DEF_CENTERED

    ' -- Bail

    Exit Sub

    End If

    ' -- Store current drawing's name

    strOriginalPath = GetCurrentFileName

    ' -- Format a time and date stamp and strip illegal chars

    strYear = Replace(FormatDateTime(Date, vbShortDate), "/", "-")

    strHour = Replace(FormatDateTime(Time, vbShortTime), ":", "")

    ' -- Build path for the MC9 file name with date/time stamp added

    strBackupPath = AddBackSlash(DEF_BACKUP_DIR) & FSO.GetBaseName(strOriginalPath) & "_" & strYear & "_" & strHour & "." & FSO.GetExtensionName(strOriginalPath)

    ' -- Build path for .ZIP file, (MC9 file name without date/time stamp, reduces clutter)

    strFilePath = AddBackSlash(DEF_BACKUP_DIR) & FSO.GetBaseName(strOriginalPath) & ".zip"

    Call ClearMenuAndPrompts

    ' -- Display current file in prompt area

    Call WriteString("Backing up file, please wait..." & strBackupPath)

    ' -- Save current file with new name and continue

    If SaveMCAs(strBackupPath, True) Then

    ' -- Build the command string for zipping (I'm having to truncate the exe's path, and

    ' -- quote the zip name and file name, go figure..)

    strName = strZipPath & " " & C & strFilePath & C & " " & C & strBackupPath & C

    ' -- Fire the zipping event

    Call WriteString("Creating .zip file. Please wait..." & strFilePath)

    Call ShellAndWait(strName, True)

    ' -- Error?

    Else

    ShowString "Could not backup file to " & DEF_BACKUP_DIR & DEF_CENTERED

    End If

    ' -- Switch back to original file

    Call SaveMCAs(strOriginalPath, True)

    ' -- Clean up

    Call ClearMenuAndPrompts

    Call RepaintScreen (True)

    Dim fsoDelFile

    Set fsoDelFile = CreateObject("Scripting.FileSystemObject")

    fsoDelFile.DeleteFile(strBackupPath)

     

     

    Else

    ' -- Folder error. DOH!

    ShowString "Folder " & DEF_BACKUP_DIR & " does not exist!" & DEF_CENTERED

    Exit Sub

    End If

    ' -- Generate error message and clean up

    If Err Then Call TrapError("Sub::Main", Err, True)

    Set FSO = Nothing

    End Sub

     

    ' -----------------

    ' | Catch Errors |

    ' ------------------------------------------------------------------------

    Sub TrapError(sSource, objErr, bLogIt)

    Dim sMSG

    Dim sLogError

    Dim FSO

    sMSG = "Following error occurred in this script:" & DEF_CENTERED & vbCrLf & vbCrLf

    sMSG = sMSG & objErr.Description & DEF_CENTERED & vbCrLf

    sMSG = sMSG & "Number: " & objErr.Number & DEF_CENTERED & vbCrLf

    sMSG = sMSG & "Source: " & DEF_CENTERED & sSource

    ShowString sMSG

    If bLogIt Then

    sLogError = "Error " & objErr.Number & " in " & sSource & ":" & vbCrLf & objErr.Description

    Call WriteLog(sLogError)

    End If

    objErr.Clear

    Set objErr = Nothing

    End Sub

     

    ' ----------------

    ' | Script Engine |

    ' ------------------------------------------------------------------------

    Function GetScriptEngineInfo()

    On Error Resume Next

    Dim s

    s = "" ' Build string with necessary info.

    s = ScriptEngine & " Version "

    s = s & ScriptEngineMajorVersion & "."

    s = s & ScriptEngineMinorVersion & "."

    s = s & ScriptEngineBuildVersion

    GetScriptEngineInfo = s ' Return the results.

    If Err Then Call TrapError("GetScriptEngineInfo", Err, True)

    End Function

     

    ' ----------------

    ' | Add Backslash |

    ' ------------------------------------------------------------------------

     

    Function AddBackSlash(sPath)

    If Right(sPath, 1) <> "" Then sPath = sPath & ""

    AddBackSlash = sPath

    End Function

     

    ' -----------------

    ' | Drawing exists? |

    ' ------------------------------------------------------------------------

    Function IsDrawing()

    Dim Ret

    Ret = StartDBSearch(mc_alive, -1)

    IsDrawing = Ret

    End Function

  4. Roger, using

     

    code:

    pfixpath

    indexpos = strstr(soldstring, soriginalpath)

    if indexpos <> 0,

    [

    # First part of string is now in ‘soriginalpath’

    stempstr1 = brksps(indexpos, soriginalpath)

    # Second part of string is now in ‘stempstr2’

    stempstr2 = brksps(strlen(soldstring)+1, stempstr1)

    # Stich ‘em all together

    snewpath = soriginalpath + srepstring

    snewpath = snewpath + stempstr2

    ]

    Gives me this error...

     

    "Variable not defined: if"

     

    (it's on the "if indexpos <> 0" line)

     

    confused.gif

  5. "Oh yes why does every one use sequence numbers on every line? that gobbels up memory like no tomorrow."

     

    Same reason I have so much data in the NC file; for the operators.

     

    My programs tend to get very complicated very quickly, so I try to make it as easy as possible for those running the program to navigate around it and see what's going on.

     

    biggrin.gif

     

    code:

    (xxxxxxxx-4 REV F-1.NCF)

    (APR 21, 2006 12:27)

    (MC9 FILE: xxxxxxxx-4 REV F)

    (MACHINE: 4 AXIS)

    (MATERIAL: ALUMINUM INCH - 6061)

    (STOCK SIZE: X 3.6 Y 3. Z .75)

    (TOOL 10: DIA 0.3750 R0.0150 3/8 Hannita Varimill 3Fl Rougher)

    (TOOL 2: DIA 0.2500 1/4 CB EM 2FL TICN)

    (TOOL 3: DIA 0.1250 1/8 Hannita Varimill 3Fl)

    (TOOL 4: DIA 0.1250 1/4 CHAMFER MILL)

    (OVERALL MAX Z1.)

    (OVERALL MIN Z-.53)

    N1 G00 G17 G40 G80 G90 G20

    N2 M01

    N3 ( OPERATION: 1 FACING )

    N4 (-- OP 1 )

    N5 (-- ROUGH FACE )

    N6 T10 M06 (T10: 3/8 HANNITA VARIMILL 3FL ROUGHER)

    N7 (-- OP ID: 1)

    N8 M03 S6500

    N9 G00 G90 G54 X-.2563 Y-.084 A0.

    N10 G43 H10 Z1.

    / N11 M08

    N12 Z.2

    N13 G01 Z.01 F100.

    N14 X3.6063 F156.

    ...

    N35 G00 Z1.

    N36 (OPERATION: 2 CONTOUR)

    N37(--OP 1)

    N38(--ROUGH CONTOUR)

    (T10: 3/8 HANNITA VARIMILL 3FL ROUGHER)

    ( TOOLPATH - CONTOUR)

    ( STOCK LEFT ON X & Y = .01)

    ( STOCK LEFT ON Z = 0.)

    N39 (-- OP ID: 2)

    N40 X3.8175 Y1.325

    N41 Z.1

    I also made apps to remove sequence numbers and comments, just in case memory becomes a problem. wink.gif

  6. Are there any functions in MP to parse strings? i.e. Instr(), Mid(), Replace() etc.

     

    Is there a way to count ALL operations during posting the current MC9 file, even if some ops are set NOT to post?

     

    Also, I see things like

     

    fexist(sfilename2)

    and

    remove(sfilename2)

    and

    ex

     

    I can guess what they're for (well, cept for EX), but are there more? Are they listed in my (extremely old) Post book that I haven't unpacked since the move?

     

     

    Thanks!

  7. Here's another good example.

     

    code:

    pwcs       # G54+ coordinate setting at toolchange

    if wcstype < two, "G92"

    if wcstype = two | wcstype > three,

    [

    if workofs < 0, workofs = 0

    if workofs < 6,

    [

    g_wcs = workofs + 54

    *g_wcs

    ]

    else,

    [

    p_wcs = workofs - five

    "G54.1", *p_wcs

    ]

    !workofs

    ]

    if wcstype = three, "-"

  8. Here's a sample of a nested IF/ELSE statement.

     

    code:

               if opcountpg = ops_per_pg & page_breaks,

    [

    #Page break

    "<br style=", 34, "page-break-before:always;", 34, ">", e

    if list_type = 0, "<p><b><font SIZE=+1>OPERATION LIST - CONTINUED...</font></b></p>", e

    else, "<p><b><font SIZE=+1>TOOL LIST - CONTINUED...</font></b></p>", e

    opcountpg = 0

    ]

    HTH.

  9. Been busy like a mofo, connormac. Between work and the weenies that sold us our house, I can hardly find a minute to scratch my .... mad.gif

     

    Kelly, its a program I made in Visual Basic. It reads the NCF files, strips the "%" signs, and combines them all together in one file, then adds the "%" back. You can edit files before they're merged, or edit the merged file.

     

    It's set up to be able to send that file to a floppy, or to a machine, (right now, just SComm, but anything is possible) wink.gif

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