Need a little guidance

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need a little guidance

    Has anyone come across a way to export a program run as basic?
    Or, has come across a way to export a program run in a way that can be imported back in later for review?

    I know it may seem unnecessary.

    My lab does a lot of protoyping, and as a result the customer sometimes desires to change datum scheme/bonus/hit targets/profile tolerances as the process goes on.
    It gets tedious to have to re-run a part to get updated dimensional data.

    Is there a solid way to do it?
    I've exported programs as basic before, then re-uploaded them.
    So i would assume it is possible.

    I would just prefer an automated approach, anyone point me in a direction?

  • #2
    This saves the entire .prg file.


    NOTE! It does this by first saving the program which is executing, then copying the file to an archive location.

    i.e. if you can't save the existing program with measured data in it for some reason you'll need to find another method.




    Code:
    'JON WOOD - AUTOMETTECH LTD (UK) www.automettech.com
    
    Sub main()
    
    
    '========= SETTINGS =================
    
    'Root save directory For archive
    Dim archivePath
    archivePath = "C:\CMM\Archive"
    
    'This is the Name of a PC-Dmis ASSIGNMENT - If it exist the value it holds will be used In the file Name
    'of the archived program (i.e. can be a serial number, Or works order number etc)
    Dim myUID
    myUID = "UID"
    
    'NOTE! - File Name will be In the following format...
    'SaveDirectory\Program Name\ProgramName_UniqueID_DateTime.prg
    
    'i.e. C:\CMM Files\Part Program Run Instances Archive\123456-01\123456-01_abc123_20140824104232.prg
    
    'Where...
    'archivePath = "C:\CMM Files\Part Program Run Instances Archive"
    'Part program = 123456-01.prg
    'Serial Number / Unique Id = abc123
    'DateTime = 24/08/2014 10:42:32
    
    
    '===========End OF SETTINGS==========
    
    'Create objects
    Dim pcapp As Object
    Set pcapp = createobject("pcdlrn.application")
    
    Dim pcpart As Object
    Set pcpart = pcapp.activepartprogram
    
    'Save existing program
    pcpart.save
    
    'Get the current program path
    Dim source_path
    source_path = pcpart.fullname
    
    'Get program Name (without file extension)
    Dim progname
    progname = left(pcpart.Name,len(pcpart.Name)-4)
    
    'Create File System Object For file operations 
    Dim fso As Object
    Set fso = createobject("scripting.filesystemobject")
    
    'Check main archive directory And program specific directories exist
    Dim ofolder As Object
    
    If Not fso.folderexists(archivepath) Then
    Set ofolder = fso.createfolder(archivepath)
    End If
    
    If Not fso.folderexists(archivepath & "\" & progname) Then
    Set ofolder = fso.createfolder(archivepath & "\" & progname)
    End If
    
    'Get a UID If present
    Dim uid
    uid=""
    
    Dim myvar As Object
    Set myvar = pcpart.getvariablevalue(myUID)
    
    If Not myVar is Nothing Then
    uid = myvar.stringvalue
    'MsgBox(uid)
    End If
    
    'Genrate the destination (save) path
    dest_path = archivepath & "\" & progname & "\" & progname & "_" & uid & "_" &  format(now(),"YYYYMMDDHHNNSS") & ".prg"
    'MsgBox(dest_path)
    
    
    'Save the file
    MsgBox(source_path & chr(13) & dest_path)
    
    fso.copyfile source_path, dest_path
    
    
    'Tidy up
    Set fso = Nothing
    Set pcpart = Nothing
    Set pcapp = Nothing
    
    
    End Sub
    Call it from within Pc-Dmis like so...


    Code:
    CS5        =SCRIPT/FILENAME= C:\CMM FILES\SUBROUTINES\AUTOARCHIVE.BAS
                FUNCTION/Main,SHOW=YES,,
                STARTSCRIPT/
                ENDSCRIPT/
    Automettech - Automated Metrology Technology

    Comment


    • #3
      Neat little script.
      I will probably modify it to include a CAD file if present and append both files to their own folder.
      Is there a way through the basic script shell, to append to a zip archive?
      Save space.

      Comment


      • #4
        this script is what i was searching for exept of one item i do miss. the Serial Number in the file name.
        I tried to add this but i really have no clue how to.
        i added this
        Code:
        Dim serial
        serial =Serial_number
        and changed the file name to:
        Code:
        dest_path = archivePath & "\" & progname & "\" & progname & "_" & Serial & "_" & uid & "_" & Format(Now(), "YYYYMMDDHHNN") & ".prg"
        somehow the callout is "193" and not what i've filled in as Serial Number.
        What have i done wrong?

        At the beginning of each prg the serial number is defined
        Code:
        WERKSTÜCKSNAME : 45555
        VERSIONSNR.: 5208438/-
        SERIENNR.: 88066_000
        need help

        Comment


        • vpt.se
          vpt.se commented
          Editing a comment
          If you replace 'serial' with 'Serial_number', does it say the same thing? Are you sure you are using the correct source variable (Serial_number)?

        • Craess
          Craess commented
          Editing a comment
          I replaced it in the dest_path --> same result 193
          no i'm not sure this is the correct source variable. in my fileheader i work with =SERIAL_NUMBER and i get what i filled in so i thought it will be the same.

      • #5
        Originally posted by Craess
        i'm not sure this is the correct source variable. in my fileheader i work with =SERIAL_NUMBER and i get what i filled in so i thought it will be the same.
        There's no correlation between "Report BASIC" and "Script BASIC". If you need the SER NUMBER from the program you need something like this (off the top of my head, untested, code):

        Code:
        Dim App As Object
        Dim Part As Object
        Sub main
          Set App = CreateObject("PCDLRN.Application")
          Set Part = App.ActivePartProgram
          Serial = Part.SerialNumber
        End Sub
        AndersI
        SW support - Hexagon Metrology Nordic AB

        Comment


        • Craess
          Craess commented
          Editing a comment
          Thank you so much. it worked.
          the script looks like this:
          Code:
          'Add Serial Number To Path
          Set App = CreateObject("PCDLRN.Application")
          Set Part = App.ActivePartProgram
          Serial = Part.SerialNumber
          
          'Genrate the destination (save) path
          dest_path = archivePath & "\" & progname & "\" & progname & "_" & Serial & "_" & uid & "_" & Format(Now(), "YYYYMMDDHHNN") & ".prg"
          'MsgBox(dest_path)
          Thank you, again

        • AndersI
          AndersI commented
          Editing a comment
          Glad it worked!

      • #6
        I have recently made the biggest mistake - update from 2019R1 to R2
        The problem I have now is not working script created by NinjaBadger Everything was perfect up to 2019R1, on 2019R2 throws the error like in the below picture.Udklip1.JPG

        Udklip.JPG
        Attached Files

        Comment


        • #7
          I'll get back to this later but as a quick thought try replace every instance of 'uid' with something like 'uniqueid'
          Automettech - Automated Metrology Technology

          Comment


          • #8
            It looks like they have added a check against PC-DMIS 'reserved words' - I have a script with a variable called ID which has worked many years, but now it gets the error message "Duplicate definition: ID" even though it is only DIM:ed once in the file. Renaming my variable to "myID" makes it work again. It would be nice if the error message had been "Not allowed to use a reserved word as variable name", or something like that...
            AndersI
            SW support - Hexagon Metrology Nordic AB

            Comment


            • #9
              AndersI wouldn't "Option Explicit" avoid the "Duplicate definition" error?
              Last edited by Kp61dude!; 10-23-2019, 09:44 AM. Reason: clarified my statement; thanks @AndersI
              PcDmis 2015.1 SP10 CAD++
              Global 7-10-7 DC800S

              Comment


              • #10
                Originally posted by Kp61dude! View Post
                AndersI would "Option Explicit" catch that?
                Depends on what you mean by "catch". It just makes it mandatory to DIM a variable before using it. So it catches misspellings in your code, and you get the "Duplicate…" error on the DIM line if you use a reserved Word as a variable name.
                AndersI
                SW support - Hexagon Metrology Nordic AB

                Comment


                • Kp61dude!
                  Kp61dude! commented
                  Editing a comment
                  Updated my comment. Been dealing with 2 bad mechanical keyboards giving problems with key chatter, makes it a drag to type anything.

              • #11
                I have add one extra "U" so now with "UUID" seems that is working. I wonder if I need to add extra U after each new Pc-dmis release...like UUUUUUUUUUUUUID

                Comment

                Related Topics

                Collapse

                Working...
                X