hexagon logo

Save Measurement Routine Locally from Server Drive

Save Measurement Routine Locally from Server Drive

A sample example of a process to save the measurement routine to the local PC Drive.

This example is part of my Container Template routine that I use for coping and paste to other measurement routines.

I had to create this code in order to protect the programs from any server issues. For years now, we have been using
the measurement routines directly from the server with no issues. Just recently the server will now act like it is
reloading and placing everything in a pause state. When using this code, I am able to keep the measurement routines
on the server in its original state and use them on the local drive. The code will look to see if the measurement
routine that you have open is not located on the local drive. If the routine is not located on the local drive there
be a comment to ask you to save the routine locally.​

SAVE_ROUTINE_LOCALLY_C1     =COMMENT/YESNO,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
                Do you want to save the Measurement Routine locally?
                "Local Folder: "+LOCAL_ROUTINE_FILE_PATH1​


If the measurement routine is already on the local drive then this comment and save routine to the local drive is
skip.

This is where I will usually have the SAVE_ROUTINE_LOCALLY Group placed within the measurement routine.​

PART NAME  : Routine Container
REV NUMBER :
SER NUMBER :
STATS COUNT : 1
 
STARTUP    =ALIGNMENT/START,RECALL:USE_PART_SETUP,LIST=YES
            ALIGNMENT/END
            RECALL/ALIGNMENT,EXTERNAL,FX-BP400_400
            MODE/MANUAL
            MOVESPEED/ 50
            FORMAT/TEXT,OPTIONS, ,HEADINGS,SYMBOLS, ;NOM,TOL,MEAS,DEV,OUTTOL, ,
            LOADPROBE/PC1_4BY20_T1_4BY50_5W_CTM2_10E_35E_X4
            TIP/TIP1, SHANKIJK=-0.0001, -0.0003, 1, ANGLE=0.0503
            WORKPLANE/ZPLUS
SAVE_ROUTINE_LOCALLY=GROUP/SHOWALLPARAMS=NO
            ENDGROUP/ID=SAVE_ROUTINE_LOCALLY
PART_MACHINE_ENTRY=GROUP/SHOWALLPARAMS=NO
            ENDGROUP/ID=PART_MACHINE_ENTRY
MOVE_SETTINGS=GROUP/SHOWALLPARAMS=NO
            ENDGROUP/ID=MOVE_SETTINGS
START_MENU =GROUP/SHOWALLPARAMS=NO
            ENDGROUP/ID=START_MENU
PREFEATURE_CHECK=GROUP/SHOWALLPARAMS=NO
            ENDGROUP/ID=PREFEATURE_CHECK
ROUTINE_MODE_MEAS1=GROUP/SHOWALLPARAMS=NO
            ENDGROUP/ID=START_MENU
MANUAL_MODE_MEAS2=GROUP/SHOWALLPARAMS=NO
            ENDGROUP/ID=MANUAL_MODE_MEAS2
MANUAL_START_MEAS=LABEL/
MAN_ALIGN  =GROUP/SHOWALLPARAMS=YES​


Here is the PC-DMIS code for the SAVE_ROUTINE_LOCALLY Group

SAVE_ROUTINE_LOCALLY=GROUP/SHOWALLPARAMS=YES
              ASSIGN/SAVE_ROUTINE_LOCALLY_BUILD_VERSION=0
LOCAL_ROUTNE_START1  =LABEL/
              ASSIGN/USE_LOCAL_ROUTINE="YES"
              IF_GOTO/USE_LOCAL_ROUTINE=="NO",GOTO = LOCAL_ROUTINE_END1
              ASSIGN/LOCAL_ROUTINE_FILE_PATH1=PCDMISSYSTEMVISIBLEDATAPATH()+"Routines"
              ASSIGN/CURRENT_ROUTINE_NAME1=GETPROGRAMINFO("FILENAME")
              ASSIGN/CURRENT_CURRENT_ROUTINE_PATH1=GETPROGRAMINFO("PARTPATH")
              ASSIGN/CURRENT_LOCAL_ROUTINE_PATH_COND1=IF(LOCAL_ROUTINE_FILE_PATH1+"\\"==CURRENT_CURRENT_ROUTINE_PATH1,"True","False")
