본문 바로가기
  • Welcome!
VBA For Creo

BACKUP() BY PTC

by ToolBOX01 2024. 3. 20.
반응형

Creo의 Backup 기능은 선택한 파일과 종속 파일들을 사용자가 지정한 폴더에 저장 합니다.
 - 어셈블리, 드로잉 또는 제조 객체를 백업하면 Creo Parametric에서 모든 종속 파일이 지정된 디렉토리에 저장됩니다.
- 어셈블리를 백업하면, 도면은 백업이 안됩니다.
- 어셈블리, 드로어셈블리에 관련 교환 그룹이 있으면 이러한 그룹은 어셈블리를 백업할 때 백업 디렉토리에 저장되지 
  않습니다.
- 모델을 백업하고 변경한 다음 저장하면 해당 변경 내용이 항상 백업 디렉토리에 저장됩니다.

코드

Option Explicit
Public asyncConnection As IpfcAsyncConnection
Public cAC As CCpfcAsyncConnection
Public hSession As IpfcBaseSession
Public connId As IpfcConnectionId
...
'setting inside functions and sub's
....
Set asyncConnection = cAC.Connect(Null, Null, Null, timeout)
Set connId = asyncConnection.GetConnectionId
strConnId = connId.ExternalRep
...
private Sub Test_button_Click()
Dim timeout As Long
timeout = 30
Set cAC = New CCpfcAsyncConnection
Set asyncConnection = cAC.Connect(Null, Null, Null, timeout)
Set hSession = asyncConnection.Session
...

On Error GoTo ErrCatch_123
Dim descModelCreate As CCpfcModelDescriptor
Dim my_model As IpfcModel
Dim model1 As IpfcModel
Dim descModel As pfcls.IpfcModelDescriptor
'Dim descModelCreate As pfcls.CCpfcModelDescriptor
Set descModelCreate = New CCpfcModelDescriptor
Set descModel = descModelCreate.CreateFromFileName("E:\PROGRAMMING\VBA\CREO2\Excel_comp_test\plate.prt")
Set my_model = hSession.RetrieveModel(descModel)
Dim oWindow As IpfcWindow
my_model.Display
Dim descModel1 As IpfcModelDescriptor
Set descModel1 = my_model.Descr
descModel1.Path = "E:\PROGRAMMING\VBA\CREO2\Excel_comp_test\output"
my_model.Backup descModel1
Exit Sub
ErrCatch_123:
 MsgBox ("error in Sub CommandButton3_Click() :: Error NR:" + Str(Err.Number) + ": Descr:" + Err.Description)
End Sub