본문 바로가기
  • 환영 합니다 ! Welcome!
VBA For Creo

어셈블 파일 BACKUP 프로그램 ver 0.1

by ToolBOX01 2022. 9. 30.
반응형

Creo의 BackUP 기능은 3D/2D를 한번에 Copy 할수 없습니다. VBA BackUP 프로그램은 한번에 사용자가 지정한 폴더로 사본 3D /2D를 BackUP 합니다.

 

프로그램 동작 순서는 아래와 같습니다

1. Open된 Creo Top 어셈블리 파일의 모든 부품 이름들을 표시 합니다

2. 동일한 폴더에 3D 모델과 동일한 이름의 Drawing 파일들을 표시 합니다

3. 2D를 BackUP하고, 3D를  BackUP 합니다. 

 

[ VBA 엑셀 프로그램 화면]

 

도면은 하드디스크 폴더에 있지 Session에 없습니다. 각각의 도면을 Session으로 불러오고, 활성화 상태로 지정하고

도면들을 하나씩  BackUP 해야 합니다. 

 

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        Dim oSession As pfcls.IpfcBaseSession: Set oSession = conn.session
        Dim oModel As IpfcModel: Set oModel = oSession.CurrentModel
        ' Target Folder Name
        Dim oPathName As String: oPathName = Cells(2, "C")
        
        'Drawing File BackUP Count
        Dim rng As Range
        Set rng = Range("F8", Cells(Rows.count, "F").End(xlUp))
        
        Dim jCnt As Long
        Dim oCreateModelDescriptor As New CCpfcModelDescriptor
        Dim oModelDescriptor As IpfcModelDescriptor
        Dim oDrawingFileName As String
             
        For jCnt = 0 To rng.count - 1
             
            oDrawingFileName = Cells(jCnt + 8, "F")
            
            If oDrawingFileName <> "" Then
               Set oModelDescriptor = oCreateModelDescriptor.CreateFromFileName(oDrawingFileName)
               oModelDescriptor.Path = oPathName
                   
               Call oSession.RetrieveModel(oModelDescriptor)                  ' Folder에 있는 파일 Session으로 불러오기
               Set oModel = oSession.GetModel(oDrawingFileName, 2)    ' Drawing 파일 활성화 
               Call oModel.Backup(oModelDescriptor)                                ' Top 어셈블 모델 포함 Drawing File BackUP  
                   
            End If
            
        Next jCnt
        
        MsgBox ("파일 " & Cells(4, "c").Value + Cells(5, "c").Value + Cells(6, "c").Value & " 개 백업하였습니다")
            
    conn.Disconnect (2)

 

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

■ 프로그램 파일

File Rename Backup V2.xlsm
0.05MB

 

 

 

 

 

 

 

by : lionkk@idt21c.com