hexagon logo

There is a problem with the auto-save script?

Dim pcdApp As PCDLRN.Application = CreateObject("PCDLRN.Application")
Dim pcdParts As PartPrograms = pcdApp.PartPrograms
Dim pcdPart As PartProgram = pcdApp.ActivePartProgram
Dim Cmds As Object
Cmds = pcdPart.Commands
Dim Cmd As Object
Dim archivePath As String
archivePath = TextBox37.Text
Dim myUID
myUID = "UID"
pcdPart.Save()
Dim source_path
source_path = pcdPart.FullName

Dim progname As String = pcdPart.Name.Substring(0, pcdPart.Name.Length - 4)

Dim fso As Object = CreateObject("scripting.filesystemobject")


Dim ofolder As Object

If Not fso.folderexists(archivePath) Then
ofolder = Directory.CreateDirectory(archivePath)
End If

If Not fso.folderexists(archivePath & "\" & progname) Then
ofolder = Directory.CreateDirectory(Path.Combine(archivePath, progname))
End If


Dim uniqueid
uniqueid = ""

Dim myvar As Object
myvar = pcdPart.GetVariableValue(myUID)

If Not myvar Is Nothing Then
uniqueid = myvar.stringvalue

End If

Dim dest_path As String
Dim dest_path_cad As String
Dim currentTime As DateTime = DateTime.Now
Dim formattedTime As String = currentTime.ToString("yyyy年MM月dd日 HH时mm分ss秒")

dest_path = archivePath & "\" & progname & "\" & progname & "_" & uniqueid & "_" & Format(Now(), formattedTime) & ".PRG"
dest_path_cad = archivePath & "\" & progname & "\" & progname & "_" & uniqueid & "_" & Format(Now(), formattedTime) & ".CAD"


fso.copyfile(source_path, dest_path)
fso.copyfile(source_path, dest_path_cad)


fso = Nothing
pcdPart = Nothing
pcdApp = Nothing

VB.net can save CAD normally. PRG. But when I open the backup program again, there is a situation of losing 3D. How can I solve this problem?

Parents
  • Is there a reason you need to specify the CAD path? Did you make sure when loading the backup program that the CAD has the same exact name? They need to be completely identical.

    Example:

    PartName_PartNumber_20240304_095015.CAD

    PartName_PartNumber_20240304_095015.PRG

    PartName_PartNumber_20240304_095003.PRG

    If you load in the program with the wrong end date number it will not link it to the program. 

Reply
  • Is there a reason you need to specify the CAD path? Did you make sure when loading the backup program that the CAD has the same exact name? They need to be completely identical.

    Example:

    PartName_PartNumber_20240304_095015.CAD

    PartName_PartNumber_20240304_095015.PRG

    PartName_PartNumber_20240304_095003.PRG

    If you load in the program with the wrong end date number it will not link it to the program. 

Children