ROUTINE_PATH_EXISTS1  =FILE/EXISTS,LOCAL_ROUTINE_FILE_PATH1+"\\"+CURRENT_ROUTINE_NAME1
              IF/ROUTINE_PATH_EXISTS1<>0 AND CURRENT_LOCAL_ROUTINE_PATH_COND1=="True"
    $$ NO,
                Measurement Routine in loacal folder.
                "File Location: "+LOCAL_ROUTINE_FILE_PATH1+"\\"+CURRENT_ROUTINE_NAME1
              END_IF/
              ELSE/
SAVE_ROUTINE_LOCALLY_C1     =COMMENT/YESNO,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
                Do you want to save the Measurement Routine locally?
                "Local Folder: "+LOCAL_ROUTINE_FILE_PATH1
                IF/SAVE_ROUTINE_LOCALLY_C1.INPUT=="YES"
PCDMIS_SYSTEM_PATH_FILE_EXISTS1      =FILE/EXISTS,PCDMISSYSTEMVISIBLEDATAPATH()+"SAVE_AS_LOCAL_ROUTINE.BAS"
                  ASSIGN/SAVE_AS_FILE_EXISTS1=IF(PCDMIS_SYSTEM_PATH_FILE_EXISTS1<>0,"True","False")
                  IF/SAVE_AS_FILE_EXISTS1=="False"
SAVE_AS_LOCAL_ROUTINE_FPTR1        =FILE/OPEN,PCDMISSYSTEMVISIBLEDATAPATH()+"SAVE_AS_LOCAL_ROUTINE.BAS",WRITE
                    FILE/WRITELINE,SAVE_AS_LOCAL_ROUTINE_FPTR1,Sub Main(strText As String)
                    FILE/WRITELINE,SAVE_AS_LOCAL_ROUTINE_FPTR1,  Dim DmisApp, DmisPart, DmisCommands, prgName, fs, createFolder As Object
                    FILE/WRITELINE,SAVE_AS_LOCAL_ROUTINE_FPTR1,  Set DmisApp = CreateObject("PCDLRN.Application")
                    FILE/WRITELINE,SAVE_AS_LOCAL_ROUTINE_FPTR1,  Set DmisPart = DmisApp.ActivePartProgram
                    FILE/WRITELINE,SAVE_AS_LOCAL_ROUTINE_FPTR1,  prgNewPath = strText
                    FILE/WRITELINE,SAVE_AS_LOCAL_ROUTINE_FPTR1,  prgName = left(DmisPart.Name, len(DmisPart.Name)-4)
                    FILE/WRITELINE,SAVE_AS_LOCAL_ROUTINE_FPTR1,  Set fs = CreateObject("scripting.filesystemobject")
                    FILE/WRITELINE,SAVE_AS_LOCAL_ROUTINE_FPTR1,  If Not fs.folderexists(prgNewPath) Then
                    FILE/WRITELINE,SAVE_AS_LOCAL_ROUTINE_FPTR1,    Set createFolder = fs.CreateFolder(prgNewPath)
                    FILE/WRITELINE,SAVE_AS_LOCAL_ROUTINE_FPTR1,  End If
                    FILE/WRITELINE,SAVE_AS_LOCAL_ROUTINE_FPTR1,  prgSaveAsName = prgNewPath & "\" & DmisPart.Name
                    FILE/WRITELINE,SAVE_AS_LOCAL_ROUTINE_FPTR1,  retval = DmisPart.SaveAs(prgSaveAsName)
                    FILE/WRITELINE,SAVE_AS_LOCAL_ROUTINE_FPTR1,  DmisPart.RefreshPart
                    FILE/WRITELINE,SAVE_AS_LOCAL_ROUTINE_FPTR1,  Set DmisPart = Nothing
                    FILE/WRITELINE,SAVE_AS_LOCAL_ROUTINE_FPTR1,  Set DmisApp = Nothing
                    FILE/WRITELINE,SAVE_AS_LOCAL_ROUTINE_FPTR1,End Sub
                    FILE/CLOSE,SAVE_AS_LOCAL_ROUTINE_FPTR1,KEEP
                  END_IF/
SAVE_ROUTINE_LOCALLY_CS1      =SCRIPT/FILENAME= PCDMISSYSTEMVISIBLEDATAPATH()+"SAVE_AS_LOCAL_ROUTINE.BAS"
                  FUNCTION/Main,SHOW=NO,ARG1=LOCAL_ROUTINE_FILE_PATH1,,
                  STARTSCRIPT/
                END_IF/
              END_ELSE/
LOCAL_ROUTINE_END1  =LABEL/
            ENDGROUP/ID=SAVE_ROUTINE_LOCALLY​


This is the current example that I am using with the permission levels that allow me to run this code.