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

Creo Drawing In Session

by ToolBOX01 2021. 3. 8.
반응형

Creo Drawing 파일을 Session (메모리)로 불러오기

 

 

폴더에 있는 Creo 2D 파일을 Session으로 불러 오는 방법 입니다. Creo 화면에는 표시되지 않습니다.

 

It is not displayed on the Creo screen.

 

Open Button Click

 

 

Source Code

EpfcModelType.EpfcMDL_DRAWING, oFilename, ""

 

1) oFilename = tmpl_lv_001_4pin_a.drw  -> File Name 변경

 

2) EpfcMDL_ASSEMBLY

   EpfcMDL_PART
   EpfcMDL_DRAWING
   EpfcMDL_2D_SECTION
   EpfcMDL_LAYOUT
   EpfcMDL_DWG_FORMAT
   EpfcMDL_MFG
   EpfcMDL_REPORT
   EpfcMDL_MARKUP
   EpfcMDL_DIAGRAM

 

3) "" --> Nothing

 


 

Sub file_retrieves()
        Dim asynconn As New pfcls.CCpfcAsyncConnection
        Dim conn As pfcls.IpfcAsyncConnection
        Dim session As pfcls.IpfcBaseSession
    
    On Error GoTo RunError
        Set conn = asynconn.Connect("", "", ".", 5)
        Set session = conn.session
        
        Dim ModelDescriptorCreate As New CCpfcModelDescriptor
        Dim ModelDescriptor As IpfcModelDescriptor
        Dim oFilename As String
        oFilename = "tmpl_lv_001_4pin_a.drw"
        Set ModelDescriptor = ModelDescriptorCreate.Create(EpfcModelType.EpfcMDL_DRAWING, oFilename, "")
        Dim model As IpfcModel
        Set model = session.RetrieveModel(ModelDescriptor)
        
        Cells(3, "c") = model.Filename
        
       
    conn.Disconnect (2)
    
    'Cleanup
    Set asynconn = Nothing
    Set conn = Nothing
    Set session = Nothing
    Set model = Nothing
    

RunError:

    If Err.Number <> 0 Then
        MsgBox "Process Failed : Unknown error occurred." + Chr(13) + _
                "Error No: " + CStr(Err.Number) + Chr(13) + _
                "Error: " + Err.Description, vbCritical, "Error"

        If Not conn Is Nothing Then
            If conn.IsRunning Then
                conn.Disconnect (2)
            End If
        End If
    End If

End Sub

 


 

Drawing Retrieves.xlsm
0.02MB

 

 

 

Business inquiries : lionkk@idt21c.com