Your Products have been synced, click here to refresh
'TOTALLY FREE OPEN SOURCE CODE NO TRADEMARK OR COPYRIGHT WHATSOEVER 'NO WARRANTY OR GUARANTEE IMPLIED OR SPECIFIED 'WORKS WITH WITH PC-DMIS SOFTWARE ' Displays an inputbox telling the user To enter a serialnumber ' Or other information that will be concatenated To the partprogram ' Part Name from program header And saved In the current partprogram folder. ' If the file already exist, the user will be prompted and told ' to enter a new serial. ' ' vpt.se 2011 '1) Requires variable assignment for SERNO to be in PC-DMIS program '2) Insert at beginning of program. '3) Additionally, use companion "Auto Save" script at end of program. '4) For PCDMIS v2011 MR1 and up, Registy Setting "DocumentRecovery" needs to be set to False '-------------------------------------------------------------------------- Sub Main() Dim PCDApp, PCDPartPrograms, PCDPartProgram Set PCDApp = CreateObject("PCDLRN.Application") Set PCDPartPrograms = PCDApp.PartPrograms Set PCDPartProgram = PCDApp.ActivePartProgram Dim Cmds As Object Dim Cmd As Object Set Cmds = PCDPartProgram.Commands ser$ = InputBox$("Enter serial number:", "Serial", "", 200, 175) If ser$ <> "" Then newname = PCDPartProgram.Path & PCDPartProgram.PartName & "_" & ser$ & ".PRG" retval = PCDPartProgram.SaveAs(newname) End If For Each Cmd In Cmds If Cmd.Type = ASSIGNMENT Then If Cmd.GetText(DEST_EXPR, 0) = "SERNO" Then bln = Cmd.PutText("""" + ser$+ """", SRC_EXPR, 0) Cmd.ReDraw End If End If Next Cmd ' Cleanup Set PCDPartProgram = Nothing Set PCDPartPrograms = Nothing Set PCDApp = Nothing End Sub
'TOTALLY FREE OPEN SOURCE CODE NO TRADEMARK OR COPYRIGHT WHATSOEVER 'NO WARRANTY OR GUARANTEE IMPLIED OR SPECIFIED 'WORKS WITH WITH PC-DMIS SOFTWARE ' 1) Insert at end of program. ' 2) Additionally, use companion "Auto Save With Serial Number" script at beginning of program. Sub Main() Dim PCDApp, PCDPartPrograms, PCDPartProgram Set PCDApp = CreateObject("PCDLRN.Application") Set PCDPartPrograms = PCDApp.PartPrograms Set PCDPartProgram = PCDApp.ActivePartProgram retval = PCDPartProgram.Save ' Cleanup Set PCDPartProgram = Nothing Set PCDPartPrograms = Nothing Set PCDApp = Nothing End Sub
' JON WOOD - AUTOMETTECH LTD (UK) www.automettech.com Sub main() '========= SETTINGS ================= 'Root save directory For archive Dim archivePath archivePath = "C:\CMM\Archive\AutoArchive" 'This is the Name of a PC-Dmis ASSIGNMENT - If it exists 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 fso.copyfile source_path, dest_path 'Tidy up Set fso = Nothing Set pcpart = Nothing Set pcapp = Nothing End Sub
[SIZE=14px][FONT=times new roman][COLOR=#0000ff][COLOR=#0000ff]Sub[/COLOR][/COLOR] Main() [COLOR=#0000ff][COLOR=#0000ff]Dim[/COLOR][/COLOR] PCDApp,PCDPartProgram, PCDCommands, PCDCommand, retval [COLOR=#0000ff][COLOR=#0000ff]Dim[/COLOR][/COLOR] objFSO [COLOR=#0000ff][COLOR=#0000ff]Set[/COLOR][/COLOR] objFSO = CreateObject ("Scripting.FileSystemObject") [COLOR=#0000ff][COLOR=#0000ff]Set[/COLOR][/COLOR] PCDApp = CreateObject("PCDLRN.Application") [COLOR=#0000ff][COLOR=#0000ff]Set[/COLOR][/COLOR] PCDPartPrograms = PCDApp.PartPrograms [COLOR=#0000ff][COLOR=#0000ff]Set[/COLOR][/COLOR] PCDPartProgram = PCDApp.ActivePartProgram [COLOR=#0000ff][COLOR=#0000ff]Dim[/COLOR][/COLOR] Cmds [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Object[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Dim[/COLOR][/COLOR] Cmd [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Object[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Set[/COLOR][/COLOR] Cmds = PCDPartProgram.Commands [COLOR=#0000ff][COLOR=#0000ff]Dim[/COLOR][/COLOR] setCrntName [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]String[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Dim[/COLOR][/COLOR] PartNo [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Object[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Dim[/COLOR][/COLOR] JobNo [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Object[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Dim[/COLOR][/COLOR] SerNo [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Object[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Dim[/COLOR][/COLOR] SerialNo [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]String[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Dim[/COLOR][/COLOR] Results [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]String[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Set[/COLOR][/COLOR] PartNo = PCDPartProgram.GetVariableValue ("V5") [COLOR=#0000ff][COLOR=#0000ff]Set[/COLOR][/COLOR] JobNo = PCDPartProgram.GetVariableValue ("V1") [COLOR=#0000ff][COLOR=#0000ff]Set[/COLOR][/COLOR] SerNo = PCDPartProgram.GetVariableValue ("V2") [COLOR=#0000ff][COLOR=#0000ff]Set[/COLOR][/COLOR] Serial = PCDPartProgram.GetVariableValue ("V2") strPath = "Q:\Quality\In Process Inspection Plans\PartNo.StringValue\CMM REPORTS\" strFolderName = JobNo.StringValue & "_" & SerNo.StringValue strFolder = strPath & "\RESULTS\" & strFolderName [COLOR=#0000ff][COLOR=#0000ff]If[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Not[/COLOR][/COLOR] objFSO.FolderExists(strFolder) [COLOR=#0000ff][COLOR=#0000ff]Then[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Set[/COLOR][/COLOR] objFolder = objFSO.CreateFolder(strFolder) [COLOR=#0000ff][COLOR=#0000ff]End[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]If[/COLOR][/COLOR] SerialNo = Serial.StringValue setCrntName = PCDPartProgram.FullName newname = "Q:\Quality\In Process Inspection Plans\" & PartNo.StringValue & "\CMM REPORTS\ObjFolder\" & PCDPartProgram.PartName & " - " & SerialNo & ".PRG" retval = PCDPartProgram.SaveAs(newname) retval = PCDPartProgram.SaveAs(setCrntName) [COLOR=#007f00][COLOR=#007f00]' Cleanup [/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Set[/COLOR][/COLOR] PCDPartProgram = [COLOR=#0000ff][COLOR=#0000ff]Nothing[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Set[/COLOR][/COLOR] PCDPartPrograms = [COLOR=#0000ff][COLOR=#0000ff]Nothing[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Set[/COLOR][/COLOR] PCDApp = [COLOR=#0000ff][COLOR=#0000ff]Nothing[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]End[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Sub[/COLOR][/COLOR][/FONT][/SIZE]
© 2024 Hexagon AB and/or its subsidiaries. | Privacy Policy | Cloud Services Agreement